目前我正在尝试创建一个 Web 部署包。所以我在我的项目的根目录中添加了一个 parameters.xml 并指定了一些自定义参数。
我发现我的很多参数都部分相同。所以我想做某种参数引用。寻找这个,我来了 Reference for the Web Application Package .在那里它说如下:
Hidden - A Hidden parameter is not shown to the user as part of the installation UI. A Hidden parameter must have a defaultValue set. These parameters are used either to set a hard-coded default value or to set a computed default value. Hard-coded defaults are sometimes used when establishing a parameter for future use. Computed values are used to construct a parameter’s value from other parameters. When constructing computed values, you can refer to other parameters by putting the other parameter name surrounded by {}s in the place you want the value. Please refer to the "Connection String" parameter in the example for a common usage of this tag.
因此,根据文档,可以从“vdeDashboardAddress”中引用参数“vdeHostName”,方法是在“vdeDashboardAddress”上设置属性 defaultValue="https://{vdeHostname}/"和 tags="Hidden"。
这让我找到了 parameters.xml 的以下代码:
<parameters>
<parameter name="vdeHostname" description="Please provide the hostname" defaultValue="www.test.com">
<description culture="en">The hostname of the website.</description>
<parameterEntry kind="XmlFile"
scope="obj\\Release\\Package\\PackageTmp\\Configuration\\hosts\.config$"
match="/hostConfigurationSection/hostConfigurations/add[@name='Default']/@host" />
</parameter>
<parameter name="vdeDashboardAddress" defaultValue="https://{vdeHostname}/" tags="Hidden">
<description culture="en">The https address of the Dashboard.</description>
<parameterEntry kind="XmlFile"
scope="obj\\Release\\Package\\PackageTmp\\Configuration\\identity\.config$"
match="/system.identityModel/identityConfiguration[@name='Default']/audienceUris/add/@value" />
</parameter>
<parameters>
然而,情况似乎并非如此。它不会引用/替换 defaultValue 中的属性部分。
目前正在输出:
<audienceUris>
<add value="https://{vdeHostname}/" />
</audienceUris>
我在这里找到的唯一一个提到我的问题的帖子是 How to get Deploy.cmd to fill in replacement fields from Parameters.xml
先感谢您!
最好的问候, rdvanbuuren
最佳答案
我不确定,但 scope
属性对我来说看起来很可疑。我面前的(工作)参数文件中的所有范围元素的形式都是 scope="\\Path\\To\\File\.extension$"
假定指定的路径从部署应用程序的根文件夹开始。 (例如,最常见的是 scope="\\Web\.config$"
。)我的工作文件中的所有范围属性都不包括路径的 Package\PackageTmp 部分,即使该路径存在于 WebDeploy 使用的 zip 文件中。
关于parameters - MsDeploy parameters.xml : howto refer a parameter?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23150728/