I am building a project for several versions of the framework. And I need to output a message after building the release of each version, for this I use AfterTargets. But AfterTarget is triggered 3 times instead of the required two. What could be the reason?
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RunAnalyzersDuringBuild>False</RunAnalyzersDuringBuild>
<RunAnalyzersDuringLiveAnalysis>False</RunAnalyzersDuringLiveAnalysis>
</PropertyGroup>
<!--Multiple Revit build adjustments.-->
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<TargetFrameworks>net47; net48</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net47'">
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net48'">
</PropertyGroup>
<Target Name ="BuiltTest" BeforeTargets="Build">
<Message Importance="high" Text="BUILD: $(Configuration) $(TargetFramework)"/>
</Target>
</Project>
Output:
Rebuild started at 18:27...
1>------ Rebuild All started: Project: MSBuild, Configuration: Release Any CPU ------
Restored C:UsersmyankDocuments_code_my projectsMSBuildMSBuildMSBuild.csproj (in 2 ms).
1>MSBuild -> C:UsersmyankDocuments_code_my projectsMSBuildMSBuildbinReleasenet48MSBuild.dll
1>BUILD: Release net48
1>MSBuild -> C:UsersmyankDocuments_code_my projectsMSBuildMSBuildbinReleasenet47MSBuild.dll
1>BUILD: Release net47
1>BUILD: Release
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
========== Rebuild completed at 18:27 and took 00.775 seconds ==========
I’ve tried using other tags, but it’s still like 3 projects are being built instead of two.