Home > Mobile >  How to test production mode
How to test production mode

Time:05-27

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.

CodePudding user response:

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.

dotnet run ASPNETCORE_ENVIRONMENT=Production

For more information: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-6.0

CodePudding user response:

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

  • Related