differencebetweendollarandatsignandpercent

Cancel Edit [WikiEntry.PreviewButtonText] Save

What is the difference between $(foo), @(foo), and %(foo)?


In a nutshell,
* $(foo) refers to a property called @foo@.
* ""@(foo)"" refers to an item list called @foo@.
* %(foo) refers to an item meta-data called @foo@.

Here is a relatively simple example of proper usage of each of these concepts:

		 <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
	
<PropertyGroup>
<OutputPath>bin\debug\</OutputPath>
</PropertyGroup>

<ItemGroup>
<Reference Include="System">
<HintPath>c:\foo\System.dll</HintPath>
</Reference>
<Reference Include="System.Xml">
<HintPath>c:\bar\System.Xml.dll</HintPath>
</Reference>
<Reference Include="System.Data">
<HintPath>c:\bing\System.Data.dll</HintPath>
</Reference>
</ItemGroup>

<Target Name="Build">
<Message Text="The OutputPath property is $(OutputPath)"/>
<Message Text="List of References is @(Reference)"/>
<Message Text="List of Reference HintPaths is @(Reference->'%(HintPath)')"/>
</Target>
		 </Project>
	

The output of this project is:

		 Target "Build" in project "example1.proj"
		    The [OutputPath] property is bin\debug\
		    List of References is System;System.Xml;System.Data
		    List of Reference [HintPaths] is c:\foo\System.dll;c:\bar\System.Xml.dll;c:\bing\System.Data.dll
	
Microsoft Communities