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

Add support for VS 2022 to the VSBuildV1 #15099

Merged
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
5e48875
add 17.0 version VS in VSBuildV1
Jul 29, 2021
a07229e
bumped task version
Jul 29, 2021
e146a5e
separate PRs
Jul 29, 2021
b857575
add MSBuildHelper
Aug 3, 2021
6b39b08
fix tests
Aug 3, 2021
de03feb
test short path to vswhere
Aug 3, 2021
c289107
Revert "test short path to vswhere"
Aug 4, 2021
be33fa8
test Select-MSBuildPath
Aug 4, 2021
aec3914
Revert changes in paths
EzzhevNikita Aug 4, 2021
526967a
Merge branch 'master' into users/v-aopareva/fix_15051_add_suport_2022…
EzzhevNikita Aug 4, 2021
f7f059e
revert test Select-MSBuildPath
Aug 4, 2021
42e4186
fix PathFunctions
Aug 4, 2021
b8591ae
fix PathFunction tests
Aug 4, 2021
0db251d
fix PathFunction tests 2
Aug 4, 2021
4e9ca30
fix common files
Aug 4, 2021
c5f11c4
bumped version tasks
Aug 4, 2021
54088ec
bumped version tasks
Aug 4, 2021
edaf96b
bumped version tasks 3
Aug 4, 2021
0f73e64
revert changes common-npm-packages
Aug 4, 2021
74eeba6
bumped version msbuildhelpers
Aug 5, 2021
30f6969
bumped version msbuildhelpers in VSBuildV1
Aug 5, 2021
398fa19
Merge branch 'master' into users/v-aopareva/fix_15051_add_suport_2022…
Aug 6, 2021
5c9bc81
bumped version to 192
Aug 6, 2021
b35d50c
Merge branch 'users/v-aopareva/fix_15051_add_suport_2022_version_VS' …
Aug 6, 2021
b1ed769
Update Tasks/VSBuildV1/task.json
AnnaOpareva Aug 9, 2021
ed49872
fix reviewpoints
Aug 9, 2021
5e02a21
Merge branch 'master' into users/v-aopareva/fix_15051_add_suport_2022…
AnnaOpareva Aug 9, 2021
e72a17b
bumped version to 1.192.1
Aug 9, 2021
73d4141
fix input, description and Get-MSBuildPath
Aug 10, 2021
ec11104
Merge branch 'master' into users/v-aopareva/fix_15051_add_suport_2022…
EzzhevNikita Aug 10, 2021
b7d4d37
fix path for VS 15.0
Aug 10, 2021
9c8955e
Merge branch 'users/v-aopareva/fix_15051_add_suport_2022_version_VS' …
Aug 10, 2021
7538a9e
try refactor Get-VSPath
Aug 12, 2021
2e17885
feractor Get-VSPath
Aug 13, 2021
c586262
Merge branch 'master' into users/v-aopareva/fix_15051_add_suport_2022…
EzzhevNikita Aug 13, 2021
81839cc
fix error comment
Aug 13, 2021
1c0db44
fix error comment
Aug 13, 2021
6d9f346
Merge branch 'users/v-aopareva/fix_15051_add_suport_2022_version_VS' …
Aug 13, 2021
f8908b2
Merge branch 'master' into users/v-aopareva/fix_15051_add_suport_2022…
EzzhevNikita Aug 16, 2021
1d58d1e
Merge branch 'master' into users/v-aopareva/fix_15051_add_suport_2022…
AnnaOpareva Aug 17, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions Tasks/Common/MSBuildHelpers/PathFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,27 @@ function Get-MSBuildPath {
[string]$Version,
[string]$Architecture)

$VersionNumber = [int]($Version.Remove(2))

