Skip to content

Commit

Permalink
Add VS2022 to the picklist for VSBuild, MSBuild, XamarinAndroid tasks (
Browse files Browse the repository at this point in the history
…#15179)

* fix latest in  VSbuild, MSBuild, XamarinAndroid

* add unit test for VSBuild

Co-authored-by: Anna Opareva <[email protected]>
  • Loading branch information
AnnaOpareva and Anna Opareva authored Aug 20, 2021
1 parent 0b86d90 commit 1ab60be
Show file tree
Hide file tree
Showing 19 changed files with 129 additions and 85 deletions.
3 changes: 2 additions & 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": 1
"Patch": 2
},
"demands": [
"msbuild"
Expand Down Expand Up @@ -56,6 +56,7 @@
"visibleRule": "msbuildLocationMethod = version",
"options": {
"latest": "Latest",
"17.0": "MSBuild 17.0",
"16.0": "MSBuild 16.0",
"15.0": "MSBuild 15.0",
"14.0": "MSBuild 14.0",
Expand Down
5 changes: 3 additions & 2 deletions 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": 1
"Patch": 2
},
"demands": [
"msbuild"
Expand Down Expand Up @@ -56,6 +56,7 @@
"visibleRule": "msbuildLocationMethod = version",
"options": {
"latest": "Latest",
"17.0": "MSBuild 17.0",
"16.0": "MSBuild 16.0",
"15.0": "MSBuild 15.0",
"14.0": "MSBuild 14.0",
Expand Down Expand Up @@ -187,4 +188,4 @@
"CreateLogFileOnlySupportedOnWindows": "ms-resource:loc.messages.CreateLogFileOnlySupportedOnWindows",
"MSB_BuildToolNotFound": "ms-resource:loc.messages.MSB_BuildToolNotFound"
}
}
}
2 changes: 1 addition & 1 deletion Tasks/VSBuildV1/Select-VSVersion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function Select-VSVersion {
Trace-VstsEnteringInvocation $MyInvocation
try {
$specificVersion = $PreferredVersion -and $PreferredVersion -ne 'latest'
$versions = '16.0', '15.0', '14.0', '12.0', '11.0', '10.0' | Where-Object { $_ -ne $PreferredVersion }
$versions = '17.0', '16.0', '15.0', '14.0', '12.0', '11.0', '10.0' | Where-Object { $_ -ne $PreferredVersion }

# Look for a specific version of Visual Studio.
if ($specificVersion) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"loc.input.label.enableDefaultLogger": "Enable Default Logger",
"loc.input.help.enableDefaultLogger": "If true - enables default logger for msbuild",
"loc.input.label.customVersion": "Custom Version",
"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.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
6 changes: 6 additions & 0 deletions Tasks/VSBuildV1/Tests/L0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ describe('VSBuild Suite', function () {
it('(Select-VSVersion) falls back from 16', (done) => {
psr.run(path.join(__dirname, 'Select-VSVersion.FallsBackFrom16.ps1'), done);
})
it('(Select-VSVersion) falls back from 17', (done) => {
psr.run(path.join(__dirname, 'Select-VSVersion.FallsBackFrom17.ps1'), done);
})
it('(Select-VSVersion) falls forward from 12', (done) => {
psr.run(path.join(__dirname, 'Select-VSVersion.FallsForwardFrom12.ps1'), done);
})
Expand All @@ -45,6 +48,9 @@ describe('VSBuild Suite', function () {
it('(Select-VSVersion) falls forward from 15', (done) => {
psr.run(path.join(__dirname, 'Select-VSVersion.FallsForwardFrom15.ps1'), done);
})
it('(Select-VSVersion) falls forward from 16', (done) => {
psr.run(path.join(__dirname, 'Select-VSVersion.FallsForwardFrom16.ps1'), done);
})
it('(Select-VSVersion) finds latest', (done) => {
psr.run(path.join(__dirname, 'Select-VSVersion.FindsLatest.ps1'), done);
})
Expand Down
2 changes: 1 addition & 1 deletion Tasks/VSBuildV1/Tests/Select-VSVersion.FallsBackFrom14.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ $actual = Select-VSVersion -PreferredVersion '14.0'

# Assert.
Assert-WasCalled Write-Warning
Assert-WasCalled Get-VSPath -Times 4
Assert-WasCalled Get-VSPath -Times 5
Assert-AreEqual -Expected '12.0' -Actual $actual
2 changes: 1 addition & 1 deletion Tasks/VSBuildV1/Tests/Select-VSVersion.FallsBackFrom15.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ $actual = Select-VSVersion -PreferredVersion '15.0'

# Assert.
Assert-WasCalled Write-Warning
Assert-WasCalled Get-VSPath -Times 3
Assert-WasCalled Get-VSPath -Times 4
Assert-AreEqual -Expected '14.0' -Actual $actual
2 changes: 1 addition & 1 deletion Tasks/VSBuildV1/Tests/Select-VSVersion.FallsBackFrom16.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ $actual = Select-VSVersion -PreferredVersion '16.0'

# Assert.
Assert-WasCalled Write-Warning
Assert-WasCalled Get-VSPath -Times 2
Assert-WasCalled Get-VSPath -Times 3
Assert-AreEqual -Expected '15.0' -Actual $actual
16 changes: 16 additions & 0 deletions Tasks/VSBuildV1/Tests/Select-VSVersion.FallsBackFrom17.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[CmdletBinding()]
param()

# Arrange.
. $PSScriptRoot\..\..\..\Tests\lib\Initialize-Test.ps1
. $PSScriptRoot\..\Select-VSVersion.ps1
Register-Mock Write-Warning
Register-Mock Get-VSPath { "Some resolved location" } -- -Version '16.0'

# Act.
$actual = Select-VSVersion -PreferredVersion '17.0'

# Assert.
Assert-WasCalled Write-Warning
Assert-WasCalled Get-VSPath -Times 2
Assert-AreEqual -Expected '16.0' -Actual $actual
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ $actual = Select-VSVersion -PreferredVersion '12.0'

# Assert.
Assert-WasCalled Write-Warning
Assert-WasCalled Get-VSPath -Times 4
Assert-WasCalled Get-VSPath -Times 5
Assert-AreEqual -Expected '14.0' -Actual $actual
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ $actual = Select-VSVersion -PreferredVersion '14.0'

# Assert.
Assert-WasCalled Write-Warning
Assert-WasCalled Get-VSPath -Times 3
Assert-WasCalled Get-VSPath -Times 4
Assert-AreEqual -Expected '15.0' -Actual $actual
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ $actual = Select-VSVersion -PreferredVersion '15.0'

# Assert.
Assert-WasCalled Write-Warning
Assert-WasCalled Get-VSPath -Times 2
Assert-WasCalled Get-VSPath -Times 3
Assert-AreEqual -Expected '16.0' -Actual $actual
16 changes: 16 additions & 0 deletions Tasks/VSBuildV1/Tests/Select-VSVersion.FallsForwardFrom16.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[CmdletBinding()]
param()

# Arrange.
. $PSScriptRoot\..\..\..\Tests\lib\Initialize-Test.ps1
. $PSScriptRoot\..\Select-VSVersion.ps1
Register-Mock Write-Warning
Register-Mock Get-VSPath { "Some resolved location" } -- -Version '17.0'

# Act.
$actual = Select-VSVersion -PreferredVersion '16.0'

# Assert.
Assert-WasCalled Write-Warning
Assert-WasCalled Get-VSPath -Times 2
Assert-AreEqual -Expected '17.0' -Actual $actual
2 changes: 1 addition & 1 deletion Tasks/VSBuildV1/Tests/Select-VSVersion.FindsLatest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ param()
. $PSScriptRoot\..\..\..\Tests\lib\Initialize-Test.ps1
. $PSScriptRoot\..\Select-VSVersion.ps1
$preferredVersions = '', 'latest'
$knownVersions = '10.0', '11.0', '12.0', '14.0', '15.0', '16.0' # Registered in ascending order to validate latest is searched first.
$knownVersions = '10.0', '11.0', '12.0', '14.0', '15.0', '16.0', '17.0' # Registered in ascending order to validate latest is searched first.
foreach ($preferredVersion in $preferredVersions) {
Unregister-Mock Get-VSPath
foreach ($knownVersion in $knownVersions) {
Expand Down
3 changes: 2 additions & 1 deletion 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": 1
"Patch": 2
},
"demands": [
"msbuild",
Expand Down Expand Up @@ -45,6 +45,7 @@
"defaultValue": "latest",
"options": {
"latest": "Latest",
"17.0": "Visual Studio 2022",
"16.0": "Visual Studio 2019",
"15.0": "Visual Studio 2017",
"14.0": "Visual Studio 2015",
Expand Down
5 changes: 3 additions & 2 deletions 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": 1
"Patch": 2
},
"demands": [
"msbuild",
Expand Down Expand Up @@ -45,6 +45,7 @@
"defaultValue": "latest",
"options": {
"latest": "Latest",
"17.0": "Visual Studio 2022",
"16.0": "Visual Studio 2019",
"15.0": "Visual Studio 2017",
"14.0": "Visual Studio 2015",
Expand Down Expand Up @@ -185,4 +186,4 @@
"VSVersion0NotFoundFallbackVersion1": "ms-resource:loc.messages.VSVersion0NotFoundFallbackVersion1",
"VSVersion15NotFound": "ms-resource:loc.messages.VSVersion15NotFound"
}
}
}
Loading

0 comments on commit 1ab60be

Please sign in to comment.