[英]C# - Custom Environment Variable in Publish Profile
We are using .Net Core 3.1 and we have multiple publish profiles.我们正在使用.Net Core 3.1并且我们有多个发布配置文件。 In each there is
每一个里面都有
<EnvironmentName>Development</EnvironmentName>
or Production etc. I would like to add another variable which is named by me.或生产等。我想添加另一个由我命名的变量。
Unfortunately you can not register any other environment variables when you publish, only the EnvironmentName.不幸的是,您在发布时无法注册任何其他环境变量,只能注册 EnvironmentName。
The same thing can be achieved like同样的事情可以实现
dotnet publish -c Debug -r win-x64 /p:EnvironmentName=Development
if you want to clear out your csproj file.如果你想清除你的 csproj 文件。
Coming back to environment variables, I can see two solutions:回到环境变量,我可以看到两种解决方案:
You can only set the environment variable in your publish profile.您只能在发布配置文件中设置环境变量。 You can name it anything you want.
您可以随意命名。 To set other variables you would have to use web.config transformations .
要设置其他变量,您必须使用web.config transformations 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.