Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support MS Build 17 (Visual Studio 2022) #326

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 39 additions & 7 deletions src/private/ConfigureBuildEnvironment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ function ConfigureBuildEnvironment {
}
{($_ -eq '4.5') -or ($_ -eq '4.5.1') -or ($_ -eq '4.5.2')} {
$versions = @('v4.0.30319')
$buildToolsVersions = @('16.0', '15.0', '14.0', '12.0')
$buildToolsVersions = @('17.0', '16.0', '15.0', '14.0', '12.0')
}
{($_ -eq '4.6') -or ($_ -eq '4.6.1') -or ($_ -eq '4.6.2')} {
$versions = @('v4.0.30319')
$buildToolsVersions = @('16.0', '15.0', '14.0')
$buildToolsVersions = @('17.0', '16.0', '15.0', '14.0')
}
{($_ -eq '4.7') -or ($_ -eq '4.7.1') -or ($_ -eq '4.7.2')} {
$versions = @('v4.0.30319')
$buildToolsVersions = @('16.0', '15.0')
$buildToolsVersions = @('17.0', '16.0', '15.0')
}
'4.8' {
{($_ -eq '4.8') -or ($_ -eq '4.8.1')} {
$versions = @('v4.0.30319')
$buildToolsVersions = @('16.0', '15.0')
$buildToolsVersions = @('17.0', '16.0')
}

default {
Expand Down Expand Up @@ -154,12 +154,12 @@ function ConfigureBuildEnvironment {

# borrowed from nightroman https://github.com/nightroman/Invoke-Build
if ($vsInstances = Get-VSSetupInstance) {
$vs = @($vsInstances | Select-VSSetupInstance -Version '[16.0,)' -Require Microsoft.Component.MSBuild)
$vs = @($vsInstances | Select-VSSetupInstance -Version '[16.0, 17.0)' -Require Microsoft.Component.MSBuild)
if ($vs) {
$frameworkDirs += Join-Path ($vs[0].InstallationPath) MSBuild\Current\Bin
}

$vs = @($vsInstances | Select-VSSetupInstance -Version '[16.0,)' -Product Microsoft.VisualStudio.Product.BuildTools)
$vs = @($vsInstances | Select-VSSetupInstance -Version '[16.0, 17.0)' -Product Microsoft.VisualStudio.Product.BuildTools)
if ($vs) {
$frameworkDirs += Join-Path ($vs[0].InstallationPath) MSBuild\Current\Bin
}
Expand All @@ -174,6 +174,38 @@ function ConfigureBuildEnvironment {
}
}
}
elseif ($ver -eq "17.0") {
if ($null -eq (Get-Module -Name VSSetup)) {
if ($null -eq (Get-Module -Name VSSetup -ListAvailable)) {
WriteColoredOutput ($msgs.warning_missing_vsssetup_module -f $ver) -foregroundcolor Yellow
continue
}

Import-Module VSSetup
}

# borrowed from nightroman https://github.com/nightroman/Invoke-Build
if ($vsInstances = Get-VSSetupInstance) {
$vs = @($vsInstances | Select-VSSetupInstance -Version '[17.0,)' -Require Microsoft.Component.MSBuild)
if ($vs) {
$frameworkDirs += Join-Path ($vs[0].InstallationPath) MSBuild\Current\Bin
}

$vs = @($vsInstances | Select-VSSetupInstance -Version '[17.0,)' -Product Microsoft.VisualStudio.Product.BuildTools)
if ($vs) {
$frameworkDirs += Join-Path ($vs[0].InstallationPath) MSBuild\Current\Bin
}
}
else {
if (!($root = ${env:ProgramFiles(x86)})) {$root = $env:ProgramFiles}
if (Test-Path -LiteralPath "$root\Microsoft Visual Studio\2022") {
$rp = @(Resolve-Path "$root\Microsoft Visual Studio\2022\*\MSBuild\Current\Bin" -ErrorAction SilentlyContinue)
if ($rp) {
$frameworkDirs += $rp[-1].ProviderPath
}
}
}
}
elseif (Test-Path "HKLM:\SOFTWARE\Microsoft\MSBuild\ToolsVersions\$ver") {
$frameworkDirs += (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\MSBuild\ToolsVersions\$ver" -Name $buildToolsKey).$buildToolsKey
}
Expand Down