diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 536052ffc..9f9de05c4 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -17,7 +17,7 @@ "rollForward": false }, "nbgv": { - "version": "3.8.118", + "version": "3.9.50", "commands": [ "nbgv" ], diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index f98875898..64f23a9eb 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,5 +1,5 @@ # Refer to https://hub.docker.com/_/microsoft-dotnet-sdk for available versions -FROM mcr.microsoft.com/dotnet/sdk:9.0.306-noble@sha256:d88e637d15248531967111fba05c6725ad45ea1dace3d35d8cfe2c4d4094e25d +FROM mcr.microsoft.com/dotnet/sdk:10.0.101@sha256:d1823fecac3689a2eb959e02ee3bfe1c2142392808240039097ad70644566190 # Installing mono makes `dotnet test` work without errors even for net472. # But installing it takes a long time, so it's excluded by default. diff --git a/.github/renovate.json b/.github/renovate.json index b165b4a06..738cf49c1 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -1,6 +1,6 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": ["config:best-practices"], + "extends": ["config:best-practices","helpers:pinGitHubActionDigestsToSemver"], "labels": ["dependencies"], "packageRules": [ { @@ -11,6 +11,10 @@ "matchPackageNames": ["xunit*"], "groupName": "xunit" }, + { + "matchPackageNames": ["Microsoft.Testing.Extensions.*"], + "groupName": "Microsoft Testing Platform" + }, { "matchDatasources": ["dotnet-version", "docker"], "matchDepNames": ["dotnet-sdk", "mcr.microsoft.com/dotnet/sdk"], diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c5f43fcf6..8bd3cac7e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,6 @@ on: env: DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true BUILDCONFIGURATION: Release - # codecov_token: 4dc9e7e2-6b01-4932-a180-847b52b43d35 # Get a new one from https://codecov.io/ NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages/ # dotnetfoundation code signing @@ -27,11 +26,11 @@ jobs: fail-fast: false matrix: os: - - ubuntu-22.04 - - windows-2022 + - ubuntu-24.04 + - windows-2025 steps: - - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 with: fetch-depth: 0 # avoid shallow clone so nbgv can do its work. submodules: true @@ -114,11 +113,13 @@ jobs: if: success() && runner.os == 'Windows' && github.event_name != 'pull_request' continue-on-error: true - name: ๐Ÿ“ข Publish code coverage results to codecov.io - run: ./tools/publish-CodeCov.ps1 -CodeCovToken "${{ env.codecov_token }}" -PathToCodeCoverage "${{ runner.temp }}/_artifacts/coverageResults" -Name "${{ runner.os }} Coverage Results" -Flags "${{ runner.os }}" + run: | + if ('${{ secrets.CODECOV_TOKEN }}') { + ./tools/publish-CodeCov.ps1 -CodeCovToken '${{ secrets.CODECOV_TOKEN }}' -PathToCodeCoverage "${{ runner.temp }}/_artifacts/coverageResults" -Name "${{ runner.os }} Coverage Results" -Flags "${{ runner.os }}" + } shell: pwsh timeout-minutes: 3 continue-on-error: true - if: env.codecov_token != '' functional_testing: name: ๐Ÿงช Functional testing @@ -300,8 +301,8 @@ jobs: name: ๐Ÿ“ƒ Docs runs-on: ubuntu-latest steps: - - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - name: ๐Ÿ”— Markup Link Checker (mlc) - uses: becheran/mlc@18a06b3aa2901ca197de59c8b0b1f54fdba6b3fa # v1.0.0 + uses: becheran/mlc@6fa3bddc1a921454b7840df30b343f6415bc8d35 # v1.1.0 with: args: --do-not-warn-for-redirect-to https://learn.microsoft.com*,https://dotnet.microsoft.com/*,https://dev.azure.com/*,https://app.codecov.io/* -p docfx -i https://www.npmjs.com/package/*,https://get.dot.net/ diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index eb69d92e8..ebd538812 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -26,7 +26,7 @@ jobs: # You can define any steps you want, and they will run before the agent starts. # If you do not check out your code, Copilot will do this for you. steps: - - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 with: fetch-depth: 0 # avoid shallow clone so nbgv can do its work. - name: โš™ Install prerequisites diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index a7155c4cf..b1ba5680c 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -24,7 +24,7 @@ jobs: url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest steps: - - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 with: fetch-depth: 0 # avoid shallow clone so nbgv can do its work. - name: โš™ Install prerequisites @@ -40,4 +40,4 @@ jobs: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4 + uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 diff --git a/.github/workflows/libtemplate-update.yml b/.github/workflows/libtemplate-update.yml index f5cf8666f..0b111a609 100644 --- a/.github/workflows/libtemplate-update.yml +++ b/.github/workflows/libtemplate-update.yml @@ -17,7 +17,7 @@ jobs: contents: write pull-requests: write steps: - - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 with: fetch-depth: 0 # avoid shallow clone so nbgv can do its work. diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5260252b7..4fee97a26 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -98,20 +98,8 @@ jobs: --azure-credential-type azure-cli shell: pwsh - - name: ๐Ÿ’ฝ Upload artifacts to release - shell: pwsh - if: ${{ github.event_name == 'release' && github.event.release.assets_url != '' }} - continue-on-error: true # until we get this to work, be willing to skip it - env: - GH_TOKEN: ${{ github.token }} - run: | - Get-ChildItem '${{ runner.temp }}/deployables' -File -Recurse |% { - Write-Host "Uploading $($_.Name) to release..." - gh release -R ${{ github.repository }} upload "${{ github.ref_name }}" $_.FullName - } - - name: ๐Ÿชช Authorize NuGet package push - uses: NuGet/login@d22cc5f58ff5b88bf9bd452535b4335137e24544 # v1 + uses: NuGet/login@d22cc5f58ff5b88bf9bd452535b4335137e24544 # v1.1.0 id: nuget-login with: user: ${{ secrets.NUGET_USER }} @@ -127,3 +115,15 @@ jobs: npm publish $_ --registry=https://registry.npmjs.org/ } if: ${{ env.NPM_API_KEY_DEFINED == 'true' }} + + - name: ๐Ÿ’ฝ Upload artifacts to release + shell: pwsh + if: ${{ github.event_name == 'release' && github.event.release.assets_url != '' }} + continue-on-error: true # until we get this to work, be willing to skip it + env: + GH_TOKEN: ${{ github.token }} + run: | + Get-ChildItem '${{ runner.temp }}/deployables' -File -Recurse |% { + Write-Host "Uploading $($_.Name) to release..." + gh release -R ${{ github.repository }} upload "${{ github.ref_name }}" $_.FullName + } diff --git a/Directory.Build.props b/Directory.Build.props index 17b09b906..17b08b67d 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -13,6 +13,7 @@ true true true + true true @@ -41,7 +42,7 @@ - 13 + 14 16.9 diff --git a/Directory.Packages.props b/Directory.Packages.props index ce7e42a07..9c770d3fd 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -4,9 +4,9 @@ true true + 2.0.2 0.15.5 16.11.6 - 17.14.28 2.0.323 @@ -38,13 +38,14 @@ - - + - - - + + + + + diff --git a/global.json b/global.json index cfaecd0dd..a0ec2d8d9 100644 --- a/global.json +++ b/global.json @@ -1,7 +1,10 @@ { "sdk": { - "version": "9.0.306", + "version": "10.0.101", "rollForward": "patch", "allowPrerelease": false + }, + "test": { + "runner": "Microsoft.Testing.Platform" } } diff --git a/test/Cake.GitVersioning.Tests/Cake.GitVersioning.Tests.csproj b/test/Cake.GitVersioning.Tests/Cake.GitVersioning.Tests.csproj index c27fb8907..36451c617 100644 --- a/test/Cake.GitVersioning.Tests/Cake.GitVersioning.Tests.csproj +++ b/test/Cake.GitVersioning.Tests/Cake.GitVersioning.Tests.csproj @@ -2,8 +2,8 @@ net8.0 + exe false - true false true true @@ -15,10 +15,8 @@ - - - + diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 6c7aa71dc..2b5b542d6 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -5,6 +5,7 @@ false true + true diff --git a/test/Directory.Build.targets b/test/Directory.Build.targets index 9f32cd061..3758bb8c9 100644 --- a/test/Directory.Build.targets +++ b/test/Directory.Build.targets @@ -1,5 +1,11 @@ + + + + + + diff --git a/test/Directory.Packages.targets b/test/Directory.Packages.targets new file mode 100644 index 000000000..2f3b4d086 --- /dev/null +++ b/test/Directory.Packages.targets @@ -0,0 +1,8 @@ + + + + + + 17.14.28 + + diff --git a/test/Nerdbank.GitVersioning.Benchmarks/Nerdbank.GitVersioning.Benchmarks.csproj b/test/Nerdbank.GitVersioning.Benchmarks/Nerdbank.GitVersioning.Benchmarks.csproj index 0dc719f4a..f57b609cd 100644 --- a/test/Nerdbank.GitVersioning.Benchmarks/Nerdbank.GitVersioning.Benchmarks.csproj +++ b/test/Nerdbank.GitVersioning.Benchmarks/Nerdbank.GitVersioning.Benchmarks.csproj @@ -7,6 +7,7 @@ true AnyCPU false + false diff --git a/test/Nerdbank.GitVersioning.Tests/AssemblyInfoTest.cs b/test/Nerdbank.GitVersioning.Tests/AssemblyInfoTest.cs index 73d89d8c1..f124ee930 100644 --- a/test/Nerdbank.GitVersioning.Tests/AssemblyInfoTest.cs +++ b/test/Nerdbank.GitVersioning.Tests/AssemblyInfoTest.cs @@ -13,7 +13,7 @@ public class AssemblyInfoTest : IClassFixture // The MSBuildFixture throws PlatformNotSupportedException when run on mono. { - [SkippableTheory(typeof(PlatformNotSupportedException))] + [Theory(SkipExceptions = [typeof(PlatformNotSupportedException)])] [InlineData(false)] [InlineData(true)] [InlineData(null)] @@ -90,7 +90,7 @@ type internal ThisAssembly() = Assert.Equal(expected, built); } - [SkippableTheory(typeof(PlatformNotSupportedException))] + [Theory(SkipExceptions = [typeof(PlatformNotSupportedException)])] [InlineData(null, "MyRootNamespace")] [InlineData("", "MyRootNamespace")] [InlineData("MyCustomNamespace", null)] @@ -150,7 +150,7 @@ type internal ThisAssembly() = Assert.Equal(expected, built); } - [SkippableTheory(typeof(PlatformNotSupportedException))] + [Theory(SkipExceptions = [typeof(PlatformNotSupportedException)])] [InlineData(false)] [InlineData(true)] [InlineData(null)] @@ -226,7 +226,7 @@ internal static partial class ThisAssembly {{ Assert.Equal(expected, built); } - [SkippableTheory(typeof(PlatformNotSupportedException))] + [Theory(SkipExceptions = [typeof(PlatformNotSupportedException)])] [InlineData(null, "MyRootNamespace")] [InlineData("", "MyRootNamespace")] [InlineData("MyCustomNamespace", null)] @@ -284,7 +284,7 @@ internal static partial class ThisAssembly {{ Assert.Equal(expected, built); } - [SkippableTheory(typeof(PlatformNotSupportedException))] + [Theory(SkipExceptions = [typeof(PlatformNotSupportedException)])] [InlineData(false)] [InlineData(true)] [InlineData(null)] @@ -340,7 +340,7 @@ End Class Assert.Equal(expected, built); } - [SkippableTheory(typeof(PlatformNotSupportedException))] + [Theory(SkipExceptions = [typeof(PlatformNotSupportedException)])] [InlineData(null, "MyRootNamespace")] [InlineData("", "MyRootNamespace")] [InlineData("MyCustomNamespace", null)] diff --git a/test/Nerdbank.GitVersioning.Tests/BuildIntegrationTests.cs b/test/Nerdbank.GitVersioning.Tests/BuildIntegrationTests.cs index a8fef20a1..0a204817d 100644 --- a/test/Nerdbank.GitVersioning.Tests/BuildIntegrationTests.cs +++ b/test/Nerdbank.GitVersioning.Tests/BuildIntegrationTests.cs @@ -191,8 +191,8 @@ public async Task AssemblyInfo_HasKeyData(string keyFile, bool delaySigned) result.BuildResult.ProjectStateAfterBuild.GetPropertyValue("VersionSourceFile")))); this.Logger.WriteLine(versionCsContent); - SyntaxTree sourceFile = CSharpSyntaxTree.ParseText(versionCsContent); - SyntaxNode syntaxTree = await sourceFile.GetRootAsync(); + SyntaxTree sourceFile = CSharpSyntaxTree.ParseText(versionCsContent, cancellationToken: TestContext.Current.CancellationToken); + SyntaxNode syntaxTree = await sourceFile.GetRootAsync(TestContext.Current.CancellationToken); IEnumerable fields = syntaxTree.DescendantNodes().OfType(); var publicKeyField = (LiteralExpressionSyntax)fields.SingleOrDefault(f => f.Identifier.ValueText == "PublicKey")?.Initializer.Value; diff --git a/test/Nerdbank.GitVersioning.Tests/GitContextTests.cs b/test/Nerdbank.GitVersioning.Tests/GitContextTests.cs index 319e6b32d..935f49ba3 100644 --- a/test/Nerdbank.GitVersioning.Tests/GitContextTests.cs +++ b/test/Nerdbank.GitVersioning.Tests/GitContextTests.cs @@ -93,14 +93,14 @@ public void SelectCommitByPartialId(bool fromPack, bool oddLength) Assert.Equal(this.LibGit2Repository.Head.Tip.Sha, this.Context.GitCommitId); } - [SkippableTheory] + [Theory] [InlineData(4)] [InlineData(7)] [InlineData(8)] [InlineData(11)] public void GetShortUniqueCommitId(int length) { - Skip.If(length < 7 && this.Context is Nerdbank.GitVersioning.LibGit2.LibGit2Context, "LibGit2Sharp never returns commit IDs with fewer than 7 characters."); + Assert.SkipWhen(length < 7 && this.Context is Nerdbank.GitVersioning.LibGit2.LibGit2Context, "LibGit2Sharp never returns commit IDs with fewer than 7 characters."); Assert.Equal(this.Context.GitCommitId.Substring(0, length), this.Context.GetShortUniqueCommitId(length)); } diff --git a/test/Nerdbank.GitVersioning.Tests/LibGit2GitExtensionsTests.cs b/test/Nerdbank.GitVersioning.Tests/LibGit2GitExtensionsTests.cs index f393a7dd9..17430d2e8 100644 --- a/test/Nerdbank.GitVersioning.Tests/LibGit2GitExtensionsTests.cs +++ b/test/Nerdbank.GitVersioning.Tests/LibGit2GitExtensionsTests.cs @@ -467,7 +467,7 @@ public void GetIdAsVersion_MigrationFromVersionTxtToJson() public void TestBiggerRepo() { string testBiggerRepoPath = @"D:\git\Nerdbank.GitVersioning"; - Skip.If(!Directory.Exists(testBiggerRepoPath), $"{testBiggerRepoPath} does not exist."); + Assert.SkipWhen(!Directory.Exists(testBiggerRepoPath), $"{testBiggerRepoPath} does not exist."); using var largeRepo = new Repository(testBiggerRepoPath); foreach (Commit commit in largeRepo.Head.Commits) diff --git a/test/Nerdbank.GitVersioning.Tests/ManagedGit/GitObjectIdTests.cs b/test/Nerdbank.GitVersioning.Tests/ManagedGit/GitObjectIdTests.cs index ea8fb0fa1..1447b715c 100644 --- a/test/Nerdbank.GitVersioning.Tests/ManagedGit/GitObjectIdTests.cs +++ b/test/Nerdbank.GitVersioning.Tests/ManagedGit/GitObjectIdTests.cs @@ -112,7 +112,7 @@ public void CopyToUtf16StringTest() // Common use case: create the path to the object in the Git object store, // e.g. git/objects/[byte 0]/[bytes 1 - 19] byte[] valueAsBytes = Encoding.Unicode.GetBytes("git/objects/00/01020304050607080910111213141516171819"); - Span valueAsChars = MemoryMarshal.Cast(valueAsBytes); + Span valueAsChars = MemoryMarshal.Cast((Span)valueAsBytes); var objectId = GitObjectId.ParseHex(this.shaAsHexAsciiByteArray); objectId.CopyAsHex(0, 1, valueAsChars.Slice(12, 1 * 2)); diff --git a/test/Nerdbank.GitVersioning.Tests/Nerdbank.GitVersioning.Tests.csproj b/test/Nerdbank.GitVersioning.Tests/Nerdbank.GitVersioning.Tests.csproj index 8a1fb5a1a..bd9cf02c1 100644 --- a/test/Nerdbank.GitVersioning.Tests/Nerdbank.GitVersioning.Tests.csproj +++ b/test/Nerdbank.GitVersioning.Tests/Nerdbank.GitVersioning.Tests.csproj @@ -2,12 +2,12 @@ net9.0 $(TargetFrameworks);net472 + exe true true full false false - true @@ -38,14 +38,11 @@ - - - - + diff --git a/test/Nerdbank.GitVersioning.Tests/Usings.cs b/test/Nerdbank.GitVersioning.Tests/Usings.cs index 552100893..9de03448c 100644 --- a/test/Nerdbank.GitVersioning.Tests/Usings.cs +++ b/test/Nerdbank.GitVersioning.Tests/Usings.cs @@ -1,4 +1,4 @@ // Copyright (c) .NET Foundation and Contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -global using Xunit.Abstractions; +global using Xunit; diff --git a/test/Nerdbank.GitVersioning.Tests/WindowsTheoryAttribute.cs b/test/Nerdbank.GitVersioning.Tests/WindowsTheoryAttribute.cs index 1ad641bda..485304a5f 100644 --- a/test/Nerdbank.GitVersioning.Tests/WindowsTheoryAttribute.cs +++ b/test/Nerdbank.GitVersioning.Tests/WindowsTheoryAttribute.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Xunit; @@ -14,4 +15,13 @@ public WindowsTheoryAttribute() this.Skip = "This test runs on Windows only"; } } + + public WindowsTheoryAttribute([CallerFilePath] string sourceFilePath = null, [CallerLineNumber] int sourceLineNumber = -1) + : base(sourceFilePath, sourceLineNumber) + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + this.Skip = "This test runs on Windows only"; + } + } } diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index 402b4307c..590581e26 100755 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -125,14 +125,14 @@ Function Get-InstallerExe( } if ($TypedVersion.Build -eq -1) { - $versionInfo = -Split (Invoke-WebRequest -Uri "https://dotnetcli.blob.core.windows.net/dotnet/$sku/$Version/latest.version" -UseBasicParsing) + $versionInfo = -Split (Invoke-WebRequest -Uri "https://builds.dotnet.microsoft.com/dotnet/$sku/$Version/latest.version" -UseBasicParsing) $Version = $versionInfo[-1] } $majorMinor = "$($TypedVersion.Major).$($TypedVersion.Minor)" $ReleasesFile = Join-Path $DotNetInstallScriptRoot "$majorMinor\releases.json" if (!(Test-Path $ReleasesFile)) { - Get-FileFromWeb -Uri "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/$majorMinor/releases.json" -OutDir (Split-Path $ReleasesFile) | Out-Null + Get-FileFromWeb -Uri "https://builds.dotnet.microsoft.com/dotnet/release-metadata/$majorMinor/releases.json" -OutDir (Split-Path $ReleasesFile) | Out-Null } $releases = Get-Content $ReleasesFile | ConvertFrom-Json @@ -197,7 +197,7 @@ if ($InstallLocality -eq 'machine') { $restartRequired = $false $sdks |% { if ($_.Version) { $version = $_.Version } else { $version = $_.Channel } - if ($PSCmdlet.ShouldProcess(".NET SDK $_", "Install")) { + if ($PSCmdlet.ShouldProcess(".NET SDK $version ($arch)", "Install")) { Install-DotNet -Version $version -Architecture $arch $restartRequired = $restartRequired -or ($LASTEXITCODE -eq 3010) @@ -281,10 +281,10 @@ if ($IncludeX86) { } if ($IsMacOS -or $IsLinux) { - $DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/0b09de9bc136cacb5f849a6957ebd4062173c148/src/dotnet-install.sh" + $DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/a3fbd0fd625032bac207f1f590e5353fe26faa59/src/dotnet-install.sh" $DotNetInstallScriptPath = "$DotNetInstallScriptRoot/dotnet-install.sh" } else { - $DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/0b09de9bc136cacb5f849a6957ebd4062173c148/src/dotnet-install.ps1" + $DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/a3fbd0fd625032bac207f1f590e5353fe26faa59/src/dotnet-install.ps1" $DotNetInstallScriptPath = "$DotNetInstallScriptRoot/dotnet-install.ps1" } @@ -306,7 +306,7 @@ $global:LASTEXITCODE = 0 $sdks |% { if ($_.Version) { $parameters = '-Version', $_.Version } else { $parameters = '-Channel', $_.Channel } - if ($PSCmdlet.ShouldProcess(".NET SDK $_", "Install")) { + if ($PSCmdlet.ShouldProcess(".NET SDK $_ ($arch)", "Install")) { $anythingInstalled = $true Invoke-Expression -Command "$DotNetInstallScriptPathExpression $parameters -Architecture $arch -InstallDir $DotNetInstallDir $switches" diff --git a/tools/artifacts/Variables.ps1 b/tools/artifacts/Variables.ps1 index 7a320c7ea..c4d976650 100644 --- a/tools/artifacts/Variables.ps1 +++ b/tools/artifacts/Variables.ps1 @@ -26,7 +26,7 @@ Get-ChildItem "$PSScriptRoot/../variables" |% { if ($value) { # We got something, so wrap it with quotes so it's treated like a literal value. - $value = "'$value'" + $value = "'" + $value.Replace("'", "''") + "'" } } diff --git a/tools/artifacts/coverageResults.ps1 b/tools/artifacts/coverageResults.ps1 index 8c68216ed..1aadbb747 100644 --- a/tools/artifacts/coverageResults.ps1 +++ b/tools/artifacts/coverageResults.ps1 @@ -1,25 +1,26 @@ -$RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..") +$RepoRoot = Resolve-Path "$PSScriptRoot\..\.." -$coverageFiles = @(Get-ChildItem "$RepoRoot/test/*.cobertura.xml" -Recurse | Where {$_.FullName -notlike "*/In/*" -and $_.FullName -notlike "*\In\*" }) +$coverageFilesUnderRoot = @(Get-ChildItem "$RepoRoot/*.cobertura.xml" -Recurse | Where-Object {$_.FullName -notlike "*/In/*" -and $_.FullName -notlike "*\In\*" }) + +# Under MTP, coverage files are written directly to the artifacts output directory, +# so we need to look there too. +$ArtifactStagingFolder = & "$PSScriptRoot/../Get-ArtifactsStagingDirectory.ps1" +$directTestLogs = Join-Path $ArtifactStagingFolder test_logs +$coverageFilesUnderArtifacts = if (Test-Path $directTestLogs) { @(Get-ChildItem "$directTestLogs/*.cobertura.xml" -Recurse) } else { @() } # Prepare code coverage reports for merging on another machine -$repoRoot = $env:SYSTEM_DEFAULTWORKINGDIRECTORY -if (!$repoRoot) { $repoRoot = $env:GITHUB_WORKSPACE } -if ($repoRoot) { - Write-Host "Substituting $repoRoot with `"{reporoot}`"" - $coverageFiles |% { - $content = Get-Content -LiteralPath $_ |% { $_ -Replace [regex]::Escape($repoRoot), "{reporoot}" } - Set-Content -LiteralPath $_ -Value $content -Encoding UTF8 - } -} else { - Write-Warning "coverageResults: Cloud build not detected. Machine-neutral token replacement skipped." +Write-Host "Substituting $repoRoot with `"{reporoot}`"" +@($coverageFilesUnderRoot + $coverageFilesUnderArtifacts) |? { $_ }|% { + $content = Get-Content -LiteralPath $_ |% { $_ -Replace [regex]::Escape($repoRoot), "{reporoot}" } + Set-Content -LiteralPath $_ -Value $content -Encoding UTF8 } if (!((Test-Path $RepoRoot\bin) -and (Test-Path $RepoRoot\obj))) { return } @{ + $directTestLogs = $coverageFilesUnderArtifacts; $RepoRoot = ( - $coverageFiles + + $coverageFilesUnderRoot + (Get-ChildItem "$RepoRoot\obj\*.cs" -Recurse) ); } diff --git a/tools/artifacts/testResults.ps1 b/tools/artifacts/testResults.ps1 index 5310fb52a..a841967e8 100644 --- a/tools/artifacts/testResults.ps1 +++ b/tools/artifacts/testResults.ps1 @@ -4,7 +4,8 @@ Param( $result = @{} -$testRoot = Resolve-Path "$PSScriptRoot\..\..\test" +$RepoRoot = Resolve-Path "$PSScriptRoot\..\.." +$testRoot = Join-Path $RepoRoot test $result[$testRoot] = (Get-ChildItem "$testRoot\TestResults" -Recurse -Directory | Get-ChildItem -Recurse -File) $artifactStaging = & "$PSScriptRoot/../Get-ArtifactsStagingDirectory.ps1" diff --git a/tools/dotnet-test-cloud.ps1 b/tools/dotnet-test-cloud.ps1 index 02891d975..b5504801e 100644 --- a/tools/dotnet-test-cloud.ps1 +++ b/tools/dotnet-test-cloud.ps1 @@ -25,6 +25,7 @@ Param( $RepoRoot = (Resolve-Path "$PSScriptRoot/..").Path $ArtifactStagingFolder = & "$PSScriptRoot/Get-ArtifactsStagingDirectory.ps1" +$OnCI = ($env:CI -or $env:TF_BUILD) $dotnet = 'dotnet' if ($x86) { @@ -45,23 +46,57 @@ if ($x86) { } $testBinLog = Join-Path $ArtifactStagingFolder (Join-Path build_logs test.binlog) -$testDiagLog = Join-Path $ArtifactStagingFolder (Join-Path test_logs diag.log) +$testLogs = Join-Path $ArtifactStagingFolder test_logs -& $dotnet test $RepoRoot ` - --no-build ` - -c $Configuration ` - --filter "TestCategory!=FailsInCloudTest" ` - --collect "Code Coverage;Format=cobertura" ` - --settings "$PSScriptRoot/test.runsettings" ` - --blame-hang-timeout 60s ` - --blame-crash ` - -bl:"$testBinLog" ` - --diag "$testDiagLog;TraceLevel=info" ` - --logger trx ` +$globalJson = Get-Content $PSScriptRoot/../global.json | ConvertFrom-Json +$isMTP = $globalJson.test.runner -eq 'Microsoft.Testing.Platform' +$extraArgs = @() + +if ($isMTP) { + if ($OnCI) { $extraArgs += '--no-progress' } + & $dotnet test --solution $RepoRoot ` + --no-build ` + -c $Configuration ` + -bl:"$testBinLog" ` + --filter-not-trait 'TestCategory=FailsInCloudTest' ` + --coverage ` + --coverage-output-format cobertura ` + --coverage-settings "$PSScriptRoot/test.runsettings" ` + --hangdump ` + --hangdump-timeout 60s ` + --crashdump ` + --diagnostic ` + --diagnostic-output-directory $testLogs ` + --diagnostic-verbosity Information ` + --results-directory $testLogs ` + --report-trx ` + @extraArgs + + $trxFiles = Get-ChildItem -Recurse -Path $testLogs\*.trx +} else { + $testDiagLog = Join-Path $ArtifactStagingFolder (Join-Path test_logs diag.log) + & $dotnet test $RepoRoot ` + --no-build ` + -c $Configuration ` + --filter "TestCategory!=FailsInCloudTest" ` + --collect "Code Coverage;Format=cobertura" ` + --settings "$PSScriptRoot/test.runsettings" ` + --blame-hang-timeout 60s ` + --blame-crash ` + -bl:"$testBinLog" ` + --diag "$testDiagLog;TraceLevel=info" ` + --logger trx ` + @extraArgs + + $trxFiles = Get-ChildItem -Recurse -Path $RepoRoot\test\*.trx +} $unknownCounter = 0 -Get-ChildItem -Recurse -Path $RepoRoot\test\*.trx |% { - Copy-Item $_ -Destination $ArtifactStagingFolder/test_logs/ +$trxFiles |% { + New-Item $testLogs -ItemType Directory -Force | Out-Null + if (!($_.FullName.StartsWith($testLogs))) { + Copy-Item $_ -Destination $testLogs + } if ($PublishResults) { $x = [xml](Get-Content -LiteralPath $_)