MSBuild可以排除“隐藏"吗?从生成的SetParameters.xml进行Web部署参数? [英] Can MSBuild exclude "Hidden" Web Deploy parameters from the generated SetParameters.xml?

查看:72
本文介绍了MSBuild可以排除“隐藏"吗?从生成的SetParameters.xml进行Web部署参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 Parameters.xml 文件中,我有几个参数,这些参数使用Web Deploy"variable"语法来引用其他参数,例如该引用IIS Web Application Name参数的参数:

In my Parameters.xml file, I have a couple of parameters that use the Web Deploy "variable" syntax to refer to other parameters, like this one that refers to the IIS Web Application Name parameter:

<parameter name="MyParam"
           defaultValue="{IIS Web Application Name}/Web.config"
           tags="Hidden"/>

我的问题是,尽管我将部署程序包标记为隐藏,但在我构建部署程序包时,VS会自动将此参数导入到我的 SetParameters.xml 文件中.通过setParamFile传递给msdeploy时,Web Deploy会将字面值解释为

My problem is that VS automatically imports this parameter into my SetParameters.xml file when I build the deployment package in spite of it being tagged as hidden. When it is passed to msdeploy via setParamFile, Web Deploy literally interprets the value of the parameter as

{IIS Web Application Name}/Web.config

而不是替换IIS应用程序名称.

rather than substituting the IIS application name.

如果我从自动生成的 SetParameters.xml 文件中删除该参数,则该变量将按预期工作.有什么方法可以阻止VS首先通过名称或标签来包含该参数?

If I remove the parameter from the auto-generated SetParameters.xml file, the variable works as expected. Is there any way to prevent VS from including that parameter in the first place, either by name or by tag?

推荐答案

考虑到我只需要在AddIisAndContentDeclareParametersItems之后的目标中添加 Hidden 标记.显然,这会在构建软件包之前在源清单中设置标签.最终看起来像这样:

I just needed to add a Hidden tag in the target that follows AddIisAndContentDeclareParametersItems. This apparently sets the tag in the source manifest prior to the package being built. It ends up looking something like this:

<Target Name="DeclareCustomParameters" 
        AfterTargets="AddIisAndContentDeclareParametersItems">
  <ItemGroup>
    <MsDeployDeclareParameters Include="Foo">
      <!-- <snip> -->
      <!-- the following elements are the important ones: -->
      <Tags>Hidden</Tags>  
      <ExcludeFromSetParameter>True</ExcludeFromSetParameter>
    </MsDeployDeclareParameters>
  </ItemGroup>
</Target>

就是这样!

这篇关于MSBuild可以排除“隐藏"吗?从生成的SetParameters.xml进行Web部署参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