Reputation: 353
I am new to Docker and am trying to create a Dockerfile for an ASP.NET Core application. What changes do I require?
Here is my Dockerfile:
FROM microsoft/dotnet:2.1-sdk
WORKDIR /app
COPY Presentation/ECCP.Web/ *.csproj ./
RUN dotnet restore
COPY . ./
RUN dotnet publish -c Release -o out
FROM microsoft/aspnetcore:2.0
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "api.dll"]
I am facing the following error:
MSBUILD : error MSB1011: Specify which project or solution file to use because this folder contains more than one project or solution file. The command '/bin/sh -c dotnet publish -c Release -o out' returned a non-zero code: 1
Upvotes: 35
Views: 74514
Reputation: 480
If you're using bitbucket-pipelines.yml in a Bitbucket pipeline, ensure you have the following line in the step where you run Sonar scanner.
- dotnet dotcover test <your-solution-filename-here>.sln -c Release --dcReportType=HTML
Upvotes: 0
Reputation: 2403
It looks like your work directory contains both .csproj and .sln files. Try to specify the .sln file in the command.
Run
dotnet publish your-solution-file.sln -c Release -o out
I had the same error message with dotnet build
, and this solved it.
By the way, since .NET Core 2.0, the dotnet restore
command is run implicitly, so you may skip it.
Upvotes: 58
Reputation: 101
When you first open your project, a new file will be generated by the plugin that breaks the application and stops it from running.
Be default, the file is named filename.generated.sln
which is seem by .NET as a second solution filename.generated
and the original solution "filename" as named by the file "filename.csprpoj".
Because .NET views this as a second solution, this causes an error when you attempt to run the project with dotnet watch run
MSBUILD : error MSB1011: Specify which project or solution file to use because this folder contains more than one project or solution file.
If you see this error, a quick fix is to rename the file filename.generated.sln
to match the csproj file's name filename.sln
The team behind the C# Dev Kit plugin has already started the process of fixing the issue, but in the meantime I hope this helps anyone who runs into the problem.
Upvotes: 10
Reputation: 151
It's possible that you have an automatically generated sln file that you can delete. Once you delete the sln file, the build will use the csproj file.
The sln file will have a name like this:
your-projectname.generated.sln
Upvotes: 9