From f17518be33e4b76fafc8f4b3a6096aa00ca8ceb1 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 9 Feb 2023 16:46:32 -0700 Subject: [PATCH 01/14] Update the dotnet-install.ps1 script This enables downloading newer SDK versions. --- tools/Install-DotNetSdk.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index 2bac3b9b..a71ff3fd 100644 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -234,10 +234,10 @@ if ($IncludeX86) { } if ($IsMacOS -or $IsLinux) { - $DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/781752509a890ca7520f1182e8bae71f9a53d754/src/dotnet-install.sh" + $DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/88bd34f089b8a023e3523f22c92abd0ab88e4409/src/dotnet-install.sh" $DotNetInstallScriptPath = "$DotNetInstallScriptRoot/dotnet-install.sh" } else { - $DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/781752509a890ca7520f1182e8bae71f9a53d754/src/dotnet-install.ps1" + $DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/88bd34f089b8a023e3523f22c92abd0ab88e4409/src/dotnet-install.ps1" $DotNetInstallScriptPath = "$DotNetInstallScriptRoot/dotnet-install.ps1" } From 551183c1e900d30e0e8b7623c910be160a690b4e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 9 Feb 2023 16:52:41 -0700 Subject: [PATCH 02/14] Improve error message for unsupported versions --- tools/Install-DotNetSdk.ps1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index a71ff3fd..14f4c8c4 100644 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -98,7 +98,12 @@ Function Get-InstallerExe( [string]$sku ) { # Get the latest/actual version for the specified one - $TypedVersion = [Version]$Version + $TypedVersion = $null + if (![Version]::TryParse($Version, [ref] $TypedVersion)) { + Write-Error "Unable to parse $Version into an a.b.c.d version. This version cannot be installed machine-wide." + exit 1 + } + if ($TypedVersion.Build -eq -1) { $versionInfo = -Split (Invoke-WebRequest -Uri "https://dotnetcli.blob.core.windows.net/dotnet/$sku/$Version/latest.version" -UseBasicParsing) $Version = $versionInfo[-1] From 8381192a53608e7a655dfaf4f58a6edf64f8fa76 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 9 Feb 2023 17:00:31 -0700 Subject: [PATCH 03/14] Remove references to "Core" in .NET Core --- tools/Install-DotNetSdk.ps1 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index 14f4c8c4..47ccf22e 100644 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -3,7 +3,7 @@ <# .SYNOPSIS Installs the .NET SDK specified in the global.json file at the root of this repository, - along with supporting .NET Core runtimes used for testing. + along with supporting .NET runtimes used for testing. .DESCRIPTION This MAY not require elevation, as the SDK and runtimes are installed locally to this repo location, unless `-InstallLocality machine` is specified. @@ -43,7 +43,7 @@ if (!$arch) { # Windows Powershell leaves this blank if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') { $arch = 'ARM64' } } -# Search for all .NET Core runtime versions referenced from MSBuild projects and arrange to install them. +# Search for all .NET runtime versions referenced from MSBuild projects and arrange to install them. $runtimeVersions = @() $windowsDesktopRuntimeVersions = @() Get-ChildItem "$PSScriptRoot\..\src\*.*proj","$PSScriptRoot\..\test\*.*proj","$PSScriptRoot\..\Directory.Build.props" -Recurse |% { @@ -145,9 +145,9 @@ Function Get-InstallerExe( } Function Install-DotNet($Version, $Architecture, [ValidateSet('Sdk','Runtime','WindowsDesktop')][string]$sku = 'Sdk') { - Write-Host "Downloading .NET Core $sku $Version..." + Write-Host "Downloading .NET $sku $Version..." $Installer = Get-InstallerExe -Version $Version -Architecture $Architecture -sku $sku - Write-Host "Installing .NET Core $sku $Version..." + Write-Host "Installing .NET $sku $Version..." cmd /c start /wait $Installer /install /passive /norestart if ($LASTEXITCODE -eq 3010) { Write-Verbose "Restart required" @@ -290,7 +290,7 @@ if ($IncludeX86) { $dotnetRuntimeSwitches = $switches + '-Runtime','dotnet' $runtimeVersions | Sort-Object -Unique |% { - if ($PSCmdlet.ShouldProcess(".NET Core $Arch runtime $_", "Install")) { + if ($PSCmdlet.ShouldProcess(".NET $Arch runtime $_", "Install")) { $anythingInstalled = $true Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ -Architecture $arch -InstallDir $DotNetInstallDir $dotnetRuntimeSwitches" @@ -303,7 +303,7 @@ $runtimeVersions | Sort-Object -Unique |% { } if ($IncludeX86) { - if ($PSCmdlet.ShouldProcess(".NET Core x86 runtime $_", "Install")) { + if ($PSCmdlet.ShouldProcess(".NET x86 runtime $_", "Install")) { $anythingInstalled = $true Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ -Architecture x86 -InstallDir $DotNetX86InstallDir $dotnetRuntimeSwitches" @@ -320,7 +320,7 @@ $runtimeVersions | Sort-Object -Unique |% { $windowsDesktopRuntimeSwitches = $switches + '-Runtime','windowsdesktop' $windowsDesktopRuntimeVersions | Sort-Object -Unique |% { - if ($PSCmdlet.ShouldProcess(".NET Core WindowsDesktop $arch runtime $_", "Install")) { + if ($PSCmdlet.ShouldProcess(".NET WindowsDesktop $arch runtime $_", "Install")) { $anythingInstalled = $true Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ -Architecture $arch -InstallDir $DotNetInstallDir $windowsDesktopRuntimeSwitches" @@ -333,7 +333,7 @@ $windowsDesktopRuntimeVersions | Sort-Object -Unique |% { } if ($IncludeX86) { - if ($PSCmdlet.ShouldProcess(".NET Core WindowsDesktop x86 runtime $_", "Install")) { + if ($PSCmdlet.ShouldProcess(".NET WindowsDesktop x86 runtime $_", "Install")) { $anythingInstalled = $true Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ -Architecture x86 -InstallDir $DotNetX86InstallDir $windowsDesktopRuntimeSwitches" @@ -352,5 +352,5 @@ if ($PSCmdlet.ShouldProcess("Set DOTNET environment variables to discover these } if ($anythingInstalled -and ($InstallLocality -ne 'machine') -and !$env:TF_BUILD -and !$env:GITHUB_ACTIONS) { - Write-Warning ".NET Core runtimes or SDKs were installed to a non-machine location. Perform your builds or open Visual Studio from this same environment in order for tools to discover the location of these dependencies." + Write-Warning ".NET runtimes or SDKs were installed to a non-machine location. Perform your builds or open Visual Studio from this same environment in order for tools to discover the location of these dependencies." } From d19033347c00cf09ef9201a6a4d25a19673d8de4 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 9 Feb 2023 17:07:26 -0700 Subject: [PATCH 04/14] Add -SdkOnly switch --- tools/Install-DotNetSdk.ps1 | 53 ++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index 47ccf22e..39e47eb6 100644 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -15,6 +15,8 @@ When using 'repo', environment variables are set to cause the locally installed dotnet SDK to be used. Per-repo can lead to file locking issues when dotnet.exe is left running as a build server and can be mitigated by running `dotnet build-server shutdown`. Per-machine requires elevation and will download and install all SDKs and runtimes to machine-wide locations so all applications can find it. +.PARAMETER SdkOnly + Skips installing the runtime. .PARAMETER IncludeX86 Installs a x86 SDK and runtimes in addition to the x64 ones. Only supported on Windows. Ignored on others. #> @@ -22,6 +24,7 @@ Param ( [ValidateSet('repo','user','machine')] [string]$InstallLocality='user', + [switch]$SdkOnly, [switch]$IncludeX86 ) @@ -46,34 +49,36 @@ if (!$arch) { # Windows Powershell leaves this blank # Search for all .NET runtime versions referenced from MSBuild projects and arrange to install them. $runtimeVersions = @() $windowsDesktopRuntimeVersions = @() -Get-ChildItem "$PSScriptRoot\..\src\*.*proj","$PSScriptRoot\..\test\*.*proj","$PSScriptRoot\..\Directory.Build.props" -Recurse |% { - $projXml = [xml](Get-Content -Path $_) - $pg = $projXml.Project.PropertyGroup - if ($pg) { - $targetFrameworks = @() - $tf = $pg.TargetFramework - $targetFrameworks += $tf - $tfs = $pg.TargetFrameworks - if ($tfs) { - $targetFrameworks = $tfs -Split ';' +if (!$SdkOnly) { + Get-ChildItem "$PSScriptRoot\..\src\*.*proj","$PSScriptRoot\..\test\*.*proj","$PSScriptRoot\..\Directory.Build.props" -Recurse |% { + $projXml = [xml](Get-Content -Path $_) + $pg = $projXml.Project.PropertyGroup + if ($pg) { + $targetFrameworks = @() + $tf = $pg.TargetFramework + $targetFrameworks += $tf + $tfs = $pg.TargetFrameworks + if ($tfs) { + $targetFrameworks = $tfs -Split ';' + } } - } - $targetFrameworks |? { $_ -match 'net(?:coreapp)?(\d+\.\d+)' } |% { - $v = $Matches[1] - $runtimeVersions += $v - if ($v -ge '3.0' -and -not ($IsMacOS -or $IsLinux)) { - $windowsDesktopRuntimeVersions += $v + $targetFrameworks |? { $_ -match 'net(?:coreapp)?(\d+\.\d+)' } |% { + $v = $Matches[1] + $runtimeVersions += $v + if ($v -ge '3.0' -and -not ($IsMacOS -or $IsLinux)) { + $windowsDesktopRuntimeVersions += $v + } } - } - # Add target frameworks of the form: netXX - $targetFrameworks |? { $_ -match 'net(\d+\.\d+)' } |% { - $v = $Matches[1] - $runtimeVersions += $v - if (-not ($IsMacOS -or $IsLinux)) { - $windowsDesktopRuntimeVersions += $v + # Add target frameworks of the form: netXX + $targetFrameworks |? { $_ -match 'net(\d+\.\d+)' } |% { + $v = $Matches[1] + $runtimeVersions += $v + if (-not ($IsMacOS -or $IsLinux)) { + $windowsDesktopRuntimeVersions += $v + } } - } + } } Function Get-FileFromWeb([Uri]$Uri, $OutDir) { From fb2395d9a7cc483f5f1a37a82b104fde93883b34 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 27 Feb 2023 09:46:58 -0700 Subject: [PATCH 05/14] Add dotnet CLI tools --- .config/dotnet-tools.json | 18 ++++++++++++++++++ init.ps1 | 5 +++++ 2 files changed, 23 insertions(+) create mode 100644 .config/dotnet-tools.json diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json new file mode 100644 index 00000000..2599e26a --- /dev/null +++ b/.config/dotnet-tools.json @@ -0,0 +1,18 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "powershell": { + "version": "7.3.3", + "commands": [ + "pwsh" + ] + }, + "dotnet-format": { + "version": "5.1.250801", + "commands": [ + "dotnet-format" + ] + } + } +} \ No newline at end of file diff --git a/init.ps1 b/init.ps1 index ad3b4145..5bace1e6 100755 --- a/init.ps1 +++ b/init.ps1 @@ -91,6 +91,11 @@ try { if ($lastexitcode -ne 0) { throw "Failure while restoring packages." } + + dotnet tool restore @RestoreArguments + if ($lastexitcode -ne 0) { + throw "Failure while restoring dotnet CLI tools." + } } & "$PSScriptRoot/tools/Set-EnvVars.ps1" -Variables $EnvVars -PrependPath $PrependPath | Out-Null From 3eb1436057301cf295b4a895fa2e2d5fe87339c1 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 10 Mar 2023 08:32:03 -0700 Subject: [PATCH 06/14] Bump MicroBuildVersion to 2.0.115 --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index a3769e31..62d2ccc0 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -4,7 +4,7 @@ true true - 2.0.113 + 2.0.115 From 5132c2206f248cc3ff0e65c0a087a74b6d734d77 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 11 Mar 2023 16:30:55 -0700 Subject: [PATCH 07/14] Add ASP.NET Core runtime installation support --- tools/Install-DotNetSdk.ps1 | 59 ++++++++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 4 deletions(-) diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index 39e47eb6..6bff5c27 100644 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -19,13 +19,16 @@ Skips installing the runtime. .PARAMETER IncludeX86 Installs a x86 SDK and runtimes in addition to the x64 ones. Only supported on Windows. Ignored on others. +.PARAMETER IncludeAspNetCore + Installs the ASP.NET Core runtime along with the .NET runtime. #> [CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact='Medium')] Param ( [ValidateSet('repo','user','machine')] [string]$InstallLocality='user', [switch]$SdkOnly, - [switch]$IncludeX86 + [switch]$IncludeX86, + [switch]$IncludeAspNetCore ) $DotNetInstallScriptRoot = "$PSScriptRoot/../obj/tools" @@ -49,6 +52,7 @@ if (!$arch) { # Windows Powershell leaves this blank # Search for all .NET runtime versions referenced from MSBuild projects and arrange to install them. $runtimeVersions = @() $windowsDesktopRuntimeVersions = @() +$aspnetRuntimeVersions = @() if (!$SdkOnly) { Get-ChildItem "$PSScriptRoot\..\src\*.*proj","$PSScriptRoot\..\test\*.*proj","$PSScriptRoot\..\Directory.Build.props" -Recurse |% { $projXml = [xml](Get-Content -Path $_) @@ -65,6 +69,7 @@ if (!$SdkOnly) { $targetFrameworks |? { $_ -match 'net(?:coreapp)?(\d+\.\d+)' } |% { $v = $Matches[1] $runtimeVersions += $v + $aspnetRuntimeVersions += $v if ($v -ge '3.0' -and -not ($IsMacOS -or $IsLinux)) { $windowsDesktopRuntimeVersions += $v } @@ -74,6 +79,7 @@ if (!$SdkOnly) { $targetFrameworks |? { $_ -match 'net(\d+\.\d+)' } |% { $v = $Matches[1] $runtimeVersions += $v + $aspnetRuntimeVersions += $v if (-not ($IsMacOS -or $IsLinux)) { $windowsDesktopRuntimeVersions += $v } @@ -81,6 +87,10 @@ if (!$SdkOnly) { } } +if (!$IncludeAspNetCore) { + $aspnetRuntimeVersions = @() +} + Function Get-FileFromWeb([Uri]$Uri, $OutDir) { $OutFile = Join-Path $OutDir $Uri.Segments[-1] if (!(Test-Path $OutFile)) { @@ -149,7 +159,7 @@ Function Get-InstallerExe( } } -Function Install-DotNet($Version, $Architecture, [ValidateSet('Sdk','Runtime','WindowsDesktop')][string]$sku = 'Sdk') { +Function Install-DotNet($Version, $Architecture, [ValidateSet('Sdk','Runtime','WindowsDesktop','AspNetCore')][string]$sku = 'Sdk') { Write-Host "Downloading .NET $sku $Version..." $Installer = Get-InstallerExe -Version $Version -Architecture $Architecture -sku $sku Write-Host "Installing .NET $sku $Version..." @@ -206,6 +216,17 @@ if ($InstallLocality -eq 'machine') { } } + $aspnetRuntimeVersions | Sort-Object | Get-Unique |% { + if ($PSCmdlet.ShouldProcess("ASP.NET Core $_", "Install")) { + Install-DotNet -Version $_ -sku AspNetCore -Architecture $arch + $restartRequired = $restartRequired -or ($LASTEXITCODE -eq 3010) + + if ($IncludeX86) { + Install-DotNet -Version $_ -sku AspNetCore -Architecture x86 + $restartRequired = $restartRequired -or ($LASTEXITCODE -eq 3010) + } + } + } if ($restartRequired) { Write-Host -ForegroundColor Yellow "System restart required" Exit 3010 @@ -244,10 +265,10 @@ if ($IncludeX86) { } if ($IsMacOS -or $IsLinux) { - $DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/88bd34f089b8a023e3523f22c92abd0ab88e4409/src/dotnet-install.sh" + $DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/0b09de9bc136cacb5f849a6957ebd4062173c148/src/dotnet-install.sh" $DotNetInstallScriptPath = "$DotNetInstallScriptRoot/dotnet-install.sh" } else { - $DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/88bd34f089b8a023e3523f22c92abd0ab88e4409/src/dotnet-install.ps1" + $DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/0b09de9bc136cacb5f849a6957ebd4062173c148/src/dotnet-install.ps1" $DotNetInstallScriptPath = "$DotNetInstallScriptRoot/dotnet-install.ps1" } @@ -352,6 +373,36 @@ $windowsDesktopRuntimeVersions | Sort-Object -Unique |% { } } +$aspnetRuntimeSwitches = $switches + '-Runtime','aspnetcore' + +$aspnetRuntimeVersions | Sort-Object -Unique |% { + if ($PSCmdlet.ShouldProcess(".NET ASP.NET Core $arch runtime $_", "Install")) { + $anythingInstalled = $true + Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ -Architecture $arch -InstallDir $DotNetInstallDir $aspnetRuntimeSwitches" + + if ($LASTEXITCODE -ne 0) { + Write-Error ".NET SDK installation failure: $LASTEXITCODE" + exit $LASTEXITCODE + } + } else { + Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ -Architecture $arch -InstallDir $DotNetInstallDir $aspnetRuntimeSwitches -DryRun" + } + + if ($IncludeX86) { + if ($PSCmdlet.ShouldProcess(".NET ASP.NET Core x86 runtime $_", "Install")) { + $anythingInstalled = $true + Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ -Architecture x86 -InstallDir $DotNetX86InstallDir $aspnetRuntimeSwitches" + + if ($LASTEXITCODE -ne 0) { + Write-Error ".NET SDK installation failure: $LASTEXITCODE" + exit $LASTEXITCODE + } + } else { + Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ -Architecture x86 -InstallDir $DotNetX86InstallDir $aspnetRuntimeSwitches -DryRun" + } + } +} + if ($PSCmdlet.ShouldProcess("Set DOTNET environment variables to discover these installed runtimes?")) { & "$PSScriptRoot/Set-EnvVars.ps1" -Variables $envVars -PrependPath $DotNetInstallDir | Out-Null } From a921f8dcaf0ba4f93dfec660f503d17ce19d58ea Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 11 Mar 2023 16:40:50 -0700 Subject: [PATCH 08/14] Drop Microsoft.CodeCoverage reference It's brought in via Microsoft.NET.Test.Sdk anyway. --- Directory.Packages.props | 1 - test/Library.Tests/Library.Tests.csproj | 1 - 2 files changed, 2 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index b792f3f6..b523e5c6 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -5,7 +5,6 @@ true - diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index d557e4c7..3a6cc044 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -10,7 +10,6 @@ - From ea48c8eaa182f224ca3ed1a38f2a8034d15dacce Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 13 Mar 2023 15:27:56 -0600 Subject: [PATCH 09/14] Updated SDK installer script to be able to find 7.0.200 --- tools/Install-DotNetSdk.ps1 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index 6bff5c27..10af5041 100644 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -137,6 +137,14 @@ Function Get-InstallerExe( if ($release.$sku.version -eq $Version) { $filesElement = $release.$sku.files } + if (!$filesElement -and ($sku -eq 'sdk') -and $release.sdks) { + foreach ($sdk in $release.sdks) { + if ($sdk.version -eq $Version) { + $filesElement = $sdk.files + break + } + } + } if ($filesElement) { foreach ($file in $filesElement) { @@ -155,7 +163,7 @@ Function Get-InstallerExe( if ($url) { Get-FileFromWeb -Uri $url -OutDir $DotNetInstallScriptRoot } else { - Write-Error "Unable to find release of $sku v$Version" + throw "Unable to find release of $sku v$Version" } } From 2987b4457b0242e91913e9d9f4b43b5db079fd50 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 13 Mar 2023 15:31:46 -0600 Subject: [PATCH 10/14] Bump SDK version to 7.0.201 --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index cc08211e..cf9eefa6 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.101", + "version": "7.0.201", "rollForward": "patch", "allowPrerelease": false } From b47983de022de491725e8e9d4a27bb90166b9947 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 16 Mar 2023 08:28:44 -0600 Subject: [PATCH 11/14] Update MicroBuild signing plugin version --- azure-pipelines/microbuild.before.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/microbuild.before.yml b/azure-pipelines/microbuild.before.yml index d048af4b..c933df23 100644 --- a/azure-pipelines/microbuild.before.yml +++ b/azure-pipelines/microbuild.before.yml @@ -9,7 +9,7 @@ steps: outputformat: text condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) -- task: MicroBuildSigningPlugin@3 +- task: MicroBuildSigningPlugin@4 inputs: signType: $(SignType) zipSources: false From 99df8185b1a6aa6abb1cc98aa7f4c0245f8d9012 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 28 Mar 2023 15:53:46 -0600 Subject: [PATCH 12/14] Move `dotnet-coverage` to repo-level tool --- .config/dotnet-tools.json | 8 ++++- azure-pipelines/Merge-CodeCoverage.ps1 | 46 +++++++++++++------------- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 2599e26a..610b59c9 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -13,6 +13,12 @@ "commands": [ "dotnet-format" ] + }, + "dotnet-coverage": { + "version": "17.6.11", + "commands": [ + "dotnet-coverage" + ] } } -} \ No newline at end of file +} diff --git a/azure-pipelines/Merge-CodeCoverage.ps1 b/azure-pipelines/Merge-CodeCoverage.ps1 index 02ff12b0..5ecabbc9 100644 --- a/azure-pipelines/Merge-CodeCoverage.ps1 +++ b/azure-pipelines/Merge-CodeCoverage.ps1 @@ -20,32 +20,32 @@ Param( ) $RepoRoot = [string](Resolve-Path $PSScriptRoot/..) +Push-Location $RepoRoot +try { + Write-Verbose "Searching $Path for *.cobertura.xml files" + $reports = Get-ChildItem -Recurse $Path -Filter *.cobertura.xml -if (!(Test-Path $RepoRoot/obj/dotnet-coverage*)) { - dotnet tool install --tool-path $RepoRoot/obj dotnet-coverage --version 17.4.3 --configfile $PSScriptRoot/justnugetorg.nuget.config -} + if ($reports) { + $reports |% { $_.FullName } |% { + # In addition to replacing {reporoot}, we also normalize on one kind of slash so that the report aggregates data for a file whether data was collected on Windows or not. + $xml = [xml](Get-Content -Path $_) + $xml.coverage.packages.package.classes.class |? { $_.filename} |% { + $_.filename = $_.filename.Replace('{reporoot}', $RepoRoot).Replace([IO.Path]::AltDirectorySeparatorChar, [IO.Path]::DirectorySeparatorChar) + } -Write-Verbose "Searching $Path for *.cobertura.xml files" -$reports = Get-ChildItem -Recurse $Path -Filter *.cobertura.xml - -if ($reports) { - $reports |% { $_.FullName } |% { - # In addition to replacing {reporoot}, we also normalize on one kind of slash so that the report aggregates data for a file whether data was collected on Windows or not. - $xml = [xml](Get-Content -Path $_) - $xml.coverage.packages.package.classes.class |? { $_.filename} |% { - $_.filename = $_.filename.Replace('{reporoot}', $RepoRoot).Replace([IO.Path]::AltDirectorySeparatorChar, [IO.Path]::DirectorySeparatorChar) + $xml.Save($_) } - $xml.Save($_) + $Inputs = $reports |% { Resolve-Path -relative $_.FullName } + + if ((Split-Path $OutputFile) -and -not (Test-Path (Split-Path $OutputFile))) { + New-Item -Type Directory -Path (Split-Path $OutputFile) | Out-Null + } + + & dotnet tool run dotnet-coverage merge $Inputs -o $OutputFile -f cobertura + } else { + Write-Error "No reports found to merge." } - - $Inputs = $reports |% { Resolve-Path -relative $_.FullName } - - if ((Split-Path $OutputFile) -and -not (Test-Path (Split-Path $OutputFile))) { - New-Item -Type Directory -Path (Split-Path $OutputFile) | Out-Null - } - - & "$RepoRoot/obj/dotnet-coverage" merge $Inputs -o $OutputFile -f cobertura -} else { - Write-Error "No reports found to merge." +} finally { + Pop-Location } From 14699417fbde409397e7efec56c1b33268ed3634 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 28 Mar 2023 15:58:33 -0600 Subject: [PATCH 13/14] Move `nbgv` into dotnet-tools.json --- .config/dotnet-tools.json | 6 ++++++ azure-pipelines/Get-nbgv.ps1 | 24 ------------------------ azure-pipelines/build.yml | 2 +- 3 files changed, 7 insertions(+), 25 deletions(-) delete mode 100644 azure-pipelines/Get-nbgv.ps1 diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 610b59c9..5d3dae87 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -19,6 +19,12 @@ "commands": [ "dotnet-coverage" ] + }, + "nbgv": { + "version": "3.5.119", + "commands": [ + "nbgv" + ] } } } diff --git a/azure-pipelines/Get-nbgv.ps1 b/azure-pipelines/Get-nbgv.ps1 deleted file mode 100644 index a5be2cf7..00000000 --- a/azure-pipelines/Get-nbgv.ps1 +++ /dev/null @@ -1,24 +0,0 @@ -<# -.SYNOPSIS - Gets the path to the nbgv CLI tool, installing it if necessary. -#> -Param( -) - -$existingTool = Get-Command "nbgv" -ErrorAction SilentlyContinue -if ($existingTool) { - return $existingTool.Path -} - -$toolInstallDir = & "$PSScriptRoot/Get-TempToolsPath.ps1" - -$toolPath = "$toolInstallDir/nbgv" -if (!(Test-Path $toolInstallDir)) { New-Item -Path $toolInstallDir -ItemType Directory | Out-Null } - -if (!(Get-Command $toolPath -ErrorAction SilentlyContinue)) { - Write-Host "Installing nbgv to $toolInstallDir" - dotnet tool install --tool-path "$toolInstallDir" nbgv --configfile "$PSScriptRoot/justnugetorg.nuget.config" | Out-Null -} - -# Normalize the path on the way out. -return (Get-Command $toolPath).Path diff --git a/azure-pipelines/build.yml b/azure-pipelines/build.yml index c8687859..2e2f426e 100644 --- a/azure-pipelines/build.yml +++ b/azure-pipelines/build.yml @@ -17,7 +17,7 @@ jobs: clean: true - template: install-dependencies.yml - - powershell: '& (./azure-pipelines/Get-nbgv.ps1) cloud -c' + - script: dotnet tool run nbgv cloud -c displayName: ⚙ Set build number - template: dotnet.yml From 3f1e85823fac9136c058aaf48f4b8febed1d0843 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 28 Mar 2023 16:34:38 -0600 Subject: [PATCH 14/14] Install tools except when `-NoToolRestore` is specified --- init.ps1 | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/init.ps1 b/init.ps1 index 5bace1e6..6211304f 100755 --- a/init.ps1 +++ b/init.ps1 @@ -28,6 +28,8 @@ No effect if -NoPrerequisites is specified. .PARAMETER NoRestore Skips the package restore step. +.PARAMETER NoToolRestore + Skips the dotnet tool restore step. .PARAMETER AccessToken An optional access token for authenticating to Azure Artifacts authenticated feeds. .PARAMETER Interactive @@ -46,6 +48,8 @@ Param ( [Parameter()] [switch]$NoRestore, [Parameter()] + [switch]$NoToolRestore, + [Parameter()] [string]$AccessToken, [Parameter()] [switch]$Interactive @@ -91,11 +95,13 @@ try { if ($lastexitcode -ne 0) { throw "Failure while restoring packages." } + } - dotnet tool restore @RestoreArguments - if ($lastexitcode -ne 0) { - throw "Failure while restoring dotnet CLI tools." - } + if (!$NoToolRestore -and $PSCmdlet.ShouldProcess("dotnet tool", "restore")) { + dotnet tool restore @RestoreArguments + if ($lastexitcode -ne 0) { + throw "Failure while restoring dotnet CLI tools." + } } & "$PSScriptRoot/tools/Set-EnvVars.ps1" -Variables $EnvVars -PrependPath $PrependPath | Out-Null