Created
March 20, 2010 11:55
-
-
Save esfand/338629 to your computer and use it in GitHub Desktop.
MSBuild Property Demo
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 ToolsVersion="4.0" | |
DefaultTargets="PrintValues" | |
xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<PropertyGroup> | |
<Add>$([MSBuild]::Add(5,9))</Add> | |
<Subtract01>$([MSBuild]::Subtract(90,768))</Subtract01> | |
<Mult01>$([MSBuild]::Multiply(4,9))</Mult01> | |
<Div01>$([MSBuild]::Divide(100,5.2))</Div01> | |
</PropertyGroup> | |
<PropertyGroup> | |
<SampleString>This is a sample string</SampleString> | |
<SampleString2> This is a sample string </SampleString2> | |
<!-- Here we now can call instance methods on the String class --> | |
<Sub04>$(SampleString.Substring(0,4))</Sub04> | |
<Contains01>$(SampleString.Contains("This"))</Contains01> | |
<Contains02>$(SampleString.Contains("this"))</Contains02> | |
<CompareTo01>$(SampleString.CompareTo($(SampleString)))</CompareTo01> | |
<EndsWith01>$(SampleString.CompareTo("string"))</EndsWith01> | |
<Insert01>$(SampleString.Insert(2,"INSERTED"))</Insert01> | |
<Trim01>$(SampleString2.Trim())</Trim01> | |
</PropertyGroup> | |
<PropertyGroup> | |
<!-- | |
Here we Now01 can call static methods/properties on many types | |
See http://msdn.microsoft.com/en-us/library/dd633440%28VS.100%29.aspx | |
for the list of classes that we can call static methods/properties on. | |
--> | |
<Now01>$([System.DateTime]::Now)</Now01> | |
<Pow01>$([System.Math]::Pow(2,3))</Pow01> | |
<TempFile01>$([System.IO.Path]::GetTempFileName())</TempFile01> | |
</PropertyGroup> | |
<Target Name="PrintValues"> | |
<Message Text="Add: $(Add)" Importance="high"/> | |
<Message Text="Subtract01: $(Subtract01)" Importance="high"/> | |
<Message Text="Mult01: $(Mult01)" Importance="high"/> | |
<Message Text="Div01: $(Div01)" Importance="high"/> | |
<Message Text="-----------------------"/> | |
<Message Text="Now01: $(Now01)" Importance="high"/> | |
<Message Text="Pow01: $(Pow01)" Importance="high"/> | |
<Message Text="TempFile01: $(TempFile01)" Importance="high"/> | |
<Message Text="-----------------------"/> | |
<Message Text="SampleString: $(SampleString)" Importance="high"/> | |
<Message Text="Sub04: $(Sub04)" Importance="high"/> | |
<Message Text="Contains01: $(Contains01)" Importance="high"/> | |
<Message Text="Contains02: $(Contains02)" Importance="high"/> | |
<Message Text="CompareTo01: $(CompareTo01)" Importance="high"/> | |
<Message Text="EndsWith01: $(EndsWith01)" Importance="high"/> | |
<Message Text="Insert01: $(Insert01)" Importance="high"/> | |
<Message Text="Trim01: $(Trim01)" Importance="high"/> | |
<Message Text="-----------------------"/> | |
<Message Text="MSBuild: $(MSBuild)"/> | |
<Message Text="MSBuildBinPath: $(MSBuildBinPath)"/> | |
<Message Text="MSBuildExtensionsPath: $(MSBuildExtensionsPath)"/> | |
<Message Text="MSBuildExtensionsPath32: $(MSBuildExtensionsPath32)"/> | |
<Message Text="MSBuildExtensionsPath64: $(MSBuildExtensionsPath64)"/> | |
<Message Text="MSBuildLastTaskResult: $(MSBuildLastTaskResult)"/> | |
<Message Text="MSBuildNodeCount: $(MSBuildNodeCount)"/> | |
<Message Text="MSBuildOverrideTasksPath: $(MSBuildOverrideTasksPath)"/> | |
<Message Text="MSBuildProgramFiles32: $(MSBuildProgramFiles32)"/> | |
<Message Text="MSBuildProjectDefaultTargets: $(MSBuildProjectDefaultTargets)"/> | |
<Message Text="MSBuildProjectDirectory: $(MSBuildProjectDirectory)"/> | |
<Message Text="MSBuildProjectDirectoryNoRoot: $(MSBuildProjectDirectoryNoRoot)"/> | |
<Message Text="MSBuildProjectExtension: $(MSBuildProjectExtension)"/> | |
<Message Text="MSBuildProjectFile: $(MSBuildProjectFile)"/> | |
<Message Text="MSBuildProjectFullPath: $(MSBuildProjectFullPath)"/> | |
<Message Text="MSBuildProjectName: $(MSBuildProjectName)"/> | |
<Message Text="MSBuildStartupDirectory: $(MSBuildStartupDirectory)"/> | |
<Message Text="MSBuildThisFile: $(MSBuildThisFile)"/> | |
<Message Text="MSBuildThisFileDirectory: $(MSBuildThisFileDirectory)"/> | |
<Message Text="MSBuildThisFileDirectoryNoRoot: $(MSBuildThisFileDirectoryNoRoot)"/> | |
<Message Text="MSBuildThisFileExtension: $(MSBuildThisFileExtension)"/> | |
<Message Text="MSBuildThisFileFullPath: $(MSBuildThisFileFullPath)"/> | |
<Message Text="MSBuildThisFileName: $(MSBuildThisFileName)"/> | |
<Message Text="MSBuildToolsPath: $(MSBuildToolsPath)"/> | |
<Message Text="MSBuildToolsVersion: $(MSBuildToolsVersion)"/> | |
</Target> | |
</Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment