You can simply do this:
<PropertyGroup> <TargetsTriggeredByCompilation>DoStuffWithNewlyCompiledAssembly</TargetsTriggeredByCompilation> </PropertyGroup>
This works because someone smart at Microsoft added the following line at the end of the Microsoft.[CSharp|VisualBasic][.Core].targets CoreCompile target Microsoft.[CSharp|VisualBasic][.Core].targets (the file name depends on the language and version of MSBuild / Visual Studio).
<CallTarget Targets="$(TargetsTriggeredByCompilation)" Condition="'$(TargetsTriggeredByCompilation)' != ''"/>
So, if you specify the target name in the TargetsTriggeredByCompilation property, your target will be launched if CoreCompile running - and your target will not be launched if CoreCompile is skipped (for example, because the assembly assembly is already enabled, at the moment with respect to the code).
weir
source share