I’ve added a bundler to my ASP.NET Core project. Now I’m using the <environment>
tag helpers to reference the bundled files in production mode.
<environment exclude="Development">
<link rel="stylesheet" href="~/css/site-bundle.min.css" />
<link rel="stylesheet" href="~/css/layout-bundle.min.css" />
</environment>
<environment include="Development">
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
<link rel="stylesheet" href="~/css/site.css" />
<link rel="stylesheet" href="~/layout/css/app.css" />
<link rel="stylesheet" href="~/layout/css/style.css" />
</environment>
But how do I test production mode. I thought doing a release build would suffice but it’s still using the development version of the markup.
2
Answers
With the ASPNETCORE_ENVIRONMENT environment variable set to Production or other value than Development.
Maybe you use a launchSettings.json file? Also, you can pass the variable as a command-line parameter in most cases. There are many options.
For more information: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-6.0
Step 1 : You need to add new Profile in launchsettings.json file.
launchsettings
Step 2 :
Set "ASPNETCORE_ENVIRONMENT": "Production".
Step 3 :
Run project with this Profile.
Profile
Step : 4
You show environment is now production.
environment