Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 91aadd2

Browse files
committed
Restore packages in a single step, before building projects.
We've been hitting a number of concurrency issues on restore. Avoid these by running restore as a single step at the start of the build. We'll let DNX deal with concurrency via the --parallel switch.
1 parent d421196 commit 91aadd2

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

build.proj

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,27 @@
1010

1111
<Import Project="dir.traversal.targets" />
1212

13+
<PropertyGroup>
14+
<TraversalBuildDependsOn>
15+
BatchRestorePackages;
16+
$(TraversalBuildDependsOn);
17+
</TraversalBuildDependsOn>
18+
</PropertyGroup>
19+
20+
<Target Name="BatchRestorePackages">
21+
<Message Importance="High" Text="Restoring all packages..." />
22+
<!-- restore all project.jsons in one pass for perf & to avoid concurrency problems with dnu -->
23+
<Exec Command="$(DnuRestoreCommand) &quot;$(MSBuildProjectDirectory)\src&quot;" StandardOutputImportance="Low" CustomErrorRegularExpression="^Unable to locate .*" />
24+
25+
<ItemGroup>
26+
<_allPackagesConfigs Include="$(MSBuildProjectDirectory)\src\**\packages.config"/>
27+
</ItemGroup>
28+
<Exec Condition="'@(_allPackagesConfigs)' != ''" Command="$(NugetRestoreCommand) &quot;%(_allPackagesConfigs.FullPath)&quot;" StandardOutputImportance="Low" />
29+
</Target>
30+
31+
<!-- Override RestorePackages from dir.traversal.targets and do a batch restore -->
32+
<Target Name="RestorePackages" DependsOnTargets="BatchRestorePackages" />
33+
1334
<!-- Override clean from dir.traversal.targets and just remove the full BinDir -->
1435
<Target Name="Clean">
1536
<RemoveDir Directories="$(BinDir)" />

dir.props

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,16 @@
6262

6363
<DnuRestoreCommand>"$(DnuToolPath)"</DnuRestoreCommand>
6464
<DnuRestoreCommand>$(DnuRestoreCommand) restore</DnuRestoreCommand>
65+
<DnuRestoreCommand>$(DnuRestoreCommand) --parallel</DnuRestoreCommand>
6566
<DnuRestoreCommand>$(DnuRestoreCommand) --packages "$(PackagesDir.TrimEnd('/'))"</DnuRestoreCommand>
6667
<DnuRestoreCommand Condition="'$(LockDependencies)' == 'true'">$(DnuRestoreCommand) --lock</DnuRestoreCommand>
6768
</PropertyGroup>
6869

70+
<PropertyGroup Condition="'$(BuildAllProjects)'=='true'">
71+
<!-- When we do a traversal build we get all packages up front, don't restore them again -->
72+
<RestorePackages>false</RestorePackages>
73+
</PropertyGroup>
74+
6975
<!--
7076
Set up Roslyn predefines
7177
-->

0 commit comments

Comments
 (0)