Trace-VstsEnteringInvocation $MyInvocation
try {
# Only attempt to find Microsoft.Build.Utilities.Core.dll from a VS 15 Willow install
# when "15.0" or latest is specified. In 15.0, the method GetPathToBuildToolsFile(...)
# has regressed. When it is called for a version that is not found, the latest version
# found is returned instead. Same for "16.0"
# found is returned instead. Same for "16.0" and "17.0"
[System.Reflection.Assembly]$msUtilities = $null
if (($Version -eq "16.0" -or !$Version) -and # !$Version indicates "latest"
($visualStudio16 = Get-VisualStudio 16) -and
$visualStudio16.installationPath) {

$msbuildUtilitiesPath = [System.IO.Path]::Combine($visualStudio16.installationPath, "MSBuild\Current\Bin\Microsoft.Build.Utilities.Core.dll")
if (($VersionNumber -ge 16 -or !$Version) -and # !$Version indicates "latest"
($specifiedStudio = Get-VisualStudio $VersionNumber) -and
$specifiedStudio.installationPath) {

$msbuildUtilitiesPath = [System.IO.Path]::Combine($specifiedStudio.installationPath, "MSBuild\Current\Bin\Microsoft.Build.Utilities.Core.dll")
if (Test-Path -LiteralPath $msbuildUtilitiesPath -PathType Leaf) {
Write-Verbose "Loading $msbuildUtilitiesPath"
$msUtilities = [System.Reflection.Assembly]::LoadFrom($msbuildUtilitiesPath)
}
}

elseif (($Version -eq "15.0" -or !$Version) -and # !$Version indicates "latest"
($visualStudio15 = Get-VisualStudio 15) -and
$visualStudio15.installationPath) {
Expand Down Expand Up @@ -183,7 +187,7 @@ function Get-VisualStudio {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[ValidateSet(15, 16)]
[ValidateSet(15, 16, 17)]
[int]$MajorVersion)

Trace-VstsEnteringInvocation $MyInvocation
Expand Down Expand Up @@ -273,7 +277,7 @@ function Select-MSBuildPath {
}

$specificVersion = $PreferredVersion -and $PreferredVersion -ne 'latest'
$versions = "16.0", '15.0', '14.0', '12.0', '4.0' | Where-Object { $_ -ne $PreferredVersion }
$versions = '17.0', '16.0', '15.0', '14.0', '12.0', '4.0' | Where-Object { $_ -ne $PreferredVersion }

# Look for a specific version of MSBuild.
if ($specificVersion) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ Assert-WasCalled Get-MSBuildPath -- -Version '15.0' -Architecture 'Some architec
Assert-WasCalled Get-MSBuildPath -- -Version '14.0' -Architecture 'Some architecture'
Assert-WasCalled Get-MSBuildPath -- -Version '12.0' -Architecture 'Some architecture'
Assert-WasCalled Get-MSBuildPath -- -Version '4.0' -Architecture 'Some architecture'
Assert-WasCalled Get-MSBuildPath -Times 5
Assert-WasCalled Get-MSBuildPath -Times 6
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ $actual = Select-MSBuildPath -Method 'Version' -Location '' -PreferredVersion '1

# Assert.
Assert-WasCalled Write-Warning
Assert-WasCalled Get-MSBuildPath -Times 4
Assert-WasCalled Get-MSBuildPath -Times 5
Assert-AreEqual -Expected 'Some resolved location' -Actual $actual
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ $actual = Select-MSBuildPath -Method 'Version' -Location '' -PreferredVersion '1

# Assert.
Assert-WasCalled Write-Warning
Assert-WasCalled Get-MSBuildPath -Times 3
Assert-WasCalled Get-MSBuildPath -Times 4
Assert-AreEqual -Expected 'Some resolved location' -Actual $actual
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ $actual = Select-MSBuildPath -Method 'Version' -Location '' -PreferredVersion '1

# Assert.
Assert-WasCalled Write-Warning
Assert-WasCalled Get-MSBuildPath -Times 2
Assert-WasCalled Get-MSBuildPath -Times 3
Assert-AreEqual -Expected 'Some resolved location' -Actual $actual
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ $actual = Select-MSBuildPath -Method 'Version' -Location '' -PreferredVersion '1

# Assert.
Assert-WasCalled Write-Warning
Assert-WasCalled Get-MSBuildPath -Times 4
Assert-WasCalled Get-MSBuildPath -Times 5
Assert-AreEqual -Expected 'Some resolved location' -Actual $actual
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ $actual = Select-MSBuildPath -Method 'Version' -Location '' -PreferredVersion '1

# Assert.
Assert-WasCalled Write-Warning
Assert-WasCalled Get-MSBuildPath -Times 3
Assert-WasCalled Get-MSBuildPath -Times 4
Assert-AreEqual -Expected 'Some resolved location' -Actual $actual
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ $actual = Select-MSBuildPath -Method 'Version' -Location '' -PreferredVersion '1

# Assert.
Assert-WasCalled Write-Warning
Assert-WasCalled Get-MSBuildPath -Times 2
Assert-WasCalled Get-MSBuildPath -Times 3
Assert-AreEqual -Expected 'Some resolved location' -Actual $actual
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ foreach ($version in @('', 'latest')) {

# Assert.
Assert-AreEqual -Expected 'Some resolved location' -Actual $actual
Assert-WasCalled Get-MSBuildPath -Times 1
Assert-WasCalled Get-MSBuildPath -Times 2
}
2 changes: 1 addition & 1 deletion Tasks/Common/MSBuildHelpers/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Tasks/Common/MSBuildHelpers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "msbuildhelpers",
"version": "1.191.0",
"version": "1.192.1",
"description": "Azure Pipelines tasks MSBuild helpers",
"main": "msbuildhelpers.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion Tasks/MSBuildV1/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Tasks/MSBuildV1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@types/mocha": "^5.2.7",
"@types/node": "^10.17.0",
"azure-pipelines-task-lib": "^3.1.2",
"msbuildhelpers": "file:../../_build/Tasks/Common/msbuildhelpers-1.191.0.tgz"
"msbuildhelpers": "file:../../_build/Tasks/Common/msbuildhelpers-1.192.1.tgz"
},
"devDependencies": {
"typescript": "4.0.2"
Expand Down
2 changes: 1 addition & 1 deletion Tasks/MSBuildV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"version": {
"Major": 1,
"Minor": 192,
"Patch": 0
"Patch": 1
},
"demands": [
"msbuild"
Expand Down
2 changes: 1 addition & 1 deletion Tasks/MSBuildV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"version": {
"Major": 1,
"Minor": 192,
"Patch": 0
"Patch": 1
},
"demands": [
"msbuild"
Expand Down
41 changes: 20 additions & 21 deletions Tasks/VSBuildV1/Get-VSPath.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,28 @@ function Get-VSPath {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]$Version)

[string]$Version)

$Versions = @('15.0', '16.0', '17.0')
Trace-VstsEnteringInvocation $MyInvocation
try {
if ($Version -eq "16.0" -and
($instance = Get-VisualStudio 16) -and
$instance.installationPath) {

return $instance.installationPath
}
# Search for a 15.0 Willow instance.
if ($Version -eq "15.0" -and
($instance = Get-VisualStudio 15) -and
$instance.installationPath) {

return $instance.installationPath
}

# Fallback to searching for an older install.
if ($path = (Get-ItemProperty -LiteralPath "HKLM:\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\$Version" -Name 'ShellFolder' -ErrorAction Ignore).ShellFolder) {
return $path
}
try {
if ( !($Version -in $Versions )) {
Write-Warning "Please enter one of the versions 15.0, 16.0, 17.0"
} else {
$VersionNumber = [int]$Version.Remove(2)
# Search for more than 15.0 Willow instance.
if (($instance = Get-VisualStudio $VersionNumber) -and
$instance.installationPath) {

return $instance.installationPath
}

if ($path = (Get-ItemProperty -LiteralPath "HKLM:\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\$Version" -Name 'ShellFolder' -ErrorAction Ignore).ShellFolder) {
return $path
}
}
} finally {
Trace-VstsLeavingInvocation $MyInvocation
}
}
}
AnnaOpareva marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"loc.input.help.logFileVerbosity": "Optional log file verbosity.",
"loc.input.label.enableDefaultLogger": "Enable Default Logger",
"loc.input.help.enableDefaultLogger": "If true - enables default logger for msbuild",
"loc.input.label.customVersion": "Custom Version",
AnnaOpareva marked this conversation as resolved.
Show resolved Hide resolved
AnnaOpareva marked this conversation as resolved.
Show resolved Hide resolved
"loc.input.help.customVersion": "Allows setting custom version of Visual Studio. Examples: 15.0, 16.0, 17.0.Make sure that the required version of Visual Studio is installed in the system.",
"loc.messages.MSBuildLocationDeprecated0": "The MSBuild location parameter has been deprecated. Ignoring value '{0}'",
"loc.messages.MSBuildVersionDeprecated0": "The MSBuild version parameter has been deprecated. Ignoring value '{0}'.",
"loc.messages.UnexpectedVSVersion0": "Unexpected Visual Studio version '{0}'.",
Expand Down
2 changes: 2 additions & 0 deletions Tasks/VSBuildV1/Tests/MapsVSVersions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Register-Mock Format-MSBuildArguments
Register-Mock Invoke-BuildTools
$mappings = @(
@{ VSVersion = '' ; MSBuildVersion = '14.0' }
@{ VSVersion = '17.0' ; MSBuildVersion = '17.0' }
@{ VSVersion = '16.0' ; MSBuildVersion = '16.0' }
@{ VSVersion = '15.0' ; MSBuildVersion = '15.0' }
@{ VSVersion = '14.0' ; MSBuildVersion = '14.0' }
Expand All @@ -32,6 +33,7 @@ foreach ($mapping in $mappings) {
Register-Mock Get-VstsInput { $false } -- -Name LogProjectEvents -AsBool
Register-Mock Get-VstsInput { $false } -- -Name CreateLogFile -AsBool
Register-Mock Get-VstsInput { $false } -- -Name EnableDefaultLogger -AsBool
Register-Mock Get-VstsInput { $false } -- -Name isCustomVersion -AsBool
Register-Mock Select-VSVersion { $mapping.VSVersion } -- -PreferredVersion $mapping.VSVersion
Register-Mock Select-MSBuildPath

Expand Down
1 change: 1 addition & 0 deletions Tasks/VSBuildV1/Tests/PassesArguments.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ foreach ($variableSet in $variableSets) {
Register-Mock Get-VstsInput { $variableSet.CreateLogFile } -- -Name CreateLogFile -AsBool
Register-Mock Get-VstsInput { $variableSet.LogFileVerbosity } -- -Name LogFileVerbosity
Register-Mock Get-VstsInput { $variableSet.EnableDefaultLogger } -- -Name EnableDefaultLogger -AsBool
Register-Mock Get-VstsInput { $false } -- -Name isCustomVersion -AsBool
Register-Mock Get-VstsTaskVariable { $variableSet.Debug } -- -Name System.Debug -AsBool
Register-Mock Get-SolutionFiles { 'Some solution 1', 'Some solution 2' } -- -Solution 'Some input solution'
Register-Mock Select-VSVersion { $variableSet.VSVersion } -- -PreferredVersion $variableSet.VSVersion
Expand Down
1 change: 1 addition & 0 deletions Tasks/VSBuildV1/Tests/ThrowsIfUnknownVSVersion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Register-Mock Get-VstsInput { $false } -- -Name RestoreNuGetPackages -AsBool
Register-Mock Get-VstsInput { $false } -- -Name LogProjectEvents -AsBool
Register-Mock Get-VstsInput { $false } -- -Name CreateLogFile -AsBool
Register-Mock Get-VstsInput { $true } -- -Name EnableDefaultLogger -AsBool
Register-Mock Get-VstsInput { $false } -- -Name isCustomVersion -AsBool
Register-Mock Get-VstsTaskVariable { $false } -- -Name System.Debug -AsBool
Register-Mock Select-VSVersion { 'nosuchversion' } -- -PreferredVersion '14.0'
Register-Mock Select-MSBuildPath
Expand Down
8 changes: 7 additions & 1 deletion Tasks/VSBuildV1/VSBuild.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ try {
[bool]$createLogFile = Get-VstsInput -Name CreateLogFile -AsBool
[string]$logFileVerbosity = if ($debug) { "diagnostic" } else { Get-VstsInput -Name LogFileVerbosity }
[bool]$enableDefaultLogger = Get-VstsInput -Name EnableDefaultLogger -AsBool
[string]$customVersion = Get-VstsInput -Name customVersion

# Warn if deprecated inputs were specified.
if ([string]$vsLocation = Get-VstsInput -Name VSLocation) {
Expand All @@ -48,12 +49,17 @@ try {
$solutionFiles = Get-SolutionFiles -Solution $Solution

# Resolve a VS version.
$vsVersion = Select-VSVersion -PreferredVersion $vsVersion
if ($customVersion) {
$vsVersion = Select-VSVersion -PreferredVersion $customVersion
} else {
$vsVersion = Select-VSVersion -PreferredVersion $vsVersion
}

# Translate to MSBuild version.
$msBuildVersion = $null;
switch ("$vsVersion") {
'' { $msBuildVersion = '14.0' ; break } # VS wasn't found. Attempt to find MSBuild 14.0 or lower.
'17.0' { $msBuildVersion = '17.0' ; break }
'16.0' { $msBuildVersion = '16.0' ; break }
'15.0' { $msBuildVersion = '15.0' ; break }
'14.0' { $msBuildVersion = '14.0' ; break }
Expand Down
13 changes: 11 additions & 2 deletions Tasks/VSBuildV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"version": {
"Major": 1,
"Minor": 192,
"Patch": 0
"Patch": 1
},
"demands": [
"msbuild",
Expand Down Expand Up @@ -158,6 +158,15 @@
"required": false,
"helpMarkDown": "If true - enables default logger for msbuild",
"groupName": "advanced"
},
{
"name": "customVersion",
"type": "string",
"label": "Custom Version",
"defaultValue": "",
"required": false,
"helpMarkDown": "Allows setting custom version of Visual Studio. Examples: 15.0, 16.0, 17.0. Make sure that the required version of Visual Studio is installed in the system.",
"groupName": "advanced"
}
],
"instanceNameFormat": "Build solution $(solution)",
Expand All @@ -176,4 +185,4 @@
"VSVersion0NotFoundFallbackVersion1": "Visual Studio version '{0}' not found. Falling back to version '{1}'.",
"VSVersion15NotFound": "Visual Studio 2017 was not found."
}
}
}
11 changes: 10 additions & 1 deletion Tasks/VSBuildV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"version": {
"Major": 1,
"Minor": 192,
"Patch": 0
"Patch": 1
},
"demands": [
"msbuild",
Expand Down Expand Up @@ -158,6 +158,15 @@
"required": false,
"helpMarkDown": "ms-resource:loc.input.help.enableDefaultLogger",
"groupName": "advanced"
},
{
"name": "customVersion",
"type": "string",
"label": "ms-resource:loc.input.label.customVersion",
"defaultValue": "",
"required": false,
"helpMarkDown": "ms-resource:loc.input.help.customVersion",
"groupName": "advanced"
}
],
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/XamarinAndroidV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"version": {
"Major": 1,
"Minor": 192,
"Patch": 0
"Patch": 1
},
"demands": [
"MSBuild",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/XamarinAndroidV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"version": {
"Major": 1,
"Minor": 192,
"Patch": 0
"Patch": 1
},
"demands": [
"MSBuild",
Expand Down