Restore NuGet packages separately for all platforms * configurations

Turns out this is required when consuming new style .csproj NuGet references. The NuGet
restore operation generates temp files into the obj folder, which is unique per config,
so restoring just one config doesn't enable building others.

This change also switches from restoring individual projects to restoring the top level
.sln. We previously avoided that to work around a NuGet bug that is no longer relevant.
Restoring the .sln is simpler and MUCH faster.
This commit is contained in:
Shawn Hargreaves 2018-03-09 16:42:10 -08:00
Родитель 0890413d73
Коммит de83a6464b
2 изменённых файлов: 22 добавлений и 9 удалений

Просмотреть файл

@ -87,13 +87,6 @@
<AnyCPUProject Include="tools\exportsample\exportsample.csproj" />
</ItemGroup>
<!-- Restore NuGet packages for all projects -->
<ItemGroup>
<NuGetRestore Include="samples\**\packages.config" Condition="$(BuildTests)" />
<NuGetRestore Include="samples\**\*.csproj" Condition="$(BuildTests)" />
<NuGetRestore Include="winrt\**\*.csproj" Condition="$(BuildTests)" />
</ItemGroup>
<!-- Master target just chains to a bunch of workers -->
<Target Name="Build"
@ -102,7 +95,7 @@
<!-- Use batching to build each project in turn -->
<Target Name="BuildProjects"
DependsOnTargets="PrepareVersionInfo; ChooseProjectsToBuild; RestoreNuGetPackages"
DependsOnTargets="PrepareVersionInfo; ChooseProjectsToBuild; ChooseConfigurationsToRestore; RestoreNuGetPackages"
Inputs="@(ProjectsToBuild)"
Outputs="%(PlatformIndependentName)">
@ -275,6 +268,26 @@
</Target>
<Target Name="ChooseConfigurationsToRestore">
<ItemGroup>
<ProjectToRestore Include="$(MSBuildThisFileDirectory)Win2D.uap.sln" />
<!-- Expand parameter properties into item groups, so we can batch over them -->
<BuildPlatform Include="$(BuildPlatforms)" />
<BuildConfiguration Include="$(BuildConfigurations)" />
<!-- Generate the cartesian product of all platforms * configurations that we are building -->
<ConfigToRestore Include="@(ProjectToRestore)">
<Configuration>%(BuildConfiguration.Identity)</Configuration>
</ConfigToRestore>
<NuGetRestore Include="@(ConfigToRestore)" Condition="%(BuildPlatform.Identity) != AnyCPU">
<Platform>%(BuildPlatform.Identity)</Platform>
</NuGetRestore>
</ItemGroup>
</Target>
<Import Project="$(MsBuildThisFileDirectory)build\nuget-restore.targets" />
</Project>

Просмотреть файл

@ -51,6 +51,6 @@
<Target Name="RestoreNuGetPackages" DependsOnTargets="FindNuGet; CheckNuGetVersion" Condition="'@(NuGetRestore)' != ''">
<Exec Command="$(NuGetCommand) restore %(NuGetRestore.Identity) -SolutionDirectory $(MsBuildThisFileDirectory)..\ -Verbosity Detailed -NonInteractive" />
<Exec Command="(set PLATFORM=%(NuGetRestore.Platform)) &amp; (set CONFIGURATION=%(NuGetRestore.Configuration)) &amp; $(NuGetCommand) restore %(NuGetRestore.Identity) -SolutionDirectory $(MsBuildThisFileDirectory)..\ -Verbosity Detailed -NonInteractive" />
</Target>
</Project>