webdeploy - 混合 web.config 转换和 Parameters.xml,或者类似的东西

标签 webdeploy web-config-transform

我已经使用 web.config 转换一段时间了,用于部署我们的一些项目。 我现在想要实现的是让 Web Deploy 的“导入包”屏幕提示检查和更新 中的几个变量,并针对每个环境进行调整 .

我知道我可以使用 Parameters.xml引入这些可编辑变量,但我还没有找到如何为不同的环境目标更新默认值。

考虑以下简洁但不重叠的示例,希望用户编辑“specialServer”AppSetting,并在为 编译时显示不同的默认值。新环境 目标:

Parameters.xml 中的示例条目:

<parameter name="Special server" description="" tags="" defaultValue="server1-dev.domain">
    <parameterEntry kind="XmlFile" scope="\\web.config$" match="/configuration/appSettings/add[@key='specialServer']/@value" />
</parameter>

Web.NewEnv.config 的示例转换 ,为
<appSettings>
    <add key="specialServer"
        value="other-server.domain2"
        xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
</appSettings>

Web 部署中的提示示例:

enter image description here

关于如何更新不同构建目标的默认值的任何建议?

谢谢。

最佳答案

您必须生成新的参数定义文件并将其嵌入 WebDeploy为每个环境打包。

这将为每个环境提供不同的部署包,并允许您为这些参数指定不同的默认值。显然,如果参数转换并且您最终在配置中烘焙,那么这样做会破坏这一点,但这是实现您想要的唯一方法。

我不推荐这种方法,但它可能适合您的需求。

关于webdeploy - 混合 web.config 转换和 Parameters.xml,或者类似的东西,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11644269/

相关文章:

.net - ASP.NET Web.Config 转换问题

iis - Web Deploy 3.6中缺少 “Import Web Application”选项

.net - 使用 MSDeploy 自动数据库迁移

ruby - 无方法错误 : undefined method `start_with?'

asp.net - 为什么我在 Web.Release.config XML-Document-Transform 文件中收到所需的属性 'name' is missing 警告?

msbuild - 如何在转换时将 configSource 转换为 web.config 中的内联元素

angular - 如何修改 csproj PublishRunWebpack 以包含来自外部目录的静态文件

web - "the project has been modified outside the environment ,press reload to load the update project from disk"

asp.net - Web Config 转换以添加子元素

ASP.NET 网站与 Web 应用程序