simh-testsetgenerator/cmake/v141_xp_install.ps1
B. Scott Michel 8b14bb69be
CMake build infrastructure II (#53)
* CMake build infrastructure

The squashed commit that builds and packages releases for the SIMH
simulator suite with CMake, version 3.14 or newer.

See README-CMake.md for documentation.
2023-05-17 20:18:42 -04:00

84 lines
3 KiB
PowerShell

$vsFlavor=$args[0]
$vsSetupDir="C:\Program Files (x86)\Microsoft Visual Studio\installer"
$vswhere="${vsSetupDir}\vswhere.exe"
$vsinstaller="${vsSetupDir}\vs_installer.exe"
$vstudios = @{
"vs2017" = @{
names = @{
"Visual Studio Enterprise 2019" = "Microsoft.VisualStudio.Product.Enterprise"
"Visual Studio Professional 2019" = "Microsoft.VisualStudio.Product.Professional"
"Visual Studio Community 2019" = "Microsoft.VisualStudio.Product.Community"
}
channelId = "VisualStudio.15.Release"
v141toolkit = @( "Microsoft.VisualStudio.Component.WinXP" )
}
"vs2019" = @{
names = @{
"Visual Studio Enterprise 2019" = "Microsoft.VisualStudio.Product.Enterprise"
"Visual Studio Professional 2019" = "Microsoft.VisualStudio.Product.Professional"
"Visual Studio Community 2019" = "Microsoft.VisualStudio.Product.Community"
}
displayName = "Visual Studio Community 2019"
channelId = "VisualStudio.16.Release"
v141toolkit = @( "Microsoft.VisualStudio.Component.VC.v141.x86.x64", "Microsoft.VisualStudio.Component.WinXP" )
}
"vs2022" = @{
names = @{
"Visual Studio Enterprise 2022" = "Microsoft.VisualStudio.Product.Enterprise"
"Visual Studio Professional 2022" = "Microsoft.VisualStudio.Product.Professional"
"Visual Studio Community 2022" = "Microsoft.VisualStudio.Product.Community"
}
installedChannelId = "VisualStudio.17.Release"
v141toolkit = @( "Microsoft.VisualStudio.Component.VC.v141.x86.x64", "Microsoft.VisualStudio.Component.WinXP" )
}
}
if ($args.length -eq 0) {
"Womabt!!"
exit 1
}
$wantedVS = $vstudios[$args[0]]
if ($wantedVS -eq $null) {
"Wibbles."
exit 1
}
Set-PSDebug -Trace 1
if (Test-Path -Path $vsinstaller) {
if (Test-Path -Path $vswhere) {
$vsinfo=$(& $vswhere -format json | ConvertFrom-JSON)
foreach ($vs in $vsinfo) {
$productId = $wantedVS.names[$vs.displayName]
if ($productId -ne $null) {
Write-Output $("Found: " + $vs.displayName)
$args = @( "modify", "--quiet")
$args += @( "--channelId", $wantedVS.installedChannelId )
$args += @( "--productId", $productId )
foreach ($c in $wantedVS.v141toolkit) {
$args += @( "--add", $c )
}
Write-Output $( ( @("Executing: ", $vsinstaller) + $args ) -join " " )
$proc = Start-Process -Verbose -NoNewWindow -PassThru $vsinstaller -ArgumentList $args
$proc.WaitForExit()
$proc = Start-Process -NoNewWindow -PassThru $vsinstaller -ArgumentList @("export", "--channelId", $wantedVS.installedChannelId, "--productId", $productId, "--config", "vsinstall.after", "--quiet")
$proc.WaitForExit()
if (Test-Path -Path .\vsinstall.after) {
Get-Content .\vsinstall.after
}
}
}
} else {
Write-Ouput @("vswhere not found or available. ", $vswhere) -join " "
}
} else {
Write-Ouput @("VS installer not found or available. ", $vsinstaller) -join " "
}