Last post Feb 08, 2018 03:35 AM by bruce (sqlwork.com)
Feb 07, 2018 09:49 PM|avsln|LINK
I am deploying an ASP.NET Core web application to a local IIS instance. I have a Ci/CD process setup and have been able to deploy successfully. However, on my first deploy, I got an error
Swapping to Development environment will display more detailed information about the error that occurred.
Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENTenvironment
variable to Development, and restarting the application.
I found that my web.config only had
<?xml version="1.0" encoding="utf-8"?>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
<aspNetCore processPath="dotnet" arguments=".\XXXX.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
To be able to see the error I needed to add
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
to my web.config file. I had to do this manually.
Is there any way the dotnet build command can do that for me so that it is there when I deploy? Or should I be doing it at a different stage of my build and deploy process.
Feb 08, 2018 03:10 AM|Edward Z|LINK
>> Is there any way the dotnet build command can do that for me so that it is there when I deploy? Or should I be doing it at a different stage of my build and deploy process.
I have checked
dotnet msbuild, there is no environment variable parameters, I am afraid it is impossible to specify the environment parameter for this command.
I suggest you check the available options to set the environment to see whether there is any better way for you than modifying the web.config.
# Setting the environment
Feb 08, 2018 03:35 AM|bruce (sqlwork.com)|LINK
web.config is for IIS asp.net core hosting only, its not part of .net core the create a project template has a sample web.config, but dotnet knows nothing about it.