Forked from rschiefer/SettingParametersViaMSBuild.xml
Created
April 27, 2016 07:50
-
-
Save sliekens/dec0b31afe6338cf90d2e7c1c204abd4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<PropertyGroup> | |
<OnAfterPipelineCollectFilesPhase> | |
$(OnAfterPipelineCollectFilesPhase); | |
MSDeploySetParametersFile; | |
MSDeploySetParameters; | |
MSDeploySetParametersUpdate; | |
</OnAfterPipelineCollectFilesPhase> | |
</PropertyGroup> | |
<PropertyGroup> | |
<!--<MSDeployPublishSetParametersFile>SetParameters.Test.xml</MSDeployPublishSetParametersFile>--> | |
<!--<MSDeployPublishSetParameters>testSetting='changed_fromSetParam';IIS Web Application Name='Default Web Site/app13'</MSDeployPublishSetParameters>--> | |
<MSDeployPublishSetParametersPriority>-51</MSDeployPublishSetParametersPriority> | |
</PropertyGroup> | |
<!-- Sample Usage: msdeploy.exe ... /p:MSDeployPublishSetParameters=testSetting='changed_fromSetParam';IIS Web Application Name='Default Web Site/app13' --> | |
<!-- Seperate parameters with a semicolon (;)--> | |
<!-- Seperate name and value with an equal sign (=)--> | |
<!-- Surround values with an apostophe (')--> | |
<Target Name="MSDeploySetParameters" Condition="'$(MSDeployPublishSetParameters)'!=''" BeforeTargets="MSDeployPublish"> | |
<ItemGroup> | |
<SetParameterArguments Include="$(MSDeployPublishSetParameters)" /> | |
<SetParameters Include="$([System.Text.RegularExpressions.Regex]::Match(%(SetParameterArguments.Identity), `[^=]*(?==)`))"> | |
<value>$([System.Text.RegularExpressions.Regex]::Match(%(SetParameterArguments.Identity), `(?<==')[^']*`))</value> | |
</SetParameters> | |
</ItemGroup> | |
</Target> | |
<!-- Sample Usage: msdeploy.exe ... /p:MSDeployPublishSetParametersFile=SetParameters.Test.xml --> | |
<Target Name="MSDeploySetParametersFile" Condition="'$(MSDeployPublishSetParametersFile)'!=''" BeforeTargets="MSDeployPublish"> | |
<XmlPeek | |
XmlInputPath="$(MSDeployPublishSetParametersFile)" | |
Query="/child::node()/child::node()"> | |
<Output TaskParameter="Result" ItemName="SetParameterNodes" /> | |
</XmlPeek> | |
<ItemGroup> | |
<SetParameters Include="$([System.Text.RegularExpressions.Regex]::Match(%(SetParameterNodes.Identity), `(?<=name=")[^"]*`))"> | |
<value>$([System.Text.RegularExpressions.Regex]::Match(%(SetParameterNodes.Identity), `(?<=value=")[^"]*`))</value> | |
</SetParameters> | |
</ItemGroup> | |
</Target> | |
<Target Name="MSDeploySetParametersUpdate" > | |
<Message Text="%(SetParameters.Identity),%(SetParameters.value)" /> | |
<ItemGroup> | |
<MsDeployDeclareParameters Include="%(SetParameters.Identity)"> | |
<DefaultValue>%(SetParameters.value)</DefaultValue> | |
<Priority>$(MSDeployPublishSetParametersPriority)</Priority> | |
</MsDeployDeclareParameters> | |
</ItemGroup> | |
</Target> | |
</Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment