summaryrefslogtreecommitdiff
path: root/.github/scripts
diff options
context:
space:
mode:
authorMatt <[email protected]>2024-06-27 14:17:05 -0700
committerGitHub <[email protected]>2024-06-27 14:17:05 -0700
commitf9eb04d34edd823873e491a7da6e6ed7a064e823 (patch)
tree601d4ea7c230b6e825cf1104587d075a321d16e7 /.github/scripts
parent2e07f1b58a93eb36c616192045db654cf043a670 (diff)
Refactored vsix install and cleaned up build sampleset
Diffstat (limited to '.github/scripts')
-rw-r--r--.github/scripts/Install-Vsix.ps188
1 files changed, 25 insertions, 63 deletions
diff --git a/.github/scripts/Install-Vsix.ps1 b/.github/scripts/Install-Vsix.ps1
index 8579b36b..50ef088b 100644
--- a/.github/scripts/Install-Vsix.ps1
+++ b/.github/scripts/Install-Vsix.ps1
@@ -1,76 +1,38 @@
<#
.SYNOPSIS
-Checks WDK vsix version and downloads and installs as necessary.
+Download and install the latest WDK VSIX.
#>
-[CmdletBinding()]
-param(
- [bool]$optimize = $false
-)
-
-$root = Get-Location
-
-# launch developer powershell
-Import-Module (Resolve-Path "$env:ProgramFiles\Microsoft Visual Studio\2022\*\Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
-Enter-VsDevShell -VsInstallPath (Resolve-Path "$env:ProgramFiles\Microsoft Visual Studio\2022\*")
-cd $root
-
-# Automatically resolve the latest amd64 VSIX
+# set uri by resolving amd64 vsix
$uri = "https://marketplace.visualstudio.com$((Invoke-WebRequest -Uri "https://marketplace.visualstudio.com/items?itemName=DriverDeveloperKits-WDK.WDKVsix").Links | Where-Object outerHTML -like '*(amd64)*' | select -expand href)"
-# Set local version variable
-$version = ([regex]'(\d+\.)(\d+\.)(\d+\.)(\d+)').Matches($uri).Value
+# set download version
+$uri_version = ([regex]'(\d+\.)(\d+\.)(\d+\.)(\d+)').Matches($uri).Value
-# Set github environment variable for vsix version
-"SAMPLES_VSIX_VERSION=$version" | Out-File -FilePath "$env:GITHUB_ENV" -Append
+# set msbuild path
+$msbuild_path = (Resolve-Path "$env:ProgramFiles\Microsoft Visual Studio\2022\*\MSBuild\")
-function PrintWdkVsix {
- "WDK Vsix Version: $(ls "${env:ProgramData}\Microsoft\VisualStudio\Packages\Microsoft.Windows.DriverKit,version=*" | Select -ExpandProperty Name)"
-}
+# download vsix, expand, and store the downloaded version extracted from the extension manifest
+"Downloading WDK VSIX version: $uri_version..."
+Invoke-WebRequest -Uri "$uri" -OutFile wdk.zip
+"Expanding WDK VSIX archive..."
+Expand-Archive ".\wdk.zip" .\
+"Extracting version from manifest..."
+$downloaded_version = ([xml](Get-Content .\extension.vsixmanifest)).PackageManifest.Metadata.Identity.Version
+"Downloaded WDK VSIX version: $downloaded_version"
-function TestWdkVsix {
- Test-Path "${env:ProgramData}\Microsoft\VisualStudio\Packages\Microsoft.Windows.DriverKit,version=$version"
+# copy msbuild files, extension manifest, and check installed version from the extension manifest
+"Copying WDK extension files to build path..."
+cp (".\`$MSBuild\*", ".\extension.vsixmanifest") "$msbuild_path" -Recurse -Force
+"Extracting version from copied manifest..."
+$installed_version = ([xml](Get-Content ${msbuild_path}\extension.vsixmanifest)).PackageManifest.Metadata.Identity.Version
+"Installed WDK VSIX Version: $installed_version"
+if (-not ("$downloaded_version" -eq "$installed_version")) {
+ "WDK VSIX installation failed due to version mismatch"
+ exit 1
}
-# NOTE: The '$optimize' code path examines the '.vsixmanifest' when downloaded and then examines it again (in the 'MSBuild' directory) once
-# the necessary extension files are copied.
-if ($optimize) {
- $msbuild_path = (Resolve-Path "$env:ProgramFiles\Microsoft Visual Studio\2022\*\MSBuild\")
- "---> Downloading vsix version: $version"
- Invoke-WebRequest -Uri "$uri" -OutFile wdk.zip
- Expand-Archive ".\wdk.zip" .\
- "Downloaded VSIX Version: $(([xml](Get-Content .\extension.vsixmanifest)).PackageManifest.Metadata.Identity.Version)"
- "<--- Download complete"
- "---> Configuring build environment..."
- cp ".\`$MSBuild\*" "$msbuild_path" -Recurse -Force
- cp ".\extension.vsixmanifest" "$msbuild_path"
- "Installed VSIX Version: $(([xml](Get-Content ${msbuild_path}\extension.vsixmanifest)).PackageManifest.Metadata.Identity.Version)"
- "<--- Configuration complete"
-}
-else {
- "Getting installed WDK vsix..."
- PrintWdkVsix
- "Checking the WDK.vsix version installed..."
- if (-not (TestWdkVsix)) {
- "The correct WDK vsix is not installed."
- "Will attempt to download and install now..."
- Invoke-WebRequest -Uri "$uri" -OutFile wdk.vsix
- "Finished downloading."
- "Starting install process. This will take some time to complete..."
- Start-Process vsixinstaller -ArgumentList "/f /q /sp .\wdk.vsix" -wait
- "The install process has finished."
- "Checking the WDK.vsix version installed..."
- if (TestWdkVsix) {
- PrintWdkVsix
- "The WDK vsix version is OK"
- }
- else {
- "The WDK vsix install FAILED"
- Write-Host "`u{274C} wdk vsix install had an issue"
- Write-Error "the wdk vsix cannot be installed at this time"
- exit 1
- }
- }
-}
+# set github environment variable for vsix version
+"SAMPLES_VSIX_VERSION=$installed_version" | Out-File -FilePath "$env:GITHUB_ENV" -Append