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
|
|
|
|
2026-04-07 17:32:00 +02:00
|
|
|
if (Test-IsArm64) {
|
|
|
|
|
$vsArch = "arm64"
|
|
|
|
|
} else {
|
|
|
|
|
$vsArch = "x64"
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-19 12:38:46 +00:00
|
|
|
# Install Visual Studio for Windows 22 and 25 with InstallChannel
|
|
|
|
|
Install-VisualStudio `
|
|
|
|
|
-Version $vsToolset.subversion `
|
|
|
|
|
-Edition $vsToolset.edition `
|
|
|
|
|
-Channel $vsToolset.channel `
|
2026-02-06 10:59:14 +01:00
|
|
|
-InstallChannelUri $vsToolset.installChannelUri `
|
2026-01-19 12:38:46 +00:00
|
|
|
-RequiredComponents $vsToolset.workloads `
|
2026-04-07 17:32:00 +02:00
|
|
|
-ExtraArgs "--allWorkloads --includeRecommended --remove Component.CPython3.x64" `
|
|
|
|
|
-Architecture $vsArch
|
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
|
|
|
|
2026-04-07 17:32:00 +02:00
|
|
|
if (Test-IsWin22-X64) {
|
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
|
|
|
}
|
|
|
|
|
|
2026-01-19 12:38:46 +00:00
|
|
|
# Install Windows 11 SDK version 10.0.26100
|
|
|
|
|
Install-Binary -Type EXE `
|
2026-02-09 11:41:48 +01:00
|
|
|
-Url 'https://go.microsoft.com/fwlink/?linkid=2349110' `
|
2026-01-19 12:38:46 +00:00
|
|
|
-InstallArgs @("/q", "/norestart", "/ceip off", "/features OptionId.UWPManaged OptionId.UWPCPP OptionId.UWPLocalized OptionId.DesktopCPPx86 OptionId.DesktopCPPx64 OptionId.DesktopCPParm64") `
|
|
|
|
|
-ExpectedSubject $(Get-MicrosoftPublisher)
|
2022-02-07 20:53:07 +03:00
|
|
|
|
2026-01-30 13:06:39 +01:00
|
|
|
# Enable Windows Desktop Debuggers (cdb.exe) on Windows Server 2025
|
2026-04-07 17:32:00 +02:00
|
|
|
if (Test-IsWin25-X64) {
|
2026-01-30 13:06:39 +01:00
|
|
|
$installerEntry = Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* `
|
|
|
|
|
| Where-Object { $_.DisplayName -match "Windows Software Development Kit" } `
|
|
|
|
|
| Sort-Object DisplayVersion -Descending | Select-Object -First 1
|
|
|
|
|
|
|
|
|
|
if ($installerEntry -and $installerEntry.BundleCachePath) {
|
|
|
|
|
Install-Binary -Type EXE `
|
|
|
|
|
-LocalPath $installerEntry.BundleCachePath `
|
|
|
|
|
-InstallArgs @("/features", "OptionId.WindowsDesktopDebuggers", "/q", "/norestart") `
|
|
|
|
|
-ExpectedSubject $(Get-MicrosoftPublisher)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-28 09:30:00 +01:00
|
|
|
Invoke-PesterTests -TestFile "VisualStudio"
|