Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Core- wrong processPath in generated web.config

I have rather strange problem.

One of the applications we are working on stopped working after publish to Azure Web App. Everything works ok locally. After long investigation, the culprit is that the web.config generated by the build (in VSTFS) has this:

<aspNetCore processPath=".\SomeServiceName.Api " stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />

While the correct one is: <aspNetCore processPath=".\SomeServiceName.Api.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />

Note the missing .exe.

The build output of the project is set to Console Application. It's ASP.NET Core app, running on full framwork. The build is run using Visual Studio Build task in VSTS, with following MSBuildArguments:

/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)"

If I run the build on my dev machine, using MSBuild cli, with the same command line arguments, I get this:

<aspNetCore processPath="dotnet" arguments=".\SomeServiceName.Api.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />

The project is using <Project Sdk="Microsoft.NET.Sdk.Web">.

I'm guessing I could just add web.config to the project (it's not there at all now) and have it in source control the way I want, that should fix my immidiate problem of broken deployments. But I would like to know:

  1. The web.config genrated by build on VSTS is obviously wrong. Is that a bug in Microsoft.NET.SDK.Web thing?
  2. I don't have access to the actuall build server. I'm guessing that the only reasonable explanation is that someone updated .net core SDK, which is why the behaviour changed. Does this make sense? Does the msbuild targets come from .NET Core SDK, or is that part of visual studio?
  3. I'm getting different web.config on my machine. Why is that?

Update:
For anyone who stumbles here, here's the link for issue on github: https://github.com/aspnet/websdk/issues/408
Looks like this is now fixed and will be part of some release some day (No idea what's the release cycle though).

like image 979
Botis Avatar asked Sep 03 '18 14:09

Botis


People also ask

What is web config in ASP NET Core?

The web.config is a file that is read by IIS and the ASP.NET Core Module to configure an app hosted with IIS. In order to set up the ASP.NET Core Module correctly, the web.config file must be present at the content root path (typically the app base path) of the deployed app.

How do I configure the ASP NET Core Module?

The ASP.NET Core Module is configured with the aspNetCore section of the system.webServer node in the site's web.config file. The following web.config file is published for a framework-dependent deployment and configures the ASP.NET Core Module to handle site requests:

What happens when a web config file is transformed in IIS?

If a web.config file is present in the project, the file is transformed with the correct processPath and arguments to configure the ASP.NET Core Module and moved to published output. The transformation doesn't modify IIS configuration settings in the file.

How do I publish ASP NET Core from Visual Studio?

When publishing from Visual Studio and using a publish profile, see Visual Studio publish profiles (.pubxml) for ASP.NET Core app deployment. The ASPNETCORE_ENVIRONMENT environment variable is automatically added to the web.config file when the environment name is specified.


1 Answers

I had exactly the same problem, and I solved it last week. We had 2 ASP.Net Core projects, one showing the issue, the other didn't have the issue.

Firstly check C:\Program Files\dotnet path, if the 'sdk' folder is not available then you need to install the ASP.NET Core SDK. If you install this package then problem is resolved and hte app is running with:

<aspNetCore processPath="dotnet" arguments=".\yourapp.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout"/>

like image 142
a patidar Avatar answered Oct 10 '22 10:10

a patidar