Change AspNetCoreHostingModel During DevOps Deploy

huangapple go评论135阅读模式
英文:

Change AspNetCoreHostingModel During DevOps Deploy

问题

我有大量的应用程序部署到多个环境中。我想在Azure DevOps的发布过程中将asp net core的托管模型更改为outofprocess。

我目前使用'Web Deploy'方法进行部署,发布中似乎有应用程序设置和配置设置可用,但我找不到如何将其指定为参数。

是否有一个标志我可以在配置设置中应用?

编辑Web应用配置设置,遵循以下语法 -key value。包含空格的值应该用双引号括起来。
示例:-phpVersion 5.6 -linuxFxVersion: node|6.11

或者我应该尝试将其作为XML变量替换?Microsoft希望它在.csproj文件中定义,但它不是一个.xml文件,所以我不确定它是否会按预期工作。而且,要使替代工作,键必须已经存在于文件中,即使它支持csproj文件。

在构建或发布管道中定义的变量将与任何配置文件和parameters.xml中的appSettings、applicationSettings和connectionStrings部分中的'key'或'name'条目匹配。变量替换在配置变换之后运行。

注意:如果在发布管道和环境中都定义了相同的变量,那么环境变量将替代发布管道变量。

https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/out-of-process-hosting?view=aspnetcore-7.0

我已经查看了一段时间,但尚未找到解决方法。是否有人已经做过类似的事情?
如果我找到解决方法,我将回来更新它。

英文:

I have a plethora of applications deploying to multiple environments. I want to change the asp net core hosting model to outofprocess as part of my release process in Azure DevOps.

I am currently deploying with 'Web Deploy' method and there appears to be app settings and configuration settings available as part of the release, but I cannot find how to specify it as a parameter.

Is there a flag I can apply in config settings?

Edit web app configuration settings following the syntax -key value. Value containing spaces should be enclosed in double quotes.
Example : -phpVersion 5.6 -linuxFxVersion: node|6.11

Or should I try it as an XML variable substitution? The .csproj file that Microsoft wants it defined in is XML but it's not an .xml file, so I'm not sure if it would work as expected. Also, the key would have to be present in that file already for the substitution to work, if it even supports csproj files.

Variables defined in the build or release pipelines will be matched against the 'key' or 'name' entries in the appSettings, applicationSettings, and connectionStrings sections of any config file and parameters.xml. Variable Substitution is run after config transforms.

Note: If same variables are defined in the release pipeline and in the environment, then the environment variables will supersede the release pipeline variables.

https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/out-of-process-hosting?view=aspnetcore-7.0

I have been looking at this for some time but haven't found a solution for it yet. Has anyone already done something like this?
I will come back to update it if I find a solution.

答案1

得分: 0

My ultimate solution was not pretty, but it worked. All the three methods of setting this value ultimately instructs the build process to generate a web.config with the parameter 'inprocess' or 'outofprocess'

https://stackoverflow.com/a/68271160/5597085

For only the environment which I want to run out of process, I ran a powershell script:

$webConfig = "(buildpath)\web.config"
(Get-Content -Path $webConfig) -replace "inprocess", "OutOfProcess" | Set-Content -Path $webConfig

It worked fine.

英文:

My ultimate solution was not pretty, but it worked. All the three methods of setting this value ultimately instructs the build process to generate a web.config with the parameter 'inprocess' or 'outofprocess'

https://stackoverflow.com/a/68271160/5597085

For only the environment which I want to run out of process, I ran a powershell script:

$webConfig = "(buildpath)\web.config"
(Get-Content -Path $webConfig) -replace "inprocess", "OutOfProcess" | Set-Content -Path $webConfig

It worked fine.

huangapple
  • 本文由 发表于 2023年4月11日 04:56:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/75980655.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定