2019-12-13 09:48:00 -05:00
|
|
|
################################################################################
|
2023-11-16 11:20:11 +01:00
|
|
|
## File: Install-VisualStudio.ps1
|
2020-09-10 17:04:24 +03:00
|
|
|
## Desc: Install Visual Studio
|
2019-12-13 09:48:00 -05:00
|
|
|
################################################################################
|
2023-12-04 10:50:53 +01:00
|
|
|
$vsToolset = (Get-ToolsetContent).visualStudio
|
2019-12-13 09:48:00 -05:00
|
|
|
|
2025-02-28 18:25:17 +00:00
|
|
|
if (Test-IsWin19) {
|
|
|
|
|
# Install Visual Studio for Windows 19
|
|
|
|
|
Install-VisualStudio `
|
|
|
|
|
-Version $vsToolset.subversion `
|
|
|
|
|
-Edition $vsToolset.edition `
|
|
|
|
|
-Channel $vsToolset.channel `
|
|
|
|
|
-RequiredComponents $vsToolset.workloads `
|
2025-06-30 21:33:57 -04:00
|
|
|
-ExtraArgs "--allWorkloads --includeRecommended --remove Component.CPython3.x64"
|
2025-02-28 18:25:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( (Test-IsWin22) -or (Test-IsWin25) ) {
|
|
|
|
|
# Install Visual Studio for Windows 22 and 25 with InstallChannel
|
|
|
|
|
Install-VisualStudio `
|
|
|
|
|
-Version $vsToolset.subversion `
|
|
|
|
|
-Edition $vsToolset.edition `
|
|
|
|
|
-Channel $vsToolset.channel `
|
|
|
|
|
-InstallChannel $vsToolset.installChannel `
|
|
|
|
|
-RequiredComponents $vsToolset.workloads `
|
2025-06-30 21:33:57 -04:00
|
|
|
-ExtraArgs "--allWorkloads --includeRecommended --remove Component.CPython3.x64"
|
2025-02-28 18:25:17 +00:00
|
|
|
}
|
2019-12-13 09:48:00 -05:00
|
|
|
|
2020-09-10 17:04:24 +03:00
|
|
|
# Find the version of VS installed for this instance
|
|
|
|
|
# Only supports a single instance
|
|
|
|
|
$vsProgramData = Get-Item -Path "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances"
|
|
|
|
|
$instanceFolders = Get-ChildItem -Path $vsProgramData.FullName
|
|
|
|
|
|
2023-11-16 11:20:11 +01:00
|
|
|
if ($instanceFolders -is [array]) {
|
2023-12-04 10:50:53 +01:00
|
|
|
throw "More than one instance installed"
|
2020-09-10 17:04:24 +03:00
|
|
|
}
|
|
|
|
|
|
2019-12-13 09:48:00 -05:00
|
|
|
# Updating content of MachineState.json file to disable autoupdate of VSIX extensions
|
2021-10-06 13:44:09 +03:00
|
|
|
$vsInstallRoot = (Get-VisualStudioInstance).InstallationPath
|
2019-12-13 09:48:00 -05:00
|
|
|
$newContent = '{"Extensions":[{"Key":"1e906ff5-9da8-4091-a299-5c253c55fdc9","Value":{"ShouldAutoUpdate":false}},{"Key":"Microsoft.VisualStudio.Web.AzureFunctions","Value":{"ShouldAutoUpdate":false}}],"ShouldAutoUpdate":false,"ShouldCheckForUpdates":false}'
|
2020-07-22 14:04:40 +03:00
|
|
|
Set-Content -Path "$vsInstallRoot\Common7\IDE\Extensions\MachineState.json" -Value $newContent
|
2019-12-13 09:48:00 -05:00
|
|
|
|
2020-07-24 18:43:19 +03:00
|
|
|
if (Test-IsWin19) {
|
2023-11-16 11:20:11 +01:00
|
|
|
# Install Windows 10 SDK version 10.0.14393.795
|
2023-11-22 15:14:08 +01:00
|
|
|
Install-Binary -Type EXE `
|
|
|
|
|
-Url 'https://go.microsoft.com/fwlink/p/?LinkId=838916' `
|
|
|
|
|
-InstallArgs @("/q", "/norestart", "/ceip off", "/features OptionId.WindowsSoftwareDevelopmentKit") `
|
2025-06-30 21:33:57 -04:00
|
|
|
-ExpectedSubject 'CN=Microsoft Corporation, OU=MOPR, O=Microsoft Corporation, L=Redmond, S=Washington, C=US'
|
2023-12-04 10:50:53 +01:00
|
|
|
|
2023-11-16 11:20:11 +01:00
|
|
|
# Install Windows 11 SDK version 10.0.22621.0
|
2023-11-22 15:14:08 +01:00
|
|
|
Install-Binary -Type EXE `
|
|
|
|
|
-Url 'https://go.microsoft.com/fwlink/p/?linkid=2196241' `
|
|
|
|
|
-InstallArgs @("/q", "/norestart", "/ceip off", "/features OptionId.UWPManaged OptionId.UWPCPP OptionId.UWPLocalized OptionId.DesktopCPPx86 OptionId.DesktopCPPx64 OptionId.DesktopCPParm64") `
|
2025-06-30 21:33:57 -04:00
|
|
|
-ExpectedSubject $(Get-MicrosoftPublisher)
|
2020-07-24 18:43:19 +03:00
|
|
|
}
|
2020-07-22 14:04:40 +03:00
|
|
|
|
2024-11-29 11:08:29 +01:00
|
|
|
if (Test-IsWin22) {
|
2022-02-07 20:53:07 +03:00
|
|
|
# Install Windows 10 SDK version 10.0.17763
|
2023-11-22 15:14:08 +01:00
|
|
|
Install-Binary -Type EXE `
|
2024-11-29 11:08:29 +01:00
|
|
|
-Url 'https://go.microsoft.com/fwlink/p/?LinkID=2033908' `
|
|
|
|
|
-InstallArgs @("/q", "/norestart", "/ceip off", "/features OptionId.UWPManaged OptionId.UWPCPP OptionId.UWPLocalized OptionId.DesktopCPPx86 OptionId.DesktopCPPx64 OptionId.DesktopCPParm64") `
|
2025-06-30 21:33:57 -04:00
|
|
|
-ExpectedSubject $(Get-MicrosoftPublisher)
|
2024-11-29 11:08:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (-not (Test-IsWin19)) {
|
2024-11-13 20:09:50 +00:00
|
|
|
# Install Windows 11 SDK version 10.0.26100
|
|
|
|
|
Install-Binary -Type EXE `
|
|
|
|
|
-Url 'https://go.microsoft.com/fwlink/?linkid=2286561' `
|
|
|
|
|
-InstallArgs @("/q", "/norestart", "/ceip off", "/features OptionId.UWPManaged OptionId.UWPCPP OptionId.UWPLocalized OptionId.DesktopCPPx86 OptionId.DesktopCPPx64 OptionId.DesktopCPParm64") `
|
2025-06-30 21:33:57 -04:00
|
|
|
-ExpectedSubject $(Get-MicrosoftPublisher)
|
2022-02-07 20:53:07 +03:00
|
|
|
}
|
|
|
|
|
|
2021-09-28 09:30:00 +01:00
|
|
|
Invoke-PesterTests -TestFile "VisualStudio"
|