Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dotnet publish and web.config?

How I understand it is that web.config is required when running an ASP.NET Core web application on Azure App Service:

<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="dotnet" arguments=".\MyProgram.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
  </system.webServer>
</configuration>

dotnet publish -c Release doesn't create this web.config, so I created itself and put it in the solution (odd, because I've never had to do this before).

But the issue I am experiencing is that it does not publish the web.config file? It seems to ignores it.

The only way I can get my application working in the Web App is to manually copy the web.config file into the wwwroot folder using Kudu.

Note: This is a framework-dependent deployment (FDD), not self-contained, and using .NET Core 2.

like image 277
Dave New Avatar asked Apr 12 '18 10:04

Dave New


People also ask

What does .NET publish do?

dotnet publish compiles the application, reads through its dependencies specified in the project file, and publishes the resulting set of files to a directory. The output includes the following assets: Intermediate Language (IL) code in an assembly with a dll extension.

Does .NET Core still use Web config?

ASP.NET Core no longer uses the Global. asax and web. config files that previous versions of ASP.NET utilized.

What is the difference between dotnet build and dotnet publish?

Build compiles the source code into a (hopefully) runnable application. Publish takes the results of the build, along with any needed third-party libraries and puts it somewhere for other people to run it.


1 Answers

We finally figured it out. The project type was incorrect. It needs to be:

<Project Sdk="Microsoft.NET.Sdk.Web">

And not

<Project Sdk="Microsoft.NET.Sdk">
like image 126
Dave New Avatar answered Oct 01 '22 12:10

Dave New