Error MSB1009: Project file does not exist is no longer a problem with this handy solution by our Support Techs.
At Bobcares, we offer solutions for every query, big and small, as a part of our Server Management Service.
Let’s take a look at how our Support Team recently helped out a customer with the error MSB1009: Project file does not exist.
How to resolve error MSB1009: Project file does not exist
Have you been facing the following messages recently?
MSBUILD: error MSB1009: Project file does not exist. Switch: ProjectName.csproj ERROR: Service 'ServiceName' failed to build: The command '/bin/sh -c dotnet restore "ProjectName.csproj"' returned a non-zero code: 1
Fortunately, our Support Techs have a solution up their sleeves. After helping several customers with a similar issue, our Support Team recommends ensuring the Dockerfile is in the root of the project. Furthermore, we have to modify the settings in the docker-compose.yml file as shown below:
FROM mcr.microsoft.com/dotnet/core/runtime:2.2-stretch-slim AS base WORKDIR /app EXPOSE PortNumberOpenedOnDatabaseServer FROM mcr.microsoft.com/dotnet/core/sdk:2.2-stretch AS build WORKDIR /src COPY ["ProjectName.csproj", "ProjectName/"] RUN dotnet restore "./ProjectName.csproj" COPY . . WORKDIR "/src/." RUN dotnet build "ProjectName.csproj" -c Release -o /app/build FROM build AS publish RUN dotnet publish "ProjectName.csproj" -c Release -o /app/publish FROM base AS final WORKDIR /app COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "ProjectName.dll"]
Here, we will build the Docker Image via the sudo docker-compose build command. We can also build and run the container at the same time by running sudo docker-compose up in the folder where docker-compose.yml is present.
According to our Support Techs, the docker-compose.yml should include the correct path for this to work seamlessly and hence no longer see this error message
When we avoid pruning images or docker containers no longer in use, the second command for building images will fail. In other words, we have to clean the Docker System with the following command:
sudo docker system prune -a
Furthermore, we can verify this with the sudo docker images command and then proceed with the sudo docker-compose build command to build images. Once we get this doen, we will not come across the MSB1009 error message.
[Looking for a solution to another query? We are just a click away.]
Conclusion
In short, the skilled Support Engineers at Bobcares demonstrated how to resolve the Project file does not exist error.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
0 Comments