提交 49313696 编写于 作者: J Jason Malinowski

Consume the VS SDK build tools and targets from NuGet

The NuGet packages for the SDK don't currently support cross-targeting,
so we must pick the right version to consume based on the version of
Visual Studio you are targeting. I implement this by simply restoring
both versions, and conditioning our MSBuild includes to the right one.
The annoying bit is since we need to restore two different versions
of the same package name via NuGet, we have to put the dependencies
in separate project.json files.

Fixes #10407.
上级 18cffbe5
......@@ -34,6 +34,7 @@ UnitTestResults.html
*.nuget.props
*.nuget.targets
project.lock.json
*.project.lock.json
*_i.c
*_p.c
......
......@@ -19,6 +19,12 @@ popd
echo Restoring packages: Toolsets
call %NugetExe% restore "%~dp0build\ToolsetPackages\project.json" %NuGetAdditionalCommandLineArgs% || goto :RestoreFailed
echo Restoring packages: Toolsets (Dev14 VS SDK build tools)
call %NugetExe% restore "%~dp0build\ToolsetPackages\dev14.project.json" %NuGetAdditionalCommandLineArgs% || goto :RestoreFailed
echo Restoring packages: Toolsets (Dev15 VS SDK build tools)
call %NugetExe% restore "%~dp0build\ToolsetPackages\dev15.project.json" %NuGetAdditionalCommandLineArgs% || goto :RestoreFailed
echo Restoring packages: Samples
call %NugetExe% restore "%~dp0src\Samples\Samples.sln" %NuGetAdditionalCommandLineArgs% || goto :RestoreFailed
......@@ -29,4 +35,4 @@ exit /b 0
:RestoreFailed
echo Restore failed with ERRORLEVEL %ERRORLEVEL%
exit /b 1
\ No newline at end of file
exit /b 1
......@@ -81,7 +81,6 @@
<VisualStudioReferenceAssemblyVersion Condition="'$(VisualStudioReferenceAssemblyVersion)' == ''">$(VisualStudioReferenceMajorVersion).0.0.0</VisualStudioReferenceAssemblyVersion>
<VisualStudioCodename>Dev$(VisualStudioReferenceMajorVersion)</VisualStudioCodename>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<MinimumVisualStudioVersion>$(VisualStudioVersion)</MinimumVisualStudioVersion>
<VSLToolsPath Condition="'$(VSLToolsPath)' == ''">$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\..'))</VSLToolsPath>
......@@ -123,6 +122,22 @@
</Otherwise>
</Choose>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '15.0'">
<PropertyGroup>
<VisualStudioBuildToolsNuGetPackagePath>$(NuGetPackageRoot)\Microsoft.VSSDK.BuildTools\15.0.25201-dev15preview2</VisualStudioBuildToolsNuGetPackagePath>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<VisualStudioBuildToolsNuGetPackagePath>$(NuGetPackageRoot)\Microsoft.VSSDK.BuildTools\14.2.25201</VisualStudioBuildToolsNuGetPackagePath>
</PropertyGroup>
</Otherwise>
</Choose>
<Import Project="$(VisualStudioBuildToolsNuGetPackagePath)\build\Microsoft.VsSDK.BuildTools.props" Condition="'$(OS)' == 'Windows_NT'" />
<!-- Build reliability -->
<PropertyGroup>
<OverwriteReadOnlyFiles Condition="'$(OverwriteReadOnlyFiles)' == ''">true</OverwriteReadOnlyFiles>
......
......@@ -271,7 +271,8 @@
==================================================================================== -->
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != '' AND '$(ImportVSSDKTargets)' == 'true'" />
<Import Project="$(VisualStudioBuildToolsNuGetPackagePath)\build\Microsoft.VsSDK.BuildTools.targets" Condition="'$(ImportVSSDKTargets)' == 'true'" />
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(ImportVSSDKTargets)' == 'true'" />
<!-- ====================================================================================
......
{
"dependencies": {
"Microsoft.VSSDK.BuildTools": "14.2.25201"
},
"frameworks": {
"net46": {}
}
}
{
"dependencies": {
"Microsoft.VSSDK.BuildTools": "15.0.25201-Dev15Preview2"
},
"frameworks": {
"net46": {}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册