Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can MSBuild exclude "Hidden" Web Deploy parameters from the generated SetParameters.xml?

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"/>

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

rather than substituting the IIS application name.

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?

like image 806
ladenedge Avatar asked Mar 27 '26 15:03

ladenedge


1 Answers

This was actually far easier than I thought, given the answer to my earlier question.

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>

That was it!

like image 63
ladenedge Avatar answered Mar 31 '26 06:03

ladenedge



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!