【发布时间】:2015-02-12 22:19:49
【问题描述】:
当文件保存在 Visual Studio 中时,我正在尝试使用 MSBuild:Compile 生成器来触发对我的自定义文件类型的编译(应该像自定义工具一样工作,但使用 msbuild)。构建过程本身正在运行,但如果文件被保存,它似乎不会被触发。
有人能解释一下 MSBuild:Compile 条目到底在做什么吗?到目前为止,我刚刚看到它在 antlr msbuild 脚本和 XAML 中使用。
下面是我用来将 *.myext 文件编译为 *.g.ts 文件的 msbuild 设置的摘录。
我的目标文件:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="SampleNamespace.CustomCompilerTask" AssemblyFile="MyTask.dll" />
<PropertyGroup>
<PrepareResourcesDependsOn>
CustomLayoutCompile;
$(PrepareResourcesDependsOn)
</PrepareResourcesDependsOn>
</PropertyGroup>
<ItemDefinitionGroup>
<CustomTypeCompile>
<Generator>MSBuild:Compile</Generator>
</CustomTypeCompile>
</ItemDefinitionGroup>
<Target Name="CustomLayoutCompile" Inputs="@(TypeScriptCompile);@(CustomTypeCompile)" Outputs="@(CustomTypeCompile->'%(RootDir)%(Directory)%(Filename).g.ts')">
<CustomCompilerTask TypeScriptFiles="@(TypeScriptCompile)" LayoutFiles="@(CustomTypeCompile)" />
</Target>
</Project>
项目文件中的条目:
....
<ItemGroup>
<TypeScriptCompile Include="MyControl.ts">
<DependentUpon>MyControl.myext</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="MyControl.g.ts">
<DependentUpon>MyControl.myext</DependentUpon>
</TypeScriptCompile>
</ItemGroup>
<ItemGroup>
<CustomTypeCompile Include="MyControl.myext">
<Generator>MSBuild:Compile</Generator>
</CustomTypeCompile>
</ItemGroup>
....
<Import Project="path/to/my/target/file/mytargets.targets" />
....
【问题讨论】:
标签: c# visual-studio-2013 msbuild