Hi
I have a couple of questions:
dotnet publish like dotnet publish --environment "Development" or no? if yes how? dotnet publish?⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
Hello!
I'm not sure what you mean by environment do you mean the --configuration switch for Debug or Release?
Project warnings should not prevent you from publishing. Project errors would.
Hi again
Excuse me for not being enough clear.
By the term environment I mean ASPNETCORE_ENVIRONMENT environment variable or generally any environment variable.
And I know that warnings are not prevent the build or publish process but I want them to be hide so I can get more concentrated info
No worries!
To hide the warnings, try passing this switch to MSBuild (which is what the dotnet publish command uses) stackoverflow question/answer
/p:WarningLevel=0
Environment variable, no. Since environment variables are consumed by your app but set by the host, you need to configure the host some how. For example, if you're going to deploy to the cloud, the cloud provider usually has an option to set the environment variables for your app. If you're deploying to someone's machine, you might want to supply as startup script for them to run. You can have your app detect the value of that variable and then output an error if it's not what you're expecting.
I think your questions are answered. I'm going to close this issue. Thanks!
In case anyone arrives here looking to transform their web.config via dotnet publish, you can do this with (for example):
dotnet publish -o site /p:EnvironmentName=Staging
Adds the following to your web.config in the publish directory:
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Staging" />
Most helpful comment
In case anyone arrives here looking to transform their web.config via dotnet publish, you can do this with (for example):
dotnet publish -o site /p:EnvironmentName=Staging
Adds the following to your web.config in the publish directory:
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Staging" />