Created
April 26, 2016 19:12
-
-
Save rschiefer/428a8c6de9dfc43e8b48c8181970fc9f to your computer and use it in GitHub Desktop.
This file contains 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>-100</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