未验证 提交 3f851026 编写于 作者: F Fred Silberberg 提交者: GitHub

Merge pull request #42327 from 333fred/generate-compiler-code

Support executing generate-compiler-code.ps1 on Linux using Powershell Core
# 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()
}
}
......@@ -159,7 +159,18 @@ 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 +299,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()
}
}
......@@ -605,6 +605,10 @@ try {
. (Join-Path $PSScriptRoot "build-utils.ps1")
if ($testVsi) {
. (Join-Path $PSScriptRoot "build-utils-win.ps1")
}
Push-Location $RepoRoot
if ($ci) {
......
......@@ -204,7 +204,7 @@ private static void WriteToFile(Tree tree, Action<TextWriter, Tree> writeAction,
do
{
length = text.Length;
text = text.Replace("{\r\n\r\n", "{\r\n");
text = text.Replace($"{{{Environment.NewLine}{Environment.NewLine}", $"{{{Environment.NewLine}");
} while (text.Length != length);
try
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册