Could not find 'xxx.Program' specified for

2019-09-02 04:48发布

问题:

I am having issues when building a dotnet core application inside a docker container. I am using dotnet core 2.2.

The setting for the project are: Output: Console App Startup Project: Web.Project

When running the command below inside the container:

RUN dotnet build "Web.csproj" -c Release -o /app

I get the error below:

Could not find 'Web.Program' specified for Main method [/src/Web/Web.csproj]

If the project is just an assembly (dll) everything works fine but I'm unable to run the web app.

Any ideas?

回答1:

The solution to my problem was to remove the following line from my csproj file:

<OutputType>EXE</OutputType>

It seems like visual studio 2107 adds that tag when changing the output type. Once I removed that, I was able to build and publish inside a Docker Container and Windows.