我不明白目标如何相互依赖,最重要的是,变量如何通过目标图。我有一个具体的例子:CSC 目标具有AddModules
属性/属性。我想使用我的.csproj
文件进行设置。正如您将在下面看到的,我尝试了许多不同的解决方案,但我不明白为什么其中一个有效而其他无效。我在代码中写了一些我的问题:
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<TargetFrameworkProfile>Profile88</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<!--1) Why don't I get fatal error here even though <AddModules> is invalid inside the <PropertyGroup>?"-->
<!--2) Why doesn't this work (doesn't pass the AddModules to the CSC target unlike other properties like FileAlignment)?"-->
<AddModules>$(OutputPath)Ark.Weak.netmodule</AddModules>
<!--3) Why do I get the following fatal error here: "error : The attribute "Include" in element <AddModules> is unrecognized."?-->
<AddModules Include="$(OutputPath)Ark.Weak.netmodule" />
</PropertyGroup>
<ItemGroup>
<!--4) Why do I get the following fatal error here? "error : The reference to the built-in metadata "Extension" at position 1 is not allowed in this condition "'%(Extension)'=='netmodule'"."-->
<AddModules Include="@(ReferencePath)" Condition="'%(Extension)'=='netmodule'" />
<!--5) Why do I get the following fatal error here: "error : The attribute "Remove" in element <ReferencePath> is unrecognized."?-->
<ReferencePath Remove="@(AddModules)" />
<!--6) Why does this work even though <AddModules> is invalid inside the <ItemGroup>?"-->
<!--7) Why does this do the job (passes the AddModules to the CSC target)?"-->
<AddModules Include="$(OutputPath)Ark.Weak.netmodule" />
</ItemGroup>
</Project>