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
An error occurred while processing your request.
Development Mode
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"?><configuration><system.webServer><handlers><add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" /></handlers><aspNetCore processPath="dotnet" arguments=".\XXXX.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" /></system.webServer></configuration><!--ProjectGuid: CA45E01E-889D-496B-9EC4-B5D751BFD84F-->
To be able to see the error I needed to add
<environmentVariables><environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" /></environmentVariables>
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.