Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Put the values in an external xml file. Read the values from the xml file into a variable.</p> <p>Parameters.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;parameters&gt; &lt;setParameter name="LineNumber1" value="PeanutsAreCool" /&gt; &lt;setParameter name="LineNumber2" value="" /&gt; &lt;/parameters&gt; </code></pre> <p>MyMsbuild_MsBuildExtensions.proj </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="AllTargetsWrapped"&gt; &lt;Import Project="$(MSBuildExtensionsPath)\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks"/&gt; &lt;PropertyGroup&gt; &lt;!-- Always declare some kind of "base directory" and then work off of that in the majority of cases --&gt; &lt;WorkingCheckout&gt;.&lt;/WorkingCheckout&gt; &lt;/PropertyGroup&gt; &lt;Target Name="AllTargetsWrapped"&gt; &lt;CallTarget Targets="ReadXmlPeekValue" /&gt; &lt;/Target&gt; &lt;Target Name="ReadXmlPeekValue"&gt; &lt;!-- ReadAttribute --&gt; &lt;MSBuild.ExtensionPack.Xml.XmlFile TaskAction="ReadAttribute" File="$(WorkingCheckout)\Parameters.xml" XPath="/parameters/setParameter[@name='LineNumber1']/@value"&gt; &lt;Output PropertyName="MyValue1" TaskParameter="Value"/&gt; &lt;/MSBuild.ExtensionPack.Xml.XmlFile&gt; &lt;Message Text="MyValue1 = $(MyValue1)"/&gt; &lt;/Target&gt; &lt;/Project&gt; </code></pre> <p>OR</p> <p>MyMsbuild_WithCommunityTasks.proj </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="AllTargetsWrapped"&gt; &lt;!-- &lt;UsingTask AssemblyFile="$(ProgramFiles)\MSBuild\MSBuild.Community.Tasks.dll" TaskName="Version"/&gt; --&gt; &lt;Import Project="$(MSBuildExtensionsPath32)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" /&gt; &lt;PropertyGroup&gt; &lt;!-- Always declare some kind of "base directory" and then work off of that in the majority of cases --&gt; &lt;WorkingCheckout&gt;.&lt;/WorkingCheckout&gt; &lt;/PropertyGroup&gt; &lt;Target Name="AllTargetsWrapped"&gt; &lt;CallTarget Targets="ReadXmlPeekValue" /&gt; &lt;/Target&gt; &lt;Target Name="ReadXmlPeekValue"&gt; &lt;!-- you do not need a namespace for this example, but I left it in for future reference --&gt; &lt;XmlPeek Namespaces="&amp;lt;Namespace Prefix='peanutNamespace' Uri='http://schemas.microsoft.com/developer/msbuild/2003'/&amp;gt;" XmlInputPath=".\Parameters.xml" Query="/parameters/setParameter[@name='LineNumber1']/@value"&gt; &lt;Output TaskParameter="Result" ItemName="Peeked" /&gt; &lt;/XmlPeek&gt; &lt;Message Text="@(Peeked)"/&gt; &lt;XmlPeek Namespaces="&amp;lt;Namespace Prefix='peanutNamespace' Uri='http://schemas.microsoft.com/developer/msbuild/2003'/&amp;gt;" XmlInputPath=".\Parameters.xml" Query="/parameters/setParameter[@name='LineNumber1']/@value"&gt; &lt;Output TaskParameter="Result" PropertyName="PeekedSingle" /&gt; &lt;/XmlPeek&gt; &lt;Message Text="PeekedSingle = $(PeekedSingle) "/&gt; &lt;/Target&gt; &lt;/Project&gt; </code></pre> <p>EDIT:</p> <p>You can add some basic error checking for the values.</p> <p>See URL here:</p> <p><a href="http://tutorials.csharp-online.net/MSBuild:_By_Example%E2%80%94Dealing_with_MSBuild_Errors" rel="nofollow">http://tutorials.csharp-online.net/MSBuild:_By_Example%E2%80%94Dealing_with_MSBuild_Errors</a></p> <p>Short example.. note the condition..and how it checks for an empty string.</p> <pre><code> &lt;Error Text="Unable to connect to webserver" Code="Deploy" Condition=" '$(WebURL)' == '' "/&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload