diff --git a/images/win/scripts/ImageHelpers/ImageHelpers.psm1 b/images/win/scripts/ImageHelpers/ImageHelpers.psm1 index 9441ac7a2..07b406621 100644 --- a/images/win/scripts/ImageHelpers/ImageHelpers.psm1 +++ b/images/win/scripts/ImageHelpers/ImageHelpers.psm1 @@ -36,6 +36,6 @@ Export-ModuleMember -Function @( 'Invoke-PesterTests' 'Get-VsCatalogJsonPath' 'Install-AndroidSDKPackages' - 'Get-VisualStudioInstallation' + 'Get-VisualStudioProduct' 'Get-VisualStudioComponents' ) diff --git a/images/win/scripts/ImageHelpers/InstallHelpers.ps1 b/images/win/scripts/ImageHelpers/InstallHelpers.ps1 index 767391780..9f1a32f6a 100644 --- a/images/win/scripts/ImageHelpers/InstallHelpers.ps1 +++ b/images/win/scripts/ImageHelpers/InstallHelpers.ps1 @@ -258,27 +258,6 @@ function Install-VsixExtension } } -function Get-VSExtensionVersion -{ - Param - ( - [Parameter(Mandatory=$true)] - [string] $packageName - ) - - $instanceFolders = "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances\" + (Get-VisualStudioInstallation -VSInstallType "VS").InstanceId - $state = Get-Content -Path (Join-Path $instanceFolders '\state.packages.json') | ConvertFrom-Json - $packageVersion = ($state.packages | Where-Object { $_.id -eq $packageName }).version - - if (-not $packageVersion) - { - Write-Host "installed package $packageName for Visual Studio 2019 was not found" - exit 1 - } - - return $packageVersion -} - function Get-ToolcachePackages { $toolcachePath = Join-Path $env:ROOT_FOLDER "toolcache.json" diff --git a/images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1 b/images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1 index 10e8d0cd8..8be653f42 100644 --- a/images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1 +++ b/images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1 @@ -61,31 +61,26 @@ Function Install-VisualStudio } function Get-VsCatalogJsonPath { - $instanceFolder = "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances\" + (Get-VisualStudioInstallation -VSInstallType "VS").InstanceId + $instanceFolder = "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances\" + (Get-VisualStudioProduct -ProductType "VisualStudio").InstanceId return Join-Path $instanceFolder "catalog.json" } -function Get-VisualStudioInstallation { +function Get-VisualStudioProduct { Param ( [Parameter(Mandatory)] - [ValidateSet('VS','BuildTools')] - [String] $VSInstallType + [ValidateSet('VisualStudio','BuildTools')] + [String] $ProductType ) - if ($VSInstallType -eq "VS") + if ($ProductType -eq "VisualStudio") { $VSSelectionType = "*Enterprise*" } - elseif ($VSInstallType -eq "BuildTools") + elseif ($ProductType -eq "BuildTools") { $VSSelectionType = "*Build*" } - else - { - Write-Output "Visual Studio Installation type have to be 'VS' or 'BuildTools'" - exit 1 - } return Get-VSSetupInstance | Select-VSSetupInstance -Product * | Where-Object -Property DisplayName -like $VSSelectionType } @@ -93,10 +88,30 @@ function Get-VisualStudioComponents { Param ( [Parameter(Mandatory)] - [ValidateSet('VS','BuildTools')] - [String] $VSInstallType + [String] $ProductType ) - (Get-VisualStudioInstallation -VSInstallType $VSInstallType).Packages | Where-Object type -in 'Component', 'Workload' | + (Get-VisualStudioProduct -ProductType $ProductType).Packages | Where-Object type -in 'Component', 'Workload' | Sort-Object Id, Version | Select-Object @{n = 'Package'; e = {$_.Id}}, Version | Where-Object { $_.Package -notmatch "[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}" } } + +function Get-VSExtensionVersion +{ + Param + ( + [Parameter(Mandatory=$true)] + [string] $packageName + ) + + $instanceFolders = "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances\" + (Get-VisualStudioProduct -ProductType "VisualStudio").InstanceId + $state = Get-Content -Path (Join-Path $instanceFolders '\state.packages.json') | ConvertFrom-Json + $packageVersion = ($state.packages | Where-Object { $_.id -eq $packageName }).version + + if (-not $packageVersion) + { + Write-Host "installed package $packageName for Visual Studio 2019 was not found" + exit 1 + } + + return $packageVersion +} diff --git a/images/win/scripts/Installers/Install-VS.ps1 b/images/win/scripts/Installers/Install-VS.ps1 index af834b621..be776dded 100644 --- a/images/win/scripts/Installers/Install-VS.ps1 +++ b/images/win/scripts/Installers/Install-VS.ps1 @@ -7,18 +7,18 @@ $ErrorActionPreference = "Stop" $toolset = Get-ToolsetContent $requiredComponents = $toolset.visualStudio.workloads | ForEach-Object { "--add $_" } -$buildRequiredComponents = $toolset.visualStudio.build_workloads | ForEach-Object { "--add $_" } +$buildToolsRequiredComponents = $toolset.visualStudio.buildtools_workloads | ForEach-Object { "--add $_" } $workLoads = @( "--allWorkloads --includeRecommended" $requiredComponents "--remove Component.CPython3.x64" ) $workLoadsArgument = [String]::Join(" ", $workLoads) -$buildWorkLoads = @( +$buildToolsWorkloads= @( "--includeRecommended" - $buildRequiredComponents + $buildToolsRequiredComponents ) -$buildWorkLoadsArgument = [String]::Join(" ", $buildWorkLoads) +$buildWorkLoadsArgument = [String]::Join(" ", $buildToolsWorkloads) $releaseInPath = $toolset.visualStudio.edition $subVersion = $toolset.visualStudio.subversion @@ -29,7 +29,7 @@ $buildbootstrapperUrl = "https://aka.ms/vs/${subVersion}/release/vs_buildtools.e Install-VisualStudio -BootstrapperUrl $bootstrapperUrl -WorkLoads $workLoadsArgument Install-VisualStudio -BootstrapperUrl $buildbootstrapperUrl -WorkLoads $buildWorkLoadsArgument -$vsInstallRoot = (Get-VisualStudioInstallation -VSInstallType "VS").InstallationPath +$vsInstallRoot = (Get-VisualStudioProduct -ProductType "VisualStudio").InstallationPath # Initialize Visual Studio Experimental Instance & "$vsInstallRoot\Common7\IDE\devenv.exe" /RootSuffix Exp /ResetSettings General.vssettings /Command File.Exit diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 b/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 index e818a25d8..5ff886c77 100644 --- a/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 +++ b/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 @@ -171,12 +171,12 @@ $markdown += New-MDNewLine $markdown += New-MDHeader "Workloads, components and extensions:" -Level 4 $markdown += New-MDNewLine -$markdown += ((Get-VisualStudioComponents -VSInstallType "VS") + (Get-VisualStudioExtensions)) | New-MDTable +$markdown += ((Get-VisualStudioComponents -ProductType "VisualStudio") + (Get-VisualStudioExtensions)) | New-MDTable $markdown += New-MDNewLine -$markdown += New-MDHeader "Build Workloads and components:" -Level 4 +$markdown += New-MDHeader "Build Tools Workloads:" -Level 4 $markdown += New-MDNewLine -$markdown += (Get-VisualStudioComponents -VSInstallType "BuildTools") | New-MDTable +$markdown += (Get-VisualStudioComponents -ProductType "BuildTools") | New-MDTable $markdown += New-MDNewLine $markdown += New-MDHeader "Microsoft Visual C++:" -Level 4 diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.VisualStudio.psm1 b/images/win/scripts/SoftwareReport/SoftwareReport.VisualStudio.psm1 index ba6907b35..9d1e3941a 100644 --- a/images/win/scripts/SoftwareReport/SoftwareReport.VisualStudio.psm1 +++ b/images/win/scripts/SoftwareReport/SoftwareReport.VisualStudio.psm1 @@ -23,7 +23,7 @@ function Get-VisualStudioExtensions { # Wix $vs = (Get-VisualStudioVersion).Name.Split()[-1] $wixPackageVersion = Get-WixVersion - $wixExtensionVersion = ((Get-VisualStudioInstallation -VSInstallType "VS").Packages | Where-Object {$_.Id -match 'WixToolset.VisualStudioExtension.Dev' -and $_.type -eq 'vsix'}).Version + $wixExtensionVersion = ((Get-VisualStudioProduct -ProductType "VisualStudio").Packages | Where-Object {$_.Id -match 'WixToolset.VisualStudioExtension.Dev' -and $_.type -eq 'vsix'}).Version # WDK $wdkPackageVersion = Get-VSExtensionVersion -packageName 'Microsoft.Windows.DriverKit' diff --git a/images/win/scripts/Tests/VisualStudio.Tests.ps1 b/images/win/scripts/Tests/VisualStudio.Tests.ps1 index 315e7e5c2..0b56165a1 100644 --- a/images/win/scripts/Tests/VisualStudio.Tests.ps1 +++ b/images/win/scripts/Tests/VisualStudio.Tests.ps1 @@ -5,7 +5,7 @@ Describe "Visual Studio" { } It "Devenv.exe" { - $vsInstallRoot = (Get-VisualStudioInstallation -VSInstallType "VS").InstallationPath + $vsInstallRoot = (Get-VisualStudioProduct -ProductType "VisualStudio").InstallationPath $devenvexePath = "${vsInstallRoot}\Common7\IDE\devenv.exe" $devenvexePath | Should -Exist } @@ -15,7 +15,7 @@ Describe "Visual Studio" { $expectedComponents = Get-ToolsetContent | Select-Object -ExpandProperty visualStudio | Select-Object -ExpandProperty workloads $testCases = $expectedComponents | ForEach-Object { @{ComponentName = $_} } BeforeAll { - $installedComponents = Get-VisualStudioComponents -VSInstallType "VS" | Select-Object -ExpandProperty Package + $installedComponents = Get-VisualStudioComponents -ProductType "VisualStudio" | Select-Object -ExpandProperty Package } It "" -TestCases $testCases { @@ -23,11 +23,11 @@ Describe "Visual Studio" { } } - Context "Visual Studio build components" { - $expectedComponents = Get-ToolsetContent | Select-Object -ExpandProperty visualStudio | Select-Object -ExpandProperty build_workloads + Context "Visual Studio Build Tools components" { + $expectedComponents = Get-ToolsetContent | Select-Object -ExpandProperty visualStudio | Select-Object -ExpandProperty buildtools_workloads $testCases = $expectedComponents | ForEach-Object { @{ComponentName = $_} } BeforeAll { - $installedComponents = Get-VisualStudioComponents -VSInstallType "Build" | Select-Object -ExpandProperty Package + $installedComponents = Get-VisualStudioComponents -ProductType "Build" | Select-Object -ExpandProperty Package } It "" -TestCases $testCases { diff --git a/images/win/toolsets/toolset-2016.json b/images/win/toolsets/toolset-2016.json index d9a5a3259..feaa8e758 100644 --- a/images/win/toolsets/toolset-2016.json +++ b/images/win/toolsets/toolset-2016.json @@ -227,7 +227,7 @@ "Microsoft.VisualStudio.Component.Workflow", "Microsoft.VisualStudio.Workload.Office" ], - "build_workloads": [ + "buildtools_workloads": [ "Microsoft.VisualStudio.Workload.WebBuildTools" ] } diff --git a/images/win/toolsets/toolset-2019.json b/images/win/toolsets/toolset-2019.json index 684579e21..4a5c0fecf 100644 --- a/images/win/toolsets/toolset-2019.json +++ b/images/win/toolsets/toolset-2019.json @@ -258,7 +258,7 @@ "Component.MDD.Linux", "Component.MDD.Linux.GCC.arm" ], - "build_workloads": [ + "buildtools_workloads": [ "Microsoft.VisualStudio.Workload.WebBuildTools" ] }