Skip to content

Commit

Permalink
Update InstallVisualStudio.ps1 to support VS2022 preview (dotnet#34401)
Browse files Browse the repository at this point in the history
* Update InstallVisualStudio.ps1 to support VS2022 preview

* Update eng/scripts/InstallVisualStudio.ps1

Co-authored-by: Doug Bunting <[email protected]>

* Remove Windows 10 SDK component from global.json

* PR feedback

* Update vs.buildtools.json for VS2022

* Create vs.16.buildtools.json

* Demo a .vcxproj change

- this should work 😺 
- suggest duplicating this in the other .vcxproj files if I'm right

* Make native projects toolset version conditional for VS2022 support

Co-authored-by: Doug Bunting <[email protected]>
  • Loading branch information
DamianEdwards and dougbu authored Jul 16, 2021
1 parent 57ecf81 commit 9217656
Show file tree
Hide file tree
Showing 17 changed files with 139 additions and 50 deletions.
37 changes: 28 additions & 9 deletions eng/scripts/InstallVisualStudio.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
Selects which channel of Visual Studio to install. Must be one of these values:
Release (the default)
Preview
.PARAMETER Version
Selects which version of Visual Studio to install. Must be one of these values:
2019 (the default)
2022
.PARAMETER InstallPath
The location on disk where Visual Studio should be installed or updated. Default path is location of latest
existing installation of the specified edition, if any. If that VS edition is not currently installed, default
path is '${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\`$Edition".
path is '${env:ProgramFiles(x86)}\Microsoft Visual Studio\`$Version\`$Edition".
.PARAMETER Passive
Run the installer without requiring interaction.
.PARAMETER Quiet
Expand All @@ -34,6 +38,8 @@ param(
[string]$Edition = 'Enterprise',
[ValidateSet('Release', 'Preview')]
[string]$Channel = 'Release',
[ValidateSet('2019', '2022')]
[string]$Version = '2019',
[string]$InstallPath,
[switch]$Passive,
[switch]$Quiet
Expand All @@ -59,29 +65,36 @@ mkdir $intermedateDir -ErrorAction Ignore | Out-Null
$bootstrapper = "$intermedateDir\vsinstaller.exe"
$ProgressPreference = 'SilentlyContinue' # Workaround PowerShell/PowerShell#2138

$channelUri = "https://aka.ms/vs/16/release"
$responseFileName = "vs"
if ("$Version" -eq "2019") {
$vsversion = 16;
}
if ("$Version" -eq "2022") {
$vsversion = 17;
$Channel = "Preview";
}
$channelUri = "https://aka.ms/vs/$vsversion/release"
$responseFileName = "vs.$vsversion"
if ("$Edition" -eq "BuildTools") {
$responseFileName += ".buildtools"
}
if ("$Channel" -eq "Preview") {
$responseFileName += ".preview"
$channelUri = "https://aka.ms/vs/16/pre"
$channelUri = "https://aka.ms/vs/$vsversion/pre"
}

$responseFile = "$PSScriptRoot\$responseFileName.json"
$channelId = (Get-Content $responseFile | ConvertFrom-Json).channelId

$bootstrapperUri = "$channelUri/vs_$($Edition.ToLowerInvariant()).exe"
Write-Host "Downloading Visual Studio 2019 $Edition ($Channel) bootstrapper from $bootstrapperUri"
Write-Host "Downloading Visual Studio $Version $Edition ($Channel) bootstrapper from $bootstrapperUri"
Invoke-WebRequest -Uri $bootstrapperUri -OutFile $bootstrapper

$productId = "Microsoft.VisualStudio.Product.$Edition"
if (-not $InstallPath) {
$vsWhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
if (Test-Path $vsWhere)
{
$installations = & $vsWhere -version '[16,17)' -format json -prerelease -products $productId | ConvertFrom-Json |Sort-Object -Descending -Property installationVersion, installDate
$installations = & $vsWhere -version "[$vsversion,$($vsversion+1)))" -format json -prerelease -products $productId | ConvertFrom-Json |Sort-Object -Descending -Property installationVersion, installDate
foreach ($installation in $installations) {
Write-Host "Found '$($installation.installationName)' in '$($installation.installationPath)', channel = '$($installation.channelId)'"
if ($installation.channelId -eq $channelId) {
Expand All @@ -93,10 +106,16 @@ if (-not $InstallPath) {
}

if (-not $InstallPath) {
if ($vsversion -eq "16") {
$pathPrefix = "${env:ProgramFiles(x86)}";
}
if ($vsversion -eq "17") {
$pathPrefix = "${env:ProgramFiles}";
}
if ("$Channel" -eq "Preview") {
$InstallPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\${Edition}_Pre"
$InstallPath = "$pathPrefix\Microsoft Visual Studio\$Version\${Edition}_Pre"
} else {
$InstallPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\$Edition"
$InstallPath = "$pathPrefix\Microsoft Visual Studio\$Version\$Edition"
}
}

Expand All @@ -121,7 +140,7 @@ if ($Quiet) {
}

Write-Host
Write-Host "Installing Visual Studio 2019 $Edition ($Channel)" -f Magenta
Write-Host "Installing Visual Studio $Version $Edition ($Channel)" -f Magenta
Write-Host
Write-Host "Running '$bootstrapper $arguments'"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
"Microsoft.VisualStudio.Workload.VisualStudioExtensionBuildTools",
"Microsoft.VisualStudio.Workload.WebBuildTools"
]
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 25 additions & 0 deletions eng/scripts/vs.17.buildtools.preview.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"channelUri": "https://aka.ms/vs/17/pre/channel",
"channelId": "VisualStudio.17.Preview",
"includeRecommended": false,
"addProductLang": [
"en-US"
],
"add": [
"Microsoft.Net.Component.4.6.1.TargetingPack",
"Microsoft.Net.Component.4.7.2.SDK",
"Microsoft.Net.Component.4.7.2.TargetingPack",
"Microsoft.VisualStudio.Component.FSharp.MSBuild",
"Microsoft.VisualStudio.Component.NuGet",
"Microsoft.VisualStudio.Component.NuGet.BuildTools",
"Microsoft.VisualStudio.Component.VC.ATL",
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
"Microsoft.VisualStudio.Component.Windows10SDK.18362",
"Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools",
"Microsoft.VisualStudio.Workload.MSBuildTools",
"Microsoft.VisualStudio.Workload.NetCoreBuildTools",
"Microsoft.VisualStudio.Workload.VCTools",
"Microsoft.VisualStudio.Workload.VisualStudioExtensionBuildTools",
"Microsoft.VisualStudio.Workload.WebBuildTools"
]
}
20 changes: 20 additions & 0 deletions eng/scripts/vs.17.preview.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"channelUri": "https://aka.ms/vs/17/pre/channel",
"channelId": "VisualStudio.17.Preview",
"includeRecommended": false,
"addProductLang": [
"en-US"
],
"add": [
"Microsoft.Net.Component.4.6.1.TargetingPack",
"Microsoft.Net.Component.4.7.2.SDK",
"Microsoft.Net.Component.4.7.2.TargetingPack",
"Microsoft.VisualStudio.Component.VC.ATL",
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
"Microsoft.VisualStudio.Component.Windows10SDK.18362",
"Microsoft.VisualStudio.Workload.ManagedDesktop",
"Microsoft.VisualStudio.Workload.NativeDesktop",
"Microsoft.VisualStudio.Workload.NetWeb",
"Microsoft.VisualStudio.Workload.VisualStudioExtension"
]
}
3 changes: 1 addition & 2 deletions global.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
"version": "16.8",
"components": [
"Microsoft.VisualStudio.Component.VC.ATL",
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
"Microsoft.VisualStudio.Component.Windows10SDK.17134"
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64"
]
},
"xcopy-msbuild": "16.5.0-alpha"
Expand Down
13 changes: 8 additions & 5 deletions src/Servers/IIS/AspNetCoreModuleV2/AspNetCore/AspNetCore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@
<ProjectName>AspNetCore</ProjectName>
<TargetName>aspnetcorev2</TargetName>
<LinkIncremental>false</LinkIncremental>
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition=" '$(VisualStudioVersion)' == '17.0' ">10.0.18362.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition=" '$(WindowsTargetPlatformVersion)' == '' ">10.0.17134.0</WindowsTargetPlatformVersion>
<PlatformToolsetVersion Condition=" '$(VisualStudioVersion)' == '17.0' ">v143</PlatformToolsetVersion>
<PlatformToolsetVersion Condition=" '$(PlatformToolsetVersion)' == '' ">v142</PlatformToolsetVersion>
<OutDirName>AspNetCoreModuleShim</OutDirName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
Expand All @@ -43,26 +46,26 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>$(PlatformToolsetVersion)</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64' OR '$(Configuration)|$(Platform)'=='Debug|Any CPU'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>$(PlatformToolsetVersion)</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>$(PlatformToolsetVersion)</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64' OR '$(Configuration)|$(Platform)'=='Release|Any CPU'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>$(PlatformToolsetVersion)</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
Expand Down
13 changes: 8 additions & 5 deletions src/Servers/IIS/AspNetCoreModuleV2/CommonLib/CommonLib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
<ProjectGuid>{55494E58-E061-4C4C-A0A8-837008E72F85}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>NewCommon</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition=" '$(VisualStudioVersion)' == '17.0' ">10.0.18362.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition=" '$(WindowsTargetPlatformVersion)' == '' ">10.0.17134.0</WindowsTargetPlatformVersion>
<PlatformToolsetVersion Condition=" '$(VisualStudioVersion)' == '17.0' ">v143</PlatformToolsetVersion>
<PlatformToolsetVersion Condition=" '$(PlatformToolsetVersion)' == '' ">v142</PlatformToolsetVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
Expand All @@ -40,26 +43,26 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>$(PlatformToolsetVersion)</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>$(PlatformToolsetVersion)</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64' OR '$(Configuration)|$(Platform)'=='Debug|Any CPU'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>$(PlatformToolsetVersion)</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64' OR '$(Configuration)|$(Platform)'=='Release|Any CPU'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>$(PlatformToolsetVersion)</PlatformToolset>
<WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{1eac8125-1765-4e2d-8cbe-56dc98a1c8c1}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition=" '$(VisualStudioVersion)' == '17.0' ">10.0.18362.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition=" '$(WindowsTargetPlatformVersion)' == '' ">10.0.17134.0</WindowsTargetPlatformVersion>
<PlatformToolsetVersion Condition=" '$(VisualStudioVersion)' == '17.0' ">v143</PlatformToolsetVersion>
<PlatformToolsetVersion Condition=" '$(PlatformToolsetVersion)' == '' ">v142</PlatformToolsetVersion>
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>$(PlatformToolsetVersion)</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<IsTestProject>true</IsTestProject>
<DisableArcadeTestFramework>true</DisableArcadeTestFramework>
Expand Down
13 changes: 8 additions & 5 deletions src/Servers/IIS/AspNetCoreModuleV2/IISLib/IISLib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
<Keyword>Win32Proj</Keyword>
<RootNamespace>IISLib</RootNamespace>
<ProjectName>IISLib</ProjectName>
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition=" '$(VisualStudioVersion)' == '17.0' ">10.0.18362.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition=" '$(WindowsTargetPlatformVersion)' == '' ">10.0.17134.0</WindowsTargetPlatformVersion>
<PlatformToolsetVersion Condition=" '$(VisualStudioVersion)' == '17.0' ">v143</PlatformToolsetVersion>
<PlatformToolsetVersion Condition=" '$(PlatformToolsetVersion)' == '' ">v142</PlatformToolsetVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
Expand All @@ -40,26 +43,26 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>$(PlatformToolsetVersion)</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64' OR '$(Configuration)|$(Platform)'=='Debug|Any CPU'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>$(PlatformToolsetVersion)</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>$(PlatformToolsetVersion)</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64' OR '$(Configuration)|$(Platform)'=='Release|Any CPU'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>$(PlatformToolsetVersion)</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
<ProjectGuid>{D57EA297-6DC2-4BC0-8C91-334863327863}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>InProcessRequestHandler</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition=" '$(VisualStudioVersion)' == '17.0' ">10.0.18362.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition=" '$(WindowsTargetPlatformVersion)' == '' ">10.0.17134.0</WindowsTargetPlatformVersion>
<PlatformToolsetVersion Condition=" '$(VisualStudioVersion)' == '17.0' ">v143</PlatformToolsetVersion>
<PlatformToolsetVersion Condition=" '$(PlatformToolsetVersion)' == '' ">v142</PlatformToolsetVersion>
<ProjectName>InProcessRequestHandler</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
Expand All @@ -42,26 +45,26 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>$(PlatformToolsetVersion)</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>$(PlatformToolsetVersion)</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64' OR '$(Configuration)|$(Platform)'=='Debug|Any CPU'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>$(PlatformToolsetVersion)</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64' OR '$(Configuration)|$(Platform)'=='Release|Any CPU'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>$(PlatformToolsetVersion)</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
Expand Down
Loading

0 comments on commit 9217656

Please sign in to comment.