C# MSBuild目标检测到跳过的生成
当MS build构建解决方案时,它将跳过最新的项目。是否有办法在后续目标中检测到这一点,以避免进行额外的不必要的工作 这个例子是我的一个项目,在构建过程之后创建一个NuGet包,目标是后期构建目标。如果跳过构建,那么我们可以得出结论,Nuget包不需要被替换 我试过后构建和核心编译C# MSBuild目标检测到跳过的生成,c#,msbuild,C#,Msbuild,当MS build构建解决方案时,它将跳过最新的项目。是否有办法在后续目标中检测到这一点,以避免进行额外的不必要的工作 这个例子是我的一个项目,在构建过程之后创建一个NuGet包,目标是后期构建目标。如果跳过构建,那么我们可以得出结论,Nuget包不需要被替换 我试过后构建和核心编译 <Target Name="DebugProps" AfterTargets="CoreCompile"> <Message Import
<Target Name="DebugProps" AfterTargets="CoreCompile">
<Message Importance="high" Text="Current Saved Properties are:"/>
我想你可以在msbuild上使用
试试这个:
<Target Name="test123" BeforeTargets="CoreCompile">
<ItemGroup>
<File Include="$(TargetPath)"></File>
</ItemGroup>
<Copy SourceFiles="@(File)" DestinationFolder="$(SolutionDir)"></Copy>
<Message Importance="high" Text="$(TargetName)"></Message>
</Target>
<Target Name="DebugProps" AfterTargets="Build" Inputs="$(TargetPath)" Outputs="$(SolutionDir)$(TargetFileName)">
<Message Importance="high" Text="Current Saved Properties are:"/>
</Target>
我认为您可以在msbuild上使用
试试这个:
<Target Name="test123" BeforeTargets="CoreCompile">
<ItemGroup>
<File Include="$(TargetPath)"></File>
</ItemGroup>
<Copy SourceFiles="@(File)" DestinationFolder="$(SolutionDir)"></Copy>
<Message Importance="high" Text="$(TargetName)"></Message>
</Target>
<Target Name="DebugProps" AfterTargets="Build" Inputs="$(TargetPath)" Outputs="$(SolutionDir)$(TargetFileName)">
<Message Importance="high" Text="Current Saved Properties are:"/>
</Target>
我发现解决这个问题最有效的方法是设置一个名为
TargetsTriggeredByCompilation
的特殊属性,将其分配给希望在核心编译完成后调用的目标
增量构建跳过了核心编译,因此我在构建开始时将单独的属性SkipPostBuildActions
设置为true
。然后,在我希望以核心编译为条件的任何目标中,这将进一步用作条件
一旦核心编译完成,它将触发我的EnablePostBuild
target,这个目标实习生将SkipPostBuildActions
设置为false
。然后,这将启用后续构建目标
<!-- Defines Targets that should be run after Compile, but skipped if Compile doesn't take place -->
<PropertyGroup>
<TargetsTriggeredByCompilation>
$(TargetsTriggeredByCompilation);
EnablePostBuild
</TargetsTriggeredByCompilation>
</PropertyGroup>
<Target Name="EnablePostBuild">
<!-- Disable post build actions -->
<PropertyGroup>
<SkipPostBuildActions>false</SkipPostBuildActions>
</PropertyGroup>
</Target>
TargetsTriggeredByCompilation
在目标图的内部深处触发调用目标,该调用目标通过默认构建拉入。我找到了解决此问题的最有效方法,设置为将名为TargetsTriggeredByCompilation
的特殊属性分配给希望在核心编译完成后调用的目标
增量构建跳过了核心编译,因此我在构建开始时将单独的属性SkipPostBuildActions
设置为true
。然后,在我希望以核心编译为条件的任何目标中,这将进一步用作条件
一旦核心编译完成,它将触发我的EnablePostBuild
target,这个目标实习生将SkipPostBuildActions
设置为false
。然后,这将启用后续构建目标
<!-- Defines Targets that should be run after Compile, but skipped if Compile doesn't take place -->
<PropertyGroup>
<TargetsTriggeredByCompilation>
$(TargetsTriggeredByCompilation);
EnablePostBuild
</TargetsTriggeredByCompilation>
</PropertyGroup>
<Target Name="EnablePostBuild">
<!-- Disable post build actions -->
<PropertyGroup>
<SkipPostBuildActions>false</SkipPostBuildActions>
</PropertyGroup>
</Target>
TargetsTriggeredByCompilation
在使用默认版本拉入的目标图的内部深处触发调用目标。有关于此问题的更新吗?有关于此问题的更新吗?