From 3aeecf18ab9f06b710b58c3cfd1f2d64f8826593 Mon Sep 17 00:00:00 2001 From: Mikhail Timofeev Date: Tue, 18 Feb 2020 20:32:24 +0300 Subject: [PATCH] add WDK validation --- .../Installers/Windows2019/Install-WDK.ps1 | 15 ++++--- .../Installers/Windows2019/Validate-WDK.ps1 | 42 ++++++++++++++++++- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/images/win/scripts/Installers/Windows2019/Install-WDK.ps1 b/images/win/scripts/Installers/Windows2019/Install-WDK.ps1 index 205275e0..5389870b 100644 --- a/images/win/scripts/Installers/Windows2019/Install-WDK.ps1 +++ b/images/win/scripts/Installers/Windows2019/Install-WDK.ps1 @@ -3,10 +3,6 @@ ## Desc: Install the Windows Driver Kit ################################################################################ -# Version: 10.0.18362.0 -# Update Validate-WDK.ps1 if the version changes! -# There doesn't seem to be any way to check the version programmatically - # Requires Windows SDK with the same version number as the WDK $winSdkUrl = "https://go.microsoft.com/fwlink/p/?linkid=2083338" $wdkUrl = "https://go.microsoft.com/fwlink/?linkid=2085767" @@ -31,11 +27,20 @@ if ($wdkExitCode -ne 0) # Need to install the VSIX to get the build targets when running VSBuild # Write-Host "Installing WDK.vsix" - $process = Start-Process ` +try +{ + $process = Start-Process ` -FilePath "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\VSIXInstaller.exe" ` -ArgumentList ("/quiet", '"C:\Program Files (x86)\Windows Kits\10\Vsix\VS2019\WDK.vsix"') ` -Wait ` -PassThru +} +catch +{ + Write-Host "There is an error during WDK.vsix installation" + $_ +} + $exitCode = $process.ExitCode diff --git a/images/win/scripts/Installers/Windows2019/Validate-WDK.ps1 b/images/win/scripts/Installers/Windows2019/Validate-WDK.ps1 index db941621..f1fe044d 100644 --- a/images/win/scripts/Installers/Windows2019/Validate-WDK.ps1 +++ b/images/win/scripts/Installers/Windows2019/Validate-WDK.ps1 @@ -3,11 +3,51 @@ ## Desc: Validate the installation of the Windows Driver Kit ################################################################################ +function Get-WDKExtensionPackage { + $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 + } + + $stateContent = Get-Content -Path ($instanceFolders.FullName + '\state.packages.json') + $state = $stateContent | ConvertFrom-Json + $WDKPackageVersion = ($state.packages | where { $_.id -eq "Microsoft.Windows.DriverKit" }).version + + if (!$WDKPackageVersion) + { + Write-Host "WDK package for Visual studio was not found" + exit 1 + } + + return $WDKPackageVersion +} + +function Get-WDKVersion +{ + $WDKVersion = (Get-WmiObject Win32_Product -Filter "Name = 'Windows Driver Kit'").version + + if (!$WDK) + { + Write-Host "WDK was not found" + exit 1 + } + + return $WDKVersion +} + +$WDKVersion = Get-WDKVersion +$WDKPackageVersion = Get-WDKExtensionPackage + # Adding description of the software to Markdown $SoftwareName = "Windows Driver Kit" $Description = @" -_Version:_ 10.0.18362.0
+_WDK Version:_ $WDKVersion
+_WDK Visual Studio Extension Version:_ $WDKPackageVersion
"@ Add-SoftwareDetailsToMarkdown -SoftwareName $SoftwareName -DescriptionMarkdown $Description