Skip to content

Commit 23b5136

Browse files
committed
Invoke PrivateP2PCaching.proj fewer times
* We can invoke it once instead of twice by invoking the two targets we need in one MSBuild call. Only a small gain expected by this. * We are more careful to keep the set of global properties the same across many project invocations so that we don't get multiple project instances with global properties such as Configuration and Platform that may vary by caller. Closes #1262
1 parent 543debd commit 23b5136

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/Nerdbank.GitVersioning.Tasks/build/MSBuildTargetCaching.targets

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<ItemGroup>
2323
<NBGV_CachingProjectReference Include="$(NBGV_CachingProjectReference)">
2424
<Targets>GetBuildVersion_Properties;GetBuildVersion_CloudBuildVersionVars</Targets>
25-
<Properties>$(NBGV_InnerGlobalProperties)BuildMetadata=@(BuildMetadata, ',');PrereleaseIdentifiers=@(PrereleaseIdentifier, ',')</Properties>
25+
<Properties>$(NBGV_InnerGlobalProperties)BuildMetadata=@(BuildMetadata, ',');PrereleaseIdentifiers=@(PrereleaseIdentifier, ',');Configuration=Release;Platform=AnyCPU</Properties>
2626
<SetConfiguration>Configuration=Release</SetConfiguration>
2727
<SetPlatform>Platform=AnyCPU</SetPlatform>
2828
<GlobalPropertiesToRemove>@(NBGV_GlobalPropertiesToRemove)</GlobalPropertiesToRemove>
@@ -50,18 +50,14 @@
5050
<!-- Calculate version by invoking another "project" with global properties that will serve as a key
5151
into an msbuild cache to ensure we only invoke the GetBuildVersion task as many times as will produce a unique value. -->
5252
<MSBuild Projects="@(NBGV_CachingProjectReference)"
53-
Properties="%(NBGV_CachingProjectReference.Properties)"
5453
RemoveProperties="%(NBGV_CachingProjectReference.GlobalPropertiesToRemove)"
55-
Targets="GetBuildVersion_Properties">
56-
<Output TaskParameter="TargetOutputs" ItemName="NBGV_PropertyItems" />
54+
Targets="GetBuildVersion_Properties;GetBuildVersion_CloudBuildVersionVars">
55+
<Output TaskParameter="TargetOutputs" ItemName="_NBGV_PropertiesAndVersionVars" />
5756
</MSBuild>
5857

59-
<!-- Also get other items. -->
60-
<MSBuild Projects="@(NBGV_CachingProjectReference)"
61-
Properties="%(NBGV_CachingProjectReference.Properties)"
62-
RemoveProperties="%(NBGV_CachingProjectReference.GlobalPropertiesToRemove)"
63-
Targets="GetBuildVersion_CloudBuildVersionVars">
64-
<Output TaskParameter="TargetOutputs" ItemName="CloudBuildVersionVars" />
65-
</MSBuild>
58+
<ItemGroup>
59+
<NBGV_PropertyItems Include="@(_NBGV_PropertiesAndVersionVars)" Condition="'%(MSBuildSourceTargetName)'=='GetBuildVersion_Properties'" />
60+
<CloudBuildVersionVars Include="@(_NBGV_PropertiesAndVersionVars)" Condition="'%(MSBuildSourceTargetName)'=='GetBuildVersion_CloudBuildVersionVars'" />
61+
</ItemGroup>
6662
</Target>
6763
</Project>

0 commit comments

Comments
 (0)