ASP.NET Core IIS - Application failed to start process with commandline '%LAUNCHER_PATH% %LAUNCHER_ARGS%'
After deploying an ASP.NET Core application to IIS, it failed to start with the following error message:
Application 'MACHINE/WEBROOT/APPHOST/SampleApp/' with physical root 'C:\Sites\sampleapp\' failed to start process with commandline '%LAUNCHER_PATH% %LAUNCHER_ARGS%', ErrorCode = '0x80070002' : 0.
So what is going on?
By default when you add a web.config file to your ASP.NET core project, the following configuration is added:
You see the 2 environment variables'(%LAUNCHER_PATH%, %LAUNCHER_ARGS%) that are added to the config and also mentioned in the error message above. These 2 variables are their for Visual Studio and are replaced by Visual Studio when you try build and run your app.
For example when you do a debug build, the web.config is transformed to:
<aspNetCore processPath="C:\Program Files\dotnet\dotnet.exe" arguments="exec "C:\projects\sampleapp\bin\Release\netcoreapp2.2\sampleapp.dll"" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
MsBuild applies the same magic when you package and deploy your application. The problem was that we were using web.config transformations. These web.config transformation were executed after the ‘replace magic’ re-introducing these placeholder variables. This meant we ended up with these placeholders in our deployed application where IIS had no clue what to do with it.
More information here: https://github.com/vijayrkn/webconfigtransform/blob/master/README.md