title: C# compile error: Can't find main from *.csproj file
body: <p>I got a C#/Docker project from a coworker and have to use it with my own service. It is an REST API. My coworker used Visual Studio Community 2019 for this. I now want to run it on a linux machine with docker installed.
  There is a docker file. When I run docker build I get an error message that there is no main method specified in the *.csproj file. Therefore I specified the startup object in the csproj file. It was missing before.</p>
  
  <pre><code>&lt;Project Sdk="Microsoft.NET.Sdk.Web"&gt;
  
    &lt;PropertyGroup&gt;
      &lt;TargetFramework&gt;netcoreapp2.1&lt;/TargetFramework&gt;
      &lt;DockerDefaultTargetOS&gt;Linux&lt;/DockerDefaultTargetOS&gt;
      &lt;StartupObject&gt;Program&lt;/StartupObject&gt; // &lt;-- I added this line nothing else
    &lt;/PropertyGroup&gt;
  
    &lt;ItemGroup&gt;
      &lt;Folder Include="wwwroot\" /&gt;
    &lt;/ItemGroup&gt;
  
    &lt;ItemGroup&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.App" /&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" /&gt;
      &lt;PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.4.10" /&gt;
      &lt;PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.9" /&gt;
    &lt;/ItemGroup&gt;
  
  &lt;/Project&gt;
  </code></pre>
  
  <p>But I still get an error message, when running docker build:</p>
  
  <pre><code>user@notebook:~/Schreibtisch/DeviceApi/DeviceApi$ sudo docker build -t deviceApi .
  [...]
  CSC : error CS1555: Could not find 'Program' specified for Main method [/src/DeviceApi/DeviceApi.csproj]
  </code></pre>
  
  <p>The project structure is as follows.
  There is a directory named DeviceApi. That's my working directory (as you can see from my command line aboce).
  In that directory there are these files next to the other project files: Dockerfile, DeviceApi.csproj, Program.cs (which contains the main method)</p>
  
  <pre><code>user@notebook:~/Schreibtisch/DeviceApi/DeviceApi$ ls
  appsettings.Development.json  DeviceApi.csproj             Program.cs
  appsettings.json              DeviceApi.csproj.user        Properties
  bin                           Handler                      ResponseFilter
  Controllers                   Startup.cs                   DBManager
  Models                        Util                         Dockerfile
  obj                           wwwroot
  </code></pre>
  
  <p>Here is the content of the Dockerfile:</p>
  
  <pre><code>FROM mcr.microsoft.com/dotnet/core/aspnet:2.1-stretch-slim AS base
  WORKDIR /app
  EXPOSE 80
  EXPOSE 443
  
  FROM mcr.microsoft.com/dotnet/core/sdk:2.1-stretch AS build
  WORKDIR /src
  COPY ["DeviceApi.csproj", "DeviceApi/"]
  RUN dotnet restore "DeviceApi/DeviceApi.csproj"
  COPY . .
  WORKDIR "/src/DeviceApi"
  RUN dotnet build "DeviceApi.csproj" -c Release -o /app
  
  FROM build AS publish
  RUN dotnet publish "DeviceApi.csproj" -c Release -o /app
  
  FROM base AS final
  WORKDIR /app
  COPY --from=publish /app .
  ENTRYPOINT ["dotnet", "DeviceApi.dll"]
  </code></pre>
  
  <p>Here is the content of Program.cs:</p>
  
  <pre><code>namespace DeviceApi
  {
      public class Program
      {
  
          public static ILogger&lt;Program&gt; LOGGER = null;
          public static IConfiguration CONF = null;
          public static void Main(string[] args)
          {
              var host = CreateWebHostBuilder(args).Build();
              LOGGER = host.Services.GetRequiredService&lt;ILogger&lt;Program&gt;&gt;();
              CONF = Startup.Configuration;
              host.Run();
          }
  
          public static IWebHostBuilder CreateWebHostBuilder(string[] args) =&gt; [...] ;
      }
  }
  </code></pre>
  
  <p>My coworker used Visual Studio for this.
  I didn't use C# before and only have little experience with Visual Studio. I guess/hope there is a small user error on my side, but I don't know what I did wrong.</p>
  
  <p>Thanks for your effort.</p>