我对MS Build相当陌生,一直在审查随Visual Studio一起提供的许多内置目标文件。我看到了几种不同的传递变量的方式,但不太确定它们之间的区别:
$(...)
@(...)
%(...)
我对MS Build相当陌生,一直在审查随Visual Studio一起提供的许多内置目标文件。我看到了几种不同的传递变量的方式,但不太确定它们之间的区别:
$(...)
@(...)
%(...)
$(...)
用于访问Property
值(有关Property元素的更多信息)
<PropertyGroup>
<Configuration>Debug</Configuration>
</PropertyGroup>
<Message Text="Configuration = $(Configuration)"/>
@(...)
用于访问Item
的值(有关Item元素的更多信息)
<ItemGroup>
<Reference Include="System.Data"/>
<Reference Include="System.Web.*"/>
</ItemGroup>
<Message Text="References = @(Reference)"/>
<ItemGroup>
<Compile Include="Account\ChangePassword.aspx.cs">
<DependentUpon>ChangePassword.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
<Compile/>
</ItemGroup>
<Message Text="Element @(Compile) of subtype %(SubType) and depend of %(DependentUpon)"/>
美元符号 - $(MyProp): 允许您引用 PropertyGroups 中指定的值。
At 符号 - @(CodeFile): 允许您引用 ItemGroups 中指定的项目列表。
百分号 - %(CodeFile.BatchNum): 允许您使用元数据引用分组后的 ItemGroup 值。这比较复杂,请务必查看文档以获取更多信息。
请查看每个链接以获取有关如何使用它们的更详细信息。祝你好运 -- 希望这有所帮助!
<ItemGroup>
<IntermediateAssembly Include="$(IntermediateOutputPath)$(TargetName)$(TargetExt)"/>
</ItemGroup>
<PropertyGroup>
<_AssemblyTimestampBeforeCompile>%(IntermediateAssembly.ModifiedTime)</_AssemblyTimestampBeforeCompile>
</PropertyGroup>