我有几组项目,集合部分相交。所有集都包含源文件。每个这样的集合必须单独编译。我希望实现这一目标的方式是通过使用元数据,但我无法弄清楚方法。以下是我的设置:
<Content Include="src\Source.ts">
<Integration>integration</Integration>
<Development>development</Development>
</Content>
... <!-- more sources -->
<DeployLabel Include="deploy\integration\foo.js">
<Dir>integration\</Dir>
</DeployLabel>
... <!-- more targets --->
<DeployLabel Include="deploy\integration\bar.js">
<Dir>development\</Dir>
</DeployLabel>
<Target Inputs="@(DeployLabel)" Name="GenericDeploy" Outputs="%(Identity).Dummy">
<PropertyGroup>
<Deployroot>deploy\%(DeployLabel.Dir)</Deployroot>
</PropertyGroup>
<Message Text="Deploying: $$(Deploydir)"/>
<!-- how to select here only the TypeScriptCompile files
such that have metadata matching DeployLabel.Dir -->
<Exec Command="tsc --target ES3 -c -d --out $$(Deployroot) @(TypeScriptCompile ->'"%(fullpath)"', ' ')"/>
</Target>
我正在生成项目文件,所以如果它可以以不同方式完成,但是以自动方式完成 - 那也没关系。
答案 0 :(得分:0)
您可以使用条件和批处理来过滤项目。 如果我需要项目的元数据,我会根据情况使用两种方法。
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<DeployLabel Include="deploy\integration\foo.js">
<Dir>integration\</Dir>
<T>1</T>
</DeployLabel>
<DeployLabel Include="deploy\integration\foo2.js">
<Dir>integration\</Dir>
<T>2</T>
</DeployLabel>
<DeployLabel Include="deploy\integration\foo3.js">
<Dir>integration\</Dir>
<T>3</T>
</DeployLabel>
<DeployLabel Include="deploy\integration\bar.js">
<Dir>development\</Dir>
<T>0</T>
</DeployLabel>
</ItemGroup>
<Target Name="Filter1">
<ItemGroup>
<_DeployLabelHelper Include="%(DeployLabel.Identity)" Condition=" 'integration\' == '%(DeployLabel.Dir)' " />
</ItemGroup>
<Message Text="@(_DeployLabelHelper->'%(Identity):%(T)')"/>
</Target>
<Target Name="Filter2">
<ItemGroup>
<_RemovalHelper Include="%(DeployLabel.Identity)" Condition=" 'integration\' != '%(DeployLabel.Dir)' " />
<_DeployLabelHelper Include="@(DeployLabel)" />
<_DeployLabelHelper Remove="@(_RemovalHelper)" />
</ItemGroup>
<Message Text="@(_DeployLabelHelper->'%(Identity):%(T)')"/>
</Target>
</Project>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<DeployLabel Include="deploy\integration\foo.js">
<Dir>integration\</Dir>
<T>1</T>
</DeployLabel>
<DeployLabel Include="deploy\integration\foo2.js">
<Dir>integration\</Dir>
<T>2</T>
</DeployLabel>
<DeployLabel Include="deploy\integration\foo3.js">
<Dir>integration\</Dir>
<T>3</T>
</DeployLabel>
<DeployLabel Include="deploy\integration\bar.js">
<Dir>development\</Dir>
<T>0</T>
</DeployLabel>
</ItemGroup>
<Target Name="Filter1">
<ItemGroup>
<_DeployLabelHelper Include="%(DeployLabel.Identity)" Condition=" 'integration\' == '%(DeployLabel.Dir)' " />
</ItemGroup>
<Message Text="@(_DeployLabelHelper->'%(Identity):%(T)')"/>
</Target>
<Target Name="Filter2">
<ItemGroup>
<_RemovalHelper Include="%(DeployLabel.Identity)" Condition=" 'integration\' != '%(DeployLabel.Dir)' " />
<_DeployLabelHelper Include="@(DeployLabel)" />
<_DeployLabelHelper Remove="@(_RemovalHelper)" />
</ItemGroup>
<Message Text="@(_DeployLabelHelper->'%(Identity):%(T)')"/>
</Target>
</Project>