diff --git a/eng/build-utils-win.ps1 b/eng/build-utils-win.ps1 new file mode 100644 index 0000000000000000000000000000000000000000..c9c6258af3b77ec33d6bbc1ffcf312b6f27576dc --- /dev/null +++ b/eng/build-utils-win.ps1 @@ -0,0 +1,32 @@ + +# Collection of powershell build utility functions that we use across our scripts. + +Set-StrictMode -version 2.0 +$ErrorActionPreference="Stop" + +Add-Type -AssemblyName 'System.Drawing' +Add-Type -AssemblyName 'System.Windows.Forms' +function Capture-Screenshot($path) { + $width = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Width + $height = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Height + + $bitmap = New-Object System.Drawing.Bitmap $width, $height + try { + $graphics = [System.Drawing.Graphics]::FromImage($bitmap) + try { + $graphics.CopyFromScreen( ` + [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.X, ` + [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Y, ` + 0, ` + 0, ` + $bitmap.Size, ` + [System.Drawing.CopyPixelOperation]::SourceCopy) + } finally { + $graphics.Dispose() + } + + $bitmap.Save($path, [System.Drawing.Imaging.ImageFormat]::Png) + } finally { + $bitmap.Dispose() + } +} diff --git a/eng/build-utils.ps1 b/eng/build-utils.ps1 index 763c6a0e0cff961af84a8d117bf35b544328bc3a..c0f3b9fe257af2239db64d67dcd5c9e3dd8c3f27 100644 --- a/eng/build-utils.ps1 +++ b/eng/build-utils.ps1 @@ -159,7 +159,20 @@ function Exec-Script([string]$script, [string]$scriptArgs = "") { # Ensure the proper .NET Core SDK is available. Returns the location to the dotnet.exe. function Ensure-DotnetSdk() { - return Join-Path (InitializeDotNetCli -install:$true) "dotnet.exe" + $dotnetInstallDir = (InitializeDotNetCli -install:$true) + $dotnetTestPath = Join-Path $dotnetInstallDir "dotnet.exe" + if (Test-Path -Path $dotnetTestPath) + { + return $dotnetTestPath + } + + $dotnetTestPath = Join-Path $dotnetInstallDir "dotnet" + if (Test-Path -Path $dotnetTestPath) + { + return $dotnetTestPath + } + + throw "Could not find dotnet executable in $dotnetInstallDir" } function Get-VersionCore([string]$name, [string]$versionFile) { @@ -288,30 +301,3 @@ function Make-BootstrapBuild([switch]$force32 = $false) { return $dir } - -Add-Type -AssemblyName 'System.Drawing' -Add-Type -AssemblyName 'System.Windows.Forms' -function Capture-Screenshot($path) { - $width = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Width - $height = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Height - - $bitmap = New-Object System.Drawing.Bitmap $width, $height - try { - $graphics = [System.Drawing.Graphics]::FromImage($bitmap) - try { - $graphics.CopyFromScreen( ` - [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.X, ` - [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Y, ` - 0, ` - 0, ` - $bitmap.Size, ` - [System.Drawing.CopyPixelOperation]::SourceCopy) - } finally { - $graphics.Dispose() - } - - $bitmap.Save($path, [System.Drawing.Imaging.ImageFormat]::Png) - } finally { - $bitmap.Dispose() - } -} diff --git a/eng/build.ps1 b/eng/build.ps1 index c0f51ce619970f3ed10c2c1975b20682659bc20f..e044e8d3dfeee1f6fc653fc9524e78f5375a769a 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -605,6 +605,11 @@ try { . (Join-Path $PSScriptRoot "build-utils.ps1") + if ($testVsi) + { + . (Join-Path $PSScriptRoot "build-utils-win.ps1") + } + Push-Location $RepoRoot if ($ci) {