Skip to content

Commit

Permalink
Auto-Restore Build.sln (#2333)
Browse files Browse the repository at this point in the history
* Add auto restore project
  • Loading branch information
bbowman committed Mar 28, 2017
1 parent 4768a1e commit 0e068e4
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 1 deletion.
15 changes: 15 additions & 0 deletions build/build.sln
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,8 @@ Project("{5DD5E4FA-CB73-4610-85AB-557B54E96AA9}") = "WinObjC.Frameworks.UWP.Core
EndProject
Project("{13B669BE-BB05-4DDF-9536-439F39A36129}") = "NuprojInitializer", "..\common\NuprojInitializer.msbuildproj", "{417B0D00-F90E-47BB-9085-BE7E412C9DA8}"
EndProject
Project("{13B669BE-BB05-4DDF-9536-439F39A36129}") = "NugetRestore", "..\common\NugetRestore.msbuildproj", "{B2C6186E-B340-49D8-888E-76ED83752E43}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -2326,6 +2328,18 @@ Global
{417B0D00-F90E-47BB-9085-BE7E412C9DA8}.Release|ARM.Build.0 = Release|Any CPU
{417B0D00-F90E-47BB-9085-BE7E412C9DA8}.Release|x86.ActiveCfg = Release|Any CPU
{417B0D00-F90E-47BB-9085-BE7E412C9DA8}.Release|x86.Build.0 = Release|Any CPU
{B2C6186E-B340-49D8-888E-76ED83752E43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B2C6186E-B340-49D8-888E-76ED83752E43}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B2C6186E-B340-49D8-888E-76ED83752E43}.Debug|ARM.ActiveCfg = Debug|Any CPU
{B2C6186E-B340-49D8-888E-76ED83752E43}.Debug|ARM.Build.0 = Debug|Any CPU
{B2C6186E-B340-49D8-888E-76ED83752E43}.Debug|x86.ActiveCfg = Debug|Any CPU
{B2C6186E-B340-49D8-888E-76ED83752E43}.Debug|x86.Build.0 = Debug|Any CPU
{B2C6186E-B340-49D8-888E-76ED83752E43}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B2C6186E-B340-49D8-888E-76ED83752E43}.Release|Any CPU.Build.0 = Release|Any CPU
{B2C6186E-B340-49D8-888E-76ED83752E43}.Release|ARM.ActiveCfg = Release|Any CPU
{B2C6186E-B340-49D8-888E-76ED83752E43}.Release|ARM.Build.0 = Release|Any CPU
{B2C6186E-B340-49D8-888E-76ED83752E43}.Release|x86.ActiveCfg = Release|Any CPU
{B2C6186E-B340-49D8-888E-76ED83752E43}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -2689,5 +2703,6 @@ Global
{DFDF94D9-2A0A-4F9B-953B-6BF383858AD3} = {4BC1549F-F4C2-42D0-9F77-C323F751EA04}
{59537C2B-0319-49A8-9E2E-EEA635EEE515} = {6950E151-2219-4A37-9137-0AEAE08428E4}
{417B0D00-F90E-47BB-9085-BE7E412C9DA8} = {7B338049-F463-44B0-B7BD-F8EA16750085}
{B2C6186E-B340-49D8-888E-76ED83752E43} = {7B338049-F463-44B0-B7BD-F8EA16750085}
EndGlobalSection
EndGlobal
36 changes: 36 additions & 0 deletions common/NugetRestore.msbuildproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|AnyCPU">
<Configuration>Debug</Configuration>
<Platform>AnyCPU</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|AnyCPU">
<Configuration>Release</Configuration>
<Platform>AnyCPU</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<OutputPath>$(SolutionDir)</OutputPath>
<ProjectGuid>B2C6186E-B340-49D8-888E-76ED83752E43</ProjectGuid>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="CreateManifestResourceNames" />
<Target Name="CoreCompile" />
<Target Name="GetReferenceAssemblyPaths" />
<Target Name="CopyFilesToOutputDirectory" />
<Target Name="_GenerateCompileDependencyCache" />

<Target Name="Build">
<Message Text="EnsureSolutionRestored: Restoring solution $(SolutionPath)" Importance="High" Condition="'$(SolutionDir)' != '' And '$(BuildingInsideVisualStudio)' == 'true' And '$(BuildingPackage)' != 'true'"/>
<!-- First check that there is a valid nuget.exe to use -->
<Exec Condition="!Exists('$(MSBuildThisFileDirectory)..\.tools\nuget.exe') And '$(SolutionDir)' != '' And '$(BuildingInsideVisualStudio)' == 'true' And '$(BuildingPackage)' != 'true'" Command="init.cmd" WorkingDirectory="$(MSBuildThisFileDirectory)..\"/>

<!-- Now restore the solution -->
<Exec Command="$(MSBuildThisFileDirectory)..\.tools\nuget.exe restore $(SolutionPath)" Condition="'$(SolutionDir)' != '' And '$(BuildingInsideVisualStudio)' == 'true' And '$(BuildingPackage)' != 'true'"/>
</Target>

</Project>
15 changes: 15 additions & 0 deletions common/winobjc.packagereference.override.targets
Original file line number Diff line number Diff line change
Expand Up @@ -178,5 +178,20 @@
<LockGitVersion Condition="'$(SolutionDir)' != ''" SolutionPath="$(SolutionDir)$(SolutionName)" Unlock="true"/>
</Target>

<!--
Work around issue with new PackageReference style of Restore. This style doesn't auto-restore in viusal studio when building (at least not for .vcxproj)
Instead of relying on the automatic behavior in Visual Studio, manually restore by having one project that all other projects depend on that does the restore. This should NOT be needed in the hopefully near future.
NOTE: To make this work, this project MUST be added to the solution so that Visual Studio can see it and build it before building any projects that
depend on it.
-->
<ItemGroup>
<ProjectReference Include="$(MSBuildThisFileDirectory)\NugetRestore.msbuildproj">
<Project>{B2C6186E-B340-49D8-888E-76ED83752E43}</Project>
<IncludeInPackage>false</IncludeInPackage>
<Private>false</Private>
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
</ProjectReference>
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion init.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@echo off
powershell -ExecutionPolicy Bypass -Command .\init.ps1
powershell -noprofile -ExecutionPolicy Bypass -Command .\init.ps1
set PATH=%~dp0.tools;%~dp0.tools\VSS.NuGet.AuthHelper;%PATH%

0 comments on commit 0e068e4

Please sign in to comment.