From cf9a92d64ebb7b289782fc9ce0598ebec8267434 Mon Sep 17 00:00:00 2001 From: Leonid Lapshin Date: Tue, 1 Sep 2020 15:53:26 +0300 Subject: [PATCH 01/10] add VS build tools installation, tests, reports, made minor changes to current VS install helper functions --- .../scripts/ImageHelpers/ImageHelpers.psm1 | 3 +- .../scripts/ImageHelpers/InstallHelpers.ps1 | 10 +---- .../ImageHelpers/VisualStudioHelpers.ps1 | 38 ++++++++++++++----- images/win/scripts/Installers/Install-VS.ps1 | 25 ++++++------ .../SoftwareReport.Generator.ps1 | 7 +++- .../SoftwareReport.VisualStudio.psm1 | 2 +- .../win/scripts/Tests/VisualStudio.Tests.ps1 | 16 +++++++- images/win/toolsets/toolset-2016.json | 3 ++ images/win/toolsets/toolset-2019.json | 3 ++ 9 files changed, 70 insertions(+), 37 deletions(-) diff --git a/images/win/scripts/ImageHelpers/ImageHelpers.psm1 b/images/win/scripts/ImageHelpers/ImageHelpers.psm1 index e150e1a1..9441ac7a 100644 --- a/images/win/scripts/ImageHelpers/ImageHelpers.psm1 +++ b/images/win/scripts/ImageHelpers/ImageHelpers.psm1 @@ -35,8 +35,7 @@ Export-ModuleMember -Function @( 'Get-EnvironmentVariable' 'Invoke-PesterTests' 'Get-VsCatalogJsonPath' - 'Get-VisualStudioPath' 'Install-AndroidSDKPackages' - 'Get-VisualStudioPackages' + 'Get-VisualStudioInstallation' 'Get-VisualStudioComponents' ) diff --git a/images/win/scripts/ImageHelpers/InstallHelpers.ps1 b/images/win/scripts/ImageHelpers/InstallHelpers.ps1 index 282c0376..dc815eea 100644 --- a/images/win/scripts/ImageHelpers/InstallHelpers.ps1 +++ b/images/win/scripts/ImageHelpers/InstallHelpers.ps1 @@ -266,14 +266,8 @@ function Get-VSExtensionVersion [string] $packageName ) - $instanceFolders = Get-ChildItem -Path "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances" - if ($instanceFolders -is [array]) - { - Write-Host "More than one instance installed" - exit 1 - } - - $stateContent = Get-Content -Path (Join-Path $instanceFolders.FullName '\state.packages.json') + $instanceFolders = "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances\" + (Get-VisualStudioInstallation -VSInstallType "VS").InstanceId + $stateContent = Get-Content -Path (Join-Path $instanceFolders '\state.packages.json') $state = $stateContent | ConvertFrom-Json $packageVersion = ($state.packages | Where-Object { $_.id -eq $packageName }).version diff --git a/images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1 b/images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1 index 0fd6bc8b..bf87912d 100644 --- a/images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1 +++ b/images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1 @@ -61,20 +61,40 @@ Function Install-VisualStudio } function Get-VsCatalogJsonPath { - $instanceFolder = Get-Item "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances\*" | Select-Object -First 1 - return Join-Path $instanceFolder.FullName "catalog.json" + $instanceFolder = "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances\" + (Get-VisualStudioInstallation -VSInstallType "VS").InstanceId + return Join-Path $instanceFolder "catalog.json" } -function Get-VisualStudioPath { - return (Get-VSSetupInstance | Select-VSSetupInstance -Product *).InstallationPath -} +function Get-VisualStudioInstallation { + Param + ( + [Parameter(Mandatory)] + [String] $VSInstallType + ) -function Get-VisualStudioPackages { - return (Get-VSSetupInstance | Select-VSSetupInstance -Product *).Packages + if ($VSInstallType -eq "VS") + { + $VSSelectionType = "*Enterprise*" + } + elseif ($VSInstallType -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 } function Get-VisualStudioComponents { - Get-VisualStudioPackages | Where-Object type -in 'Component', 'Workload' | + Param + ( + [Parameter(Mandatory)] + [String] $VSInstallType + ) + (Get-VisualStudioInstallation -VSInstallType $VSInstallType).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}" } -} \ No newline at end of file +} diff --git a/images/win/scripts/Installers/Install-VS.ps1 b/images/win/scripts/Installers/Install-VS.ps1 index ed4fca73..9d075ce4 100644 --- a/images/win/scripts/Installers/Install-VS.ps1 +++ b/images/win/scripts/Installers/Install-VS.ps1 @@ -1,38 +1,35 @@ ################################################################################ ## File: Install-VS.ps1 -## Desc: Install Visual Studio +## Desc: Install Visual Studio and build tools ################################################################################ $ErrorActionPreference = "Stop" $toolset = Get-ToolsetContent $requiredComponents = $toolset.visualStudio.workloads | ForEach-Object { "--add $_" } +$buildRequiredComponents = $toolset.visualStudio.build_workloads | ForEach-Object { "--add $_" } $workLoads = @( "--allWorkloads --includeRecommended" $requiredComponents "--remove Component.CPython3.x64" ) $workLoadsArgument = [String]::Join(" ", $workLoads) +$buildWorkLoads = @( + "--includeRecommended" + $buildRequiredComponents +) +$buildWorkLoadsArgument = [String]::Join(" ", $buildWorkLoads) $releaseInPath = $toolset.visualStudio.edition $subVersion = $toolset.visualStudio.subversion $bootstrapperUrl = "https://aka.ms/vs/${subVersion}/release/vs_${releaseInPath}.exe" +$buildbootstrapperUrl = "https://aka.ms/vs/${subVersion}/release/vs_buildtools.exe" -# Install VS +# Install VS and VS Build tools Install-VisualStudio -BootstrapperUrl $bootstrapperUrl -WorkLoads $workLoadsArgument +Install-VisualStudio -BootstrapperUrl $buildbootstrapperUrl -WorkLoads $buildWorkLoadsArgument -# Find the version of VS installed for this instance -# Only supports a single instance -$vsProgramData = Get-Item -Path "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances" -$instanceFolders = Get-ChildItem -Path $vsProgramData.FullName - -if ($instanceFolders -is [array]) -{ - Write-Host "More than one instance installed" - exit 1 -} - -$vsInstallRoot = Get-VisualStudioPath +$vsInstallRoot = (Get-VisualStudioInstallation -VStype "VS").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 eb8b35f0..e818a25d 100644 --- a/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 +++ b/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 @@ -171,7 +171,12 @@ $markdown += New-MDNewLine $markdown += New-MDHeader "Workloads, components and extensions:" -Level 4 $markdown += New-MDNewLine -$markdown += ((Get-VisualStudioComponents) + (Get-VisualStudioExtensions)) | New-MDTable +$markdown += ((Get-VisualStudioComponents -VSInstallType "VS") + (Get-VisualStudioExtensions)) | New-MDTable +$markdown += New-MDNewLine + +$markdown += New-MDHeader "Build Workloads and components:" -Level 4 +$markdown += New-MDNewLine +$markdown += (Get-VisualStudioComponents -VSInstallType "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 0004c168..ba6907b3 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-VisualStudioPackages | Where-Object {$_.Id -match 'WixToolset.VisualStudioExtension.Dev' -and $_.type -eq 'vsix'}).Version + $wixExtensionVersion = ((Get-VisualStudioInstallation -VSInstallType "VS").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 142a9917..14806a5a 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-VisualStudioPath + $vsInstallRoot = (Get-VisualStudioInstallation -VStype "VS").InstallationPath $devenvexePath = "${vsInstallRoot}\Common7\IDE\devenv.exe" $devenvexePath | Should -Exist } @@ -15,7 +15,19 @@ Describe "Visual Studio" { $expectedComponents = Get-ToolsetContent | Select-Object -ExpandProperty visualStudio | Select-Object -ExpandProperty workloads $testCases = $expectedComponents | ForEach-Object { @{ComponentName = $_} } BeforeAll { - $installedComponents = Get-VisualStudioComponents | Select-Object -ExpandProperty Package + $installedComponents = Get-VisualStudioComponents -VSInstallType "VS" | Select-Object -ExpandProperty Package + } + + It "" -TestCases $testCases { + $installedComponents | Should -Contain $ComponentName + } + } + + Context "Visual Studio build components" { + $expectedComponents = Get-ToolsetContent | Select-Object -ExpandProperty visualStudio | Select-Object -ExpandProperty build_workloads + $testCases = $expectedComponents | ForEach-Object { @{ComponentName = $_} } + BeforeAll { + $installedComponents = Get-VisualStudioComponents -VSInstallType "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 f01e9473..d9a5a325 100644 --- a/images/win/toolsets/toolset-2016.json +++ b/images/win/toolsets/toolset-2016.json @@ -226,6 +226,9 @@ "Microsoft.VisualStudio.Component.VC.Runtimes.ARM64.Spectre", "Microsoft.VisualStudio.Component.Workflow", "Microsoft.VisualStudio.Workload.Office" + ], + "build_workloads": [ + "Microsoft.VisualStudio.Workload.WebBuildTools" ] } } diff --git a/images/win/toolsets/toolset-2019.json b/images/win/toolsets/toolset-2019.json index e29552df..684579e2 100644 --- a/images/win/toolsets/toolset-2019.json +++ b/images/win/toolsets/toolset-2019.json @@ -257,6 +257,9 @@ "Microsoft.VisualStudio.Workload.VisualStudioExtension", "Component.MDD.Linux", "Component.MDD.Linux.GCC.arm" + ], + "build_workloads": [ + "Microsoft.VisualStudio.Workload.WebBuildTools" ] } } From e1d821a0733d6dced74d1bf158dd8765eb17918f Mon Sep 17 00:00:00 2001 From: Leonid Lapshin Date: Tue, 1 Sep 2020 16:05:15 +0300 Subject: [PATCH 02/10] Vstype typo --- images/win/scripts/Installers/Install-VS.ps1 | 2 +- images/win/scripts/Tests/VisualStudio.Tests.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/images/win/scripts/Installers/Install-VS.ps1 b/images/win/scripts/Installers/Install-VS.ps1 index 9d075ce4..af834b62 100644 --- a/images/win/scripts/Installers/Install-VS.ps1 +++ b/images/win/scripts/Installers/Install-VS.ps1 @@ -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 -VStype "VS").InstallationPath +$vsInstallRoot = (Get-VisualStudioInstallation -VSInstallType "VS").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/Tests/VisualStudio.Tests.ps1 b/images/win/scripts/Tests/VisualStudio.Tests.ps1 index 14806a5a..315e7e5c 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 -VStype "VS").InstallationPath + $vsInstallRoot = (Get-VisualStudioInstallation -VSInstallType "VS").InstallationPath $devenvexePath = "${vsInstallRoot}\Common7\IDE\devenv.exe" $devenvexePath | Should -Exist } From ade2f9d34a48bac7ead22af7aa8e0b506a6a6b5f Mon Sep 17 00:00:00 2001 From: Leonid Lapshin Date: Tue, 1 Sep 2020 16:17:55 +0300 Subject: [PATCH 03/10] removed unused variable --- images/win/scripts/ImageHelpers/InstallHelpers.ps1 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/images/win/scripts/ImageHelpers/InstallHelpers.ps1 b/images/win/scripts/ImageHelpers/InstallHelpers.ps1 index dc815eea..76739178 100644 --- a/images/win/scripts/ImageHelpers/InstallHelpers.ps1 +++ b/images/win/scripts/ImageHelpers/InstallHelpers.ps1 @@ -267,8 +267,7 @@ function Get-VSExtensionVersion ) $instanceFolders = "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances\" + (Get-VisualStudioInstallation -VSInstallType "VS").InstanceId - $stateContent = Get-Content -Path (Join-Path $instanceFolders '\state.packages.json') - $state = $stateContent | ConvertFrom-Json + $state = Get-Content -Path (Join-Path $instanceFolders '\state.packages.json') | ConvertFrom-Json $packageVersion = ($state.packages | Where-Object { $_.id -eq $packageName }).version if (-not $packageVersion) From 425d62e593503b0b9df9bbcdd9173b0a6414f4bb Mon Sep 17 00:00:00 2001 From: Leonid Lapshin Date: Tue, 1 Sep 2020 17:22:57 +0300 Subject: [PATCH 04/10] validate set for new functions --- images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1 b/images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1 index bf87912d..10e8d0cd 100644 --- a/images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1 +++ b/images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1 @@ -69,6 +69,7 @@ function Get-VisualStudioInstallation { Param ( [Parameter(Mandatory)] + [ValidateSet('VS','BuildTools')] [String] $VSInstallType ) @@ -92,6 +93,7 @@ function Get-VisualStudioComponents { Param ( [Parameter(Mandatory)] + [ValidateSet('VS','BuildTools')] [String] $VSInstallType ) (Get-VisualStudioInstallation -VSInstallType $VSInstallType).Packages | Where-Object type -in 'Component', 'Workload' | From fdf40a931b7c67d27cc7710959b0f146b77ea88f Mon Sep 17 00:00:00 2001 From: Leonid Lapshin Date: Tue, 1 Sep 2020 22:05:26 +0300 Subject: [PATCH 05/10] some variable names clarifications --- .../scripts/ImageHelpers/ImageHelpers.psm1 | 2 +- .../scripts/ImageHelpers/InstallHelpers.ps1 | 21 --------- .../ImageHelpers/VisualStudioHelpers.ps1 | 43 +++++++++++++------ images/win/scripts/Installers/Install-VS.ps1 | 10 ++--- .../SoftwareReport.Generator.ps1 | 6 +-- .../SoftwareReport.VisualStudio.psm1 | 2 +- .../win/scripts/Tests/VisualStudio.Tests.ps1 | 10 ++--- images/win/toolsets/toolset-2016.json | 2 +- images/win/toolsets/toolset-2019.json | 2 +- 9 files changed, 46 insertions(+), 52 deletions(-) diff --git a/images/win/scripts/ImageHelpers/ImageHelpers.psm1 b/images/win/scripts/ImageHelpers/ImageHelpers.psm1 index 9441ac7a..07b40662 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 76739178..9f1a32f6 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 10e8d0cd..8be653f4 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 af834b62..be776dde 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 e818a25d..5ff886c7 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 ba6907b3..9d1e3941 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 315e7e5c..0b56165a 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 d9a5a325..feaa8e75 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 684579e2..4a5c0fec 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" ] } From 26183d0fa773fdf6a62b834b398f2b9dda34faae Mon Sep 17 00:00:00 2001 From: Leonid Lapshin Date: Wed, 2 Sep 2020 16:43:01 +0300 Subject: [PATCH 06/10] test parameter error --- images/win/scripts/Tests/VisualStudio.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/win/scripts/Tests/VisualStudio.Tests.ps1 b/images/win/scripts/Tests/VisualStudio.Tests.ps1 index 0b56165a..34c59e2d 100644 --- a/images/win/scripts/Tests/VisualStudio.Tests.ps1 +++ b/images/win/scripts/Tests/VisualStudio.Tests.ps1 @@ -27,7 +27,7 @@ Describe "Visual Studio" { $expectedComponents = Get-ToolsetContent | Select-Object -ExpandProperty visualStudio | Select-Object -ExpandProperty buildtools_workloads $testCases = $expectedComponents | ForEach-Object { @{ComponentName = $_} } BeforeAll { - $installedComponents = Get-VisualStudioComponents -ProductType "Build" | Select-Object -ExpandProperty Package + $installedComponents = Get-VisualStudioComponents -ProductType "BuildTools" | Select-Object -ExpandProperty Package } It "" -TestCases $testCases { From e438bd43025d12230714255eb77f22fed78b770b Mon Sep 17 00:00:00 2001 From: Leonid Lapshin Date: Thu, 3 Sep 2020 10:34:05 +0300 Subject: [PATCH 07/10] style and syntax improvments --- .../win/scripts/ImageHelpers/VisualStudioHelpers.ps1 | 12 +++++++----- images/win/scripts/Tests/VisualStudio.Tests.ps1 | 6 ++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1 b/images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1 index 8be653f4..7c1b7a1c 100644 --- a/images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1 +++ b/images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1 @@ -60,9 +60,12 @@ Function Install-VisualStudio } } +function Get-VisualStudioInstancePath { + return "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances\" + (Get-VisualStudioProduct -ProductType "VisualStudio").InstanceId +} + function Get-VsCatalogJsonPath { - $instanceFolder = "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances\" + (Get-VisualStudioProduct -ProductType "VisualStudio").InstanceId - return Join-Path $instanceFolder "catalog.json" + return Join-Path (Get-VisualStudioInstancePath) "catalog.json" } function Get-VisualStudioProduct { @@ -81,7 +84,7 @@ function Get-VisualStudioProduct { { $VSSelectionType = "*Build*" } - return Get-VSSetupInstance | Select-VSSetupInstance -Product * | Where-Object -Property DisplayName -like $VSSelectionType + return Get-VSSetupInstance | Where-Object -Property DisplayName -like $VSSelectionType } function Get-VisualStudioComponents { @@ -103,8 +106,7 @@ function Get-VSExtensionVersion [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 + $state = Get-Content -Path (Join-Path (Get-VisualStudioInstancePath) '\state.packages.json') | ConvertFrom-Json $packageVersion = ($state.packages | Where-Object { $_.id -eq $packageName }).version if (-not $packageVersion) diff --git a/images/win/scripts/Tests/VisualStudio.Tests.ps1 b/images/win/scripts/Tests/VisualStudio.Tests.ps1 index 34c59e2d..56869cc9 100644 --- a/images/win/scripts/Tests/VisualStudio.Tests.ps1 +++ b/images/win/scripts/Tests/VisualStudio.Tests.ps1 @@ -12,8 +12,7 @@ Describe "Visual Studio" { } Context "Visual Studio components" { - $expectedComponents = Get-ToolsetContent | Select-Object -ExpandProperty visualStudio | Select-Object -ExpandProperty workloads - $testCases = $expectedComponents | ForEach-Object { @{ComponentName = $_} } + $testCases = (Get-ToolsetContent).visualStudio.workloads | ForEach-Object { @{ComponentName = $_} } BeforeAll { $installedComponents = Get-VisualStudioComponents -ProductType "VisualStudio" | Select-Object -ExpandProperty Package } @@ -24,8 +23,7 @@ Describe "Visual Studio" { } Context "Visual Studio Build Tools components" { - $expectedComponents = Get-ToolsetContent | Select-Object -ExpandProperty visualStudio | Select-Object -ExpandProperty buildtools_workloads - $testCases = $expectedComponents | ForEach-Object { @{ComponentName = $_} } + $testCases = (Get-ToolsetContent).visualStudio.buildtools_workloads | ForEach-Object { @{ComponentName = $_} } BeforeAll { $installedComponents = Get-VisualStudioComponents -ProductType "BuildTools" | Select-Object -ExpandProperty Package } From 2e6ca0ca5607ca389569e49ebdded79fed2b8a19 Mon Sep 17 00:00:00 2001 From: Leonid Lapshin Date: Mon, 7 Sep 2020 10:27:55 +0300 Subject: [PATCH 08/10] syntax notation --- images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1 | 6 +++--- .../SoftwareReport/SoftwareReport.VisualStudio.psm1 | 8 ++++---- images/win/scripts/Tests/SSDTExtensions.Tests.ps1 | 4 ++-- images/win/scripts/Tests/WDK.Tests.ps1 | 2 +- images/win/scripts/Tests/Wix.Tests.ps1 | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1 b/images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1 index 7c1b7a1c..d9478390 100644 --- a/images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1 +++ b/images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1 @@ -103,15 +103,15 @@ function Get-VSExtensionVersion Param ( [Parameter(Mandatory=$true)] - [string] $packageName + [string] $PackageName ) $state = Get-Content -Path (Join-Path (Get-VisualStudioInstancePath) '\state.packages.json') | ConvertFrom-Json - $packageVersion = ($state.packages | Where-Object { $_.id -eq $packageName }).version + $packageVersion = ($state.packages | Where-Object { $_.id -eq $PackageName }).version if (-not $packageVersion) { - Write-Host "installed package $packageName for Visual Studio 2019 was not found" + Write-Host "installed package $PackageName for Visual Studio 2019 was not found" exit 1 } diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.VisualStudio.psm1 b/images/win/scripts/SoftwareReport/SoftwareReport.VisualStudio.psm1 index 9d1e3941..9427ccc3 100644 --- a/images/win/scripts/SoftwareReport/SoftwareReport.VisualStudio.psm1 +++ b/images/win/scripts/SoftwareReport/SoftwareReport.VisualStudio.psm1 @@ -26,15 +26,15 @@ function Get-VisualStudioExtensions { $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' + $wdkPackageVersion = Get-VSExtensionVersion -PackageName 'Microsoft.Windows.DriverKit' $wdkExtensionVersion = Get-WDKVersion # SSDT - $analysisPackageVersion = Get-VSExtensionVersion -packageName '04a86fc2-dbd5-4222-848e-911638e487fe' - $reportingPackageVersion = Get-VSExtensionVersion -packageName '717ad572-c4b7-435c-c166-c2969777f718' + $analysisPackageVersion = Get-VSExtensionVersion -PackageName '04a86fc2-dbd5-4222-848e-911638e487fe' + $reportingPackageVersion = Get-VSExtensionVersion -PackageName '717ad572-c4b7-435c-c166-c2969777f718' $integrationPackageName = ($vs -match "2019") ? '851E7A09-7B2B-4F06-A15D-BABFCB26B970' : 'D1B09713-C12E-43CC-9EF4-6562298285AB' - $integrationPackageVersion = Get-VSExtensionVersion -packageName $integrationPackageName + $integrationPackageVersion = Get-VSExtensionVersion -PackageName $integrationPackageName $extensions = @( @{Package = 'SSDT Microsoft Analysis Services Projects'; Version = $analysisPackageVersion} diff --git a/images/win/scripts/Tests/SSDTExtensions.Tests.ps1 b/images/win/scripts/Tests/SSDTExtensions.Tests.ps1 index 7d1c6ee0..5b6031de 100644 --- a/images/win/scripts/Tests/SSDTExtensions.Tests.ps1 +++ b/images/win/scripts/Tests/SSDTExtensions.Tests.ps1 @@ -9,12 +9,12 @@ Describe "SSDTExtensions" { ) It "Extensions id=" -TestCases $testExtenions { - $version = Get-VSExtensionVersion -packageName "${id}" + $version = Get-VSExtensionVersion -PackageName "${id}" $version | Should -Not -BeNullOrEmpty } } else { It "Extension SSDT" { - $version = Get-VSExtensionVersion -packageName "SSDT" + $version = Get-VSExtensionVersion -PackageName "SSDT" $version | Should -Not -BeNullOrEmpty } } diff --git a/images/win/scripts/Tests/WDK.Tests.ps1 b/images/win/scripts/Tests/WDK.Tests.ps1 index c67586e7..0f8e7677 100644 --- a/images/win/scripts/Tests/WDK.Tests.ps1 +++ b/images/win/scripts/Tests/WDK.Tests.ps1 @@ -5,7 +5,7 @@ Describe "WDK" { } It "WDK version from system" { - $version = Get-VSExtensionVersion -packageName "Microsoft.Windows.DriverKit" + $version = Get-VSExtensionVersion -PackageName "Microsoft.Windows.DriverKit" $version | Should -Not -BeNullOrEmpty } } diff --git a/images/win/scripts/Tests/Wix.Tests.ps1 b/images/win/scripts/Tests/Wix.Tests.ps1 index 2a12261e..bd22bef3 100644 --- a/images/win/scripts/Tests/Wix.Tests.ps1 +++ b/images/win/scripts/Tests/Wix.Tests.ps1 @@ -12,11 +12,11 @@ Describe "Wix" { It "Wix Toolset version from system" { if (Test-IsWin19) { - $exVersion = Get-VSExtensionVersion -packageName "WixToolset.VisualStudioExtension.Dev16" + $exVersion = Get-VSExtensionVersion -PackageName "WixToolset.VisualStudioExtension.Dev16" } else { - $exVersion = Get-VSExtensionVersion -packageName "WixToolset.VisualStudioExtension.Dev15" + $exVersion = Get-VSExtensionVersion -PackageName "WixToolset.VisualStudioExtension.Dev15" } $exVersion | Should -Not -BeNullOrEmpty } From 128244b89b8532a3604a2ad227eecd05b7a54065 Mon Sep 17 00:00:00 2001 From: Leonid Lapshin Date: Thu, 10 Sep 2020 17:04:24 +0300 Subject: [PATCH 09/10] removed VS buildtools installation --- .../scripts/ImageHelpers/ImageHelpers.psm1 | 3 +- .../scripts/ImageHelpers/InstallHelpers.ps1 | 28 +++++++++ .../ImageHelpers/VisualStudioHelpers.ps1 | 57 +++---------------- images/win/scripts/Installers/Install-VS.ps1 | 25 ++++---- .../SoftwareReport.Generator.ps1 | 7 +-- .../SoftwareReport.VisualStudio.psm1 | 10 ++-- .../scripts/Tests/SSDTExtensions.Tests.ps1 | 4 +- .../win/scripts/Tests/VisualStudio.Tests.ps1 | 18 ++---- images/win/scripts/Tests/WDK.Tests.ps1 | 2 +- images/win/scripts/Tests/Wix.Tests.ps1 | 4 +- images/win/toolsets/toolset-2016.json | 3 - images/win/toolsets/toolset-2019.json | 3 - 12 files changed, 68 insertions(+), 96 deletions(-) diff --git a/images/win/scripts/ImageHelpers/ImageHelpers.psm1 b/images/win/scripts/ImageHelpers/ImageHelpers.psm1 index 07b40662..e150e1a1 100644 --- a/images/win/scripts/ImageHelpers/ImageHelpers.psm1 +++ b/images/win/scripts/ImageHelpers/ImageHelpers.psm1 @@ -35,7 +35,8 @@ Export-ModuleMember -Function @( 'Get-EnvironmentVariable' 'Invoke-PesterTests' 'Get-VsCatalogJsonPath' + 'Get-VisualStudioPath' 'Install-AndroidSDKPackages' - 'Get-VisualStudioProduct' + 'Get-VisualStudioPackages' 'Get-VisualStudioComponents' ) diff --git a/images/win/scripts/ImageHelpers/InstallHelpers.ps1 b/images/win/scripts/ImageHelpers/InstallHelpers.ps1 index 9f1a32f6..282c0376 100644 --- a/images/win/scripts/ImageHelpers/InstallHelpers.ps1 +++ b/images/win/scripts/ImageHelpers/InstallHelpers.ps1 @@ -258,6 +258,34 @@ function Install-VsixExtension } } +function Get-VSExtensionVersion +{ + Param + ( + [Parameter(Mandatory=$true)] + [string] $packageName + ) + + $instanceFolders = Get-ChildItem -Path "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances" + if ($instanceFolders -is [array]) + { + Write-Host "More than one instance installed" + exit 1 + } + + $stateContent = Get-Content -Path (Join-Path $instanceFolders.FullName '\state.packages.json') + $state = $stateContent | 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 d9478390..0fd6bc8b 100644 --- a/images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1 +++ b/images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1 @@ -60,60 +60,21 @@ Function Install-VisualStudio } } -function Get-VisualStudioInstancePath { - return "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances\" + (Get-VisualStudioProduct -ProductType "VisualStudio").InstanceId -} - function Get-VsCatalogJsonPath { - return Join-Path (Get-VisualStudioInstancePath) "catalog.json" + $instanceFolder = Get-Item "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances\*" | Select-Object -First 1 + return Join-Path $instanceFolder.FullName "catalog.json" } -function Get-VisualStudioProduct { - Param - ( - [Parameter(Mandatory)] - [ValidateSet('VisualStudio','BuildTools')] - [String] $ProductType - ) +function Get-VisualStudioPath { + return (Get-VSSetupInstance | Select-VSSetupInstance -Product *).InstallationPath +} - if ($ProductType -eq "VisualStudio") - { - $VSSelectionType = "*Enterprise*" - } - elseif ($ProductType -eq "BuildTools") - { - $VSSelectionType = "*Build*" - } - return Get-VSSetupInstance | Where-Object -Property DisplayName -like $VSSelectionType +function Get-VisualStudioPackages { + return (Get-VSSetupInstance | Select-VSSetupInstance -Product *).Packages } function Get-VisualStudioComponents { - Param - ( - [Parameter(Mandatory)] - [String] $ProductType - ) - (Get-VisualStudioProduct -ProductType $ProductType).Packages | Where-Object type -in 'Component', 'Workload' | + Get-VisualStudioPackages | 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 - ) - - $state = Get-Content -Path (Join-Path (Get-VisualStudioInstancePath) '\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 -} +} \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-VS.ps1 b/images/win/scripts/Installers/Install-VS.ps1 index be776dde..ed4fca73 100644 --- a/images/win/scripts/Installers/Install-VS.ps1 +++ b/images/win/scripts/Installers/Install-VS.ps1 @@ -1,35 +1,38 @@ ################################################################################ ## File: Install-VS.ps1 -## Desc: Install Visual Studio and build tools +## Desc: Install Visual Studio ################################################################################ $ErrorActionPreference = "Stop" $toolset = Get-ToolsetContent $requiredComponents = $toolset.visualStudio.workloads | ForEach-Object { "--add $_" } -$buildToolsRequiredComponents = $toolset.visualStudio.buildtools_workloads | ForEach-Object { "--add $_" } $workLoads = @( "--allWorkloads --includeRecommended" $requiredComponents "--remove Component.CPython3.x64" ) $workLoadsArgument = [String]::Join(" ", $workLoads) -$buildToolsWorkloads= @( - "--includeRecommended" - $buildToolsRequiredComponents -) -$buildWorkLoadsArgument = [String]::Join(" ", $buildToolsWorkloads) $releaseInPath = $toolset.visualStudio.edition $subVersion = $toolset.visualStudio.subversion $bootstrapperUrl = "https://aka.ms/vs/${subVersion}/release/vs_${releaseInPath}.exe" -$buildbootstrapperUrl = "https://aka.ms/vs/${subVersion}/release/vs_buildtools.exe" -# Install VS and VS Build tools +# Install VS Install-VisualStudio -BootstrapperUrl $bootstrapperUrl -WorkLoads $workLoadsArgument -Install-VisualStudio -BootstrapperUrl $buildbootstrapperUrl -WorkLoads $buildWorkLoadsArgument -$vsInstallRoot = (Get-VisualStudioProduct -ProductType "VisualStudio").InstallationPath +# Find the version of VS installed for this instance +# Only supports a single instance +$vsProgramData = Get-Item -Path "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances" +$instanceFolders = Get-ChildItem -Path $vsProgramData.FullName + +if ($instanceFolders -is [array]) +{ + Write-Host "More than one instance installed" + exit 1 +} + +$vsInstallRoot = Get-VisualStudioPath # 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 5ff886c7..eb8b35f0 100644 --- a/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 +++ b/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 @@ -171,12 +171,7 @@ $markdown += New-MDNewLine $markdown += New-MDHeader "Workloads, components and extensions:" -Level 4 $markdown += New-MDNewLine -$markdown += ((Get-VisualStudioComponents -ProductType "VisualStudio") + (Get-VisualStudioExtensions)) | New-MDTable -$markdown += New-MDNewLine - -$markdown += New-MDHeader "Build Tools Workloads:" -Level 4 -$markdown += New-MDNewLine -$markdown += (Get-VisualStudioComponents -ProductType "BuildTools") | New-MDTable +$markdown += ((Get-VisualStudioComponents) + (Get-VisualStudioExtensions)) | 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 9427ccc3..0004c168 100644 --- a/images/win/scripts/SoftwareReport/SoftwareReport.VisualStudio.psm1 +++ b/images/win/scripts/SoftwareReport/SoftwareReport.VisualStudio.psm1 @@ -23,18 +23,18 @@ function Get-VisualStudioExtensions { # Wix $vs = (Get-VisualStudioVersion).Name.Split()[-1] $wixPackageVersion = Get-WixVersion - $wixExtensionVersion = ((Get-VisualStudioProduct -ProductType "VisualStudio").Packages | Where-Object {$_.Id -match 'WixToolset.VisualStudioExtension.Dev' -and $_.type -eq 'vsix'}).Version + $wixExtensionVersion = (Get-VisualStudioPackages | Where-Object {$_.Id -match 'WixToolset.VisualStudioExtension.Dev' -and $_.type -eq 'vsix'}).Version # WDK - $wdkPackageVersion = Get-VSExtensionVersion -PackageName 'Microsoft.Windows.DriverKit' + $wdkPackageVersion = Get-VSExtensionVersion -packageName 'Microsoft.Windows.DriverKit' $wdkExtensionVersion = Get-WDKVersion # SSDT - $analysisPackageVersion = Get-VSExtensionVersion -PackageName '04a86fc2-dbd5-4222-848e-911638e487fe' - $reportingPackageVersion = Get-VSExtensionVersion -PackageName '717ad572-c4b7-435c-c166-c2969777f718' + $analysisPackageVersion = Get-VSExtensionVersion -packageName '04a86fc2-dbd5-4222-848e-911638e487fe' + $reportingPackageVersion = Get-VSExtensionVersion -packageName '717ad572-c4b7-435c-c166-c2969777f718' $integrationPackageName = ($vs -match "2019") ? '851E7A09-7B2B-4F06-A15D-BABFCB26B970' : 'D1B09713-C12E-43CC-9EF4-6562298285AB' - $integrationPackageVersion = Get-VSExtensionVersion -PackageName $integrationPackageName + $integrationPackageVersion = Get-VSExtensionVersion -packageName $integrationPackageName $extensions = @( @{Package = 'SSDT Microsoft Analysis Services Projects'; Version = $analysisPackageVersion} diff --git a/images/win/scripts/Tests/SSDTExtensions.Tests.ps1 b/images/win/scripts/Tests/SSDTExtensions.Tests.ps1 index 5b6031de..7d1c6ee0 100644 --- a/images/win/scripts/Tests/SSDTExtensions.Tests.ps1 +++ b/images/win/scripts/Tests/SSDTExtensions.Tests.ps1 @@ -9,12 +9,12 @@ Describe "SSDTExtensions" { ) It "Extensions id=" -TestCases $testExtenions { - $version = Get-VSExtensionVersion -PackageName "${id}" + $version = Get-VSExtensionVersion -packageName "${id}" $version | Should -Not -BeNullOrEmpty } } else { It "Extension SSDT" { - $version = Get-VSExtensionVersion -PackageName "SSDT" + $version = Get-VSExtensionVersion -packageName "SSDT" $version | Should -Not -BeNullOrEmpty } } diff --git a/images/win/scripts/Tests/VisualStudio.Tests.ps1 b/images/win/scripts/Tests/VisualStudio.Tests.ps1 index 56869cc9..142a9917 100644 --- a/images/win/scripts/Tests/VisualStudio.Tests.ps1 +++ b/images/win/scripts/Tests/VisualStudio.Tests.ps1 @@ -5,27 +5,17 @@ Describe "Visual Studio" { } It "Devenv.exe" { - $vsInstallRoot = (Get-VisualStudioProduct -ProductType "VisualStudio").InstallationPath + $vsInstallRoot = Get-VisualStudioPath $devenvexePath = "${vsInstallRoot}\Common7\IDE\devenv.exe" $devenvexePath | Should -Exist } } Context "Visual Studio components" { - $testCases = (Get-ToolsetContent).visualStudio.workloads | ForEach-Object { @{ComponentName = $_} } + $expectedComponents = Get-ToolsetContent | Select-Object -ExpandProperty visualStudio | Select-Object -ExpandProperty workloads + $testCases = $expectedComponents | ForEach-Object { @{ComponentName = $_} } BeforeAll { - $installedComponents = Get-VisualStudioComponents -ProductType "VisualStudio" | Select-Object -ExpandProperty Package - } - - It "" -TestCases $testCases { - $installedComponents | Should -Contain $ComponentName - } - } - - Context "Visual Studio Build Tools components" { - $testCases = (Get-ToolsetContent).visualStudio.buildtools_workloads | ForEach-Object { @{ComponentName = $_} } - BeforeAll { - $installedComponents = Get-VisualStudioComponents -ProductType "BuildTools" | Select-Object -ExpandProperty Package + $installedComponents = Get-VisualStudioComponents | Select-Object -ExpandProperty Package } It "" -TestCases $testCases { diff --git a/images/win/scripts/Tests/WDK.Tests.ps1 b/images/win/scripts/Tests/WDK.Tests.ps1 index 0f8e7677..c67586e7 100644 --- a/images/win/scripts/Tests/WDK.Tests.ps1 +++ b/images/win/scripts/Tests/WDK.Tests.ps1 @@ -5,7 +5,7 @@ Describe "WDK" { } It "WDK version from system" { - $version = Get-VSExtensionVersion -PackageName "Microsoft.Windows.DriverKit" + $version = Get-VSExtensionVersion -packageName "Microsoft.Windows.DriverKit" $version | Should -Not -BeNullOrEmpty } } diff --git a/images/win/scripts/Tests/Wix.Tests.ps1 b/images/win/scripts/Tests/Wix.Tests.ps1 index bd22bef3..2a12261e 100644 --- a/images/win/scripts/Tests/Wix.Tests.ps1 +++ b/images/win/scripts/Tests/Wix.Tests.ps1 @@ -12,11 +12,11 @@ Describe "Wix" { It "Wix Toolset version from system" { if (Test-IsWin19) { - $exVersion = Get-VSExtensionVersion -PackageName "WixToolset.VisualStudioExtension.Dev16" + $exVersion = Get-VSExtensionVersion -packageName "WixToolset.VisualStudioExtension.Dev16" } else { - $exVersion = Get-VSExtensionVersion -PackageName "WixToolset.VisualStudioExtension.Dev15" + $exVersion = Get-VSExtensionVersion -packageName "WixToolset.VisualStudioExtension.Dev15" } $exVersion | Should -Not -BeNullOrEmpty } diff --git a/images/win/toolsets/toolset-2016.json b/images/win/toolsets/toolset-2016.json index c292c7af..a76246e6 100644 --- a/images/win/toolsets/toolset-2016.json +++ b/images/win/toolsets/toolset-2016.json @@ -227,9 +227,6 @@ "Microsoft.VisualStudio.Component.VC.Runtimes.ARM64.Spectre", "Microsoft.VisualStudio.Component.Workflow", "Microsoft.VisualStudio.Workload.Office" - ], - "buildtools_workloads": [ - "Microsoft.VisualStudio.Workload.WebBuildTools" ] } } diff --git a/images/win/toolsets/toolset-2019.json b/images/win/toolsets/toolset-2019.json index db7919f9..a2a7ec4a 100644 --- a/images/win/toolsets/toolset-2019.json +++ b/images/win/toolsets/toolset-2019.json @@ -259,9 +259,6 @@ "Microsoft.VisualStudio.Workload.VisualStudioExtension", "Component.MDD.Linux", "Component.MDD.Linux.GCC.arm" - ], - "buildtools_workloads": [ - "Microsoft.VisualStudio.Workload.WebBuildTools" ] } } From a963caf625d56a4ec140aad03de2b46f3bb2ae4a Mon Sep 17 00:00:00 2001 From: Leonid Lapshin Date: Fri, 11 Sep 2020 08:58:54 +0300 Subject: [PATCH 10/10] cobertura jars link changed --- images/win/scripts/Installers/Install-JavaTools.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/win/scripts/Installers/Install-JavaTools.ps1 b/images/win/scripts/Installers/Install-JavaTools.ps1 index 759d132f..04a56a91 100644 --- a/images/win/scripts/Installers/Install-JavaTools.ps1 +++ b/images/win/scripts/Installers/Install-JavaTools.ps1 @@ -119,7 +119,7 @@ setx M2_REPO $m2_repo /M setx MAVEN_OPTS $maven_opts /M # Download cobertura jars -$uri = 'https://ayera.dl.sourceforge.net/project/cobertura/cobertura/2.1.1/cobertura-2.1.1-bin.zip' +$uri = 'https://downloads.sourceforge.net/project/cobertura/cobertura/2.1.1/cobertura-2.1.1-bin.zip' $coberturaPath = "C:\cobertura-2.1.1" $archivePath = Start-DownloadWithRetry -Url $uri -Name "cobertura.zip"