diff --git a/.github/workflows/basic-validation.yml b/.github/workflows/basic-validation.yml index a13e4aae2..493b08eb1 100644 --- a/.github/workflows/basic-validation.yml +++ b/.github/workflows/basic-validation.yml @@ -5,9 +5,6 @@ on: paths-ignore: - '**.md' push: - branches: - - main - - releases/* paths-ignore: - '**.md' diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index d152b5434..9cc257d27 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -2,8 +2,6 @@ name: Check dist/ on: push: - branches: - - main paths-ignore: - '**.md' pull_request: diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 7a8261238..c18410c0c 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -2,9 +2,7 @@ name: CodeQL analysis on: push: - branches: [main] pull_request: - branches: [main] schedule: - cron: '0 3 * * 0' diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 4bda39d82..a14e2521c 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -5,9 +5,6 @@ on: paths-ignore: - '**.md' push: - branches: - - main - - releases/* paths-ignore: - '**.md' @@ -257,6 +254,106 @@ jobs: shell: pwsh run: __tests__/verify-dotnet.ps1 -Patterns "^9.0", "^10.0" + test-setup-global-json-rollforward-latestmajor: + runs-on: ${{ matrix.operating-system }} + strategy: + fail-fast: false + matrix: + operating-system: [ubuntu-latest, windows-latest, macos-latest] + steps: + - name: Checkout + uses: actions/checkout@v6 + - name: Clear toolcache + shell: pwsh + run: __tests__/clear-toolcache.ps1 ${{ runner.os }} + - name: Write global.json + shell: bash + run: | + mkdir subdirectory + echo '{"sdk":{"version": "3.1.0","rollForward": "latestMajor"}}' > ./subdirectory/global.json + - name: Setup dotnet + uses: ./ + with: + global-json-file: ./subdirectory/global.json + - name: Verify dotnet + shell: pwsh + run: __tests__/verify-dotnet.ps1 -Patterns "^(?!3)" + + test-setup-global-json-rollforward-latestminor: + runs-on: ${{ matrix.operating-system }} + strategy: + fail-fast: false + matrix: + operating-system: [windows-latest] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Clear toolcache + shell: pwsh + run: __tests__/clear-toolcache.ps1 ${{ runner.os }} + - name: Write global.json + shell: bash + run: | + mkdir subdirectory + echo '{"sdk":{"version": "3.0.100","rollForward": "latestMinor"}}' > ./subdirectory/global.json + - name: Setup dotnet + uses: ./ + with: + global-json-file: ./subdirectory/global.json + - name: Verify dotnet + shell: pwsh + run: __tests__/verify-dotnet.ps1 -Patterns "^3.1" + + test-setup-global-json-rollforward-latestfeature: + runs-on: ${{ matrix.operating-system }} + strategy: + fail-fast: false + matrix: + operating-system: [ubuntu-latest, windows-latest, macos-latest] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Clear toolcache + shell: pwsh + run: __tests__/clear-toolcache.ps1 ${{ runner.os }} + - name: Write global.json + shell: bash + run: | + mkdir subdirectory + echo '{"sdk":{"version": "6.0.100","rollForward": "latestFeature"}}' > ./subdirectory/global.json + - name: Setup dotnet + uses: ./ + with: + global-json-file: ./subdirectory/global.json + - name: Verify dotnet + shell: pwsh + run: __tests__/verify-dotnet.ps1 -Patterns "^6.0.4" + + test-setup-global-json-rollforward-latestpatch: + runs-on: ${{ matrix.operating-system }} + strategy: + fail-fast: false + matrix: + operating-system: [ubuntu-latest, windows-latest, macos-latest] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Clear toolcache + shell: pwsh + run: __tests__/clear-toolcache.ps1 ${{ runner.os }} + - name: Write global.json + shell: bash + run: | + mkdir subdirectory + echo '{"sdk":{"version": "6.0.400","rollForward": "latestPatch"}}' > ./subdirectory/global.json + - name: Setup dotnet + uses: ./ + with: + global-json-file: ./subdirectory/global.json + - name: Verify dotnet + shell: pwsh + run: __tests__/verify-dotnet.ps1 -Patterns "^6.0.428$" + test-setup-global-json-only: runs-on: ${{ matrix.operating-system }} strategy: diff --git a/.github/workflows/licensed.yml b/.github/workflows/licensed.yml index 37f1560c3..d6ac99605 100644 --- a/.github/workflows/licensed.yml +++ b/.github/workflows/licensed.yml @@ -2,11 +2,7 @@ name: Licensed on: push: - branches: - - main pull_request: - branches: - - main workflow_dispatch: jobs: diff --git a/.github/workflows/test-dotnet.yml b/.github/workflows/test-dotnet.yml index 96985dcbe..a3a31bbfe 100644 --- a/.github/workflows/test-dotnet.yml +++ b/.github/workflows/test-dotnet.yml @@ -5,9 +5,6 @@ on: paths-ignore: - '**.md' push: - branches: - - main - - releases/* paths-ignore: - '**.md' diff --git a/__tests__/clear-toolcache.ps1 b/__tests__/clear-toolcache.ps1 index 5589ec1dd..a8bd902d1 100644 --- a/__tests__/clear-toolcache.ps1 +++ b/__tests__/clear-toolcache.ps1 @@ -6,8 +6,8 @@ $dotnetPaths = @{ foreach ($srcPath in $dotnetPaths[$args[0]]) { if (Test-Path $srcPath) { - Write-Host "Move $srcPath path" - $dstPath = Join-Path ([IO.Path]::GetTempPath()) ([IO.Path]::GetRandomFileName()) + $dstPath = "$srcPath-" + [IO.Path]::GetRandomFileName() + Write-Host "Moving $srcPath to $dstPath" Move-Item -Path $srcPath -Destination $dstPath } } \ No newline at end of file diff --git a/__tests__/e2e-test-csproj/AssemblyInfo.cs b/__tests__/e2e-test-csproj/AssemblyInfo.cs deleted file mode 100644 index d34b21fcc..000000000 --- a/__tests__/e2e-test-csproj/AssemblyInfo.cs +++ /dev/null @@ -1,4 +0,0 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; - -// Sequential test execution -[assembly: DoNotParallelize] \ No newline at end of file diff --git a/__tests__/e2e-test-csproj/Test.cs b/__tests__/e2e-test-csproj/Test.cs index d97fa0cd9..3ff0ea31a 100644 --- a/__tests__/e2e-test-csproj/Test.cs +++ b/__tests__/e2e-test-csproj/Test.cs @@ -1,18 +1,12 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; using System; namespace test_csproj { - [TestClass] - public class Test + public static class Program { - [TestMethod] - public void TestMethod() + public static void Main() { - Console.WriteLine("TestMethod"); - int calculatedResult = 1000 / 25; - int expectedResult = 40; - Assert.AreEqual(expectedResult, calculatedResult); + Console.WriteLine("Test"); } } } diff --git a/__tests__/e2e-test-csproj/packages.lock.json b/__tests__/e2e-test-csproj/packages.lock.json index 5b7a2c26c..ebf0ee9ee 100644 --- a/__tests__/e2e-test-csproj/packages.lock.json +++ b/__tests__/e2e-test-csproj/packages.lock.json @@ -2,116 +2,11 @@ "version": 1, "dependencies": { "net10.0": { - "Microsoft.NET.Test.Sdk": { - "type": "Direct", - "requested": "[18.0.1, )", - "resolved": "18.0.1", - "contentHash": "WNpu6vI2rA0pXY4r7NKxCN16XRWl5uHu6qjuyVLoDo6oYEggIQefrMjkRuibQHm/NslIUNCcKftvoWAN80MSAg==", - "dependencies": { - "Microsoft.CodeCoverage": "18.0.1", - "Microsoft.TestPlatform.TestHost": "18.0.1" - } - }, - "MSTest.TestAdapter": { - "type": "Direct", - "requested": "[4.0.2, )", - "resolved": "4.0.2", - "contentHash": "AHyUqtL2GUB5Of0LRvYtz1DvNHIP7KBItI1uX4Cfvgv3Vbdc1ZaCGCN2Zac/bz0S8pQpmnf7xn5K4zrL25NERg==", - "dependencies": { - "MSTest.TestFramework": "4.0.2", - "Microsoft.Testing.Extensions.VSTestBridge": "2.0.2", - "Microsoft.Testing.Platform.MSBuild": "2.0.2" - } - }, - "MSTest.TestFramework": { - "type": "Direct", - "requested": "[4.0.2, )", - "resolved": "4.0.2", - "contentHash": "ANLNvVh13tfi4ou0Xu0bZ5J83brlLufxMVVp1feUm99cWtfEn8i8PH4kskD0HSp1bFl8goZiHoCwd+fu/0L2hA==", - "dependencies": { - "MSTest.Analyzers": "4.0.2" - } - }, - "Microsoft.ApplicationInsights": { - "type": "Transitive", - "resolved": "2.23.0", - "contentHash": "nWArUZTdU7iqZLycLKWe0TDms48KKGE6pONH2terYNa8REXiqixrMOkf1sk5DHGMaUTqONU2YkS4SAXBhLStgw==" - }, - "Microsoft.CodeCoverage": { - "type": "Transitive", - "resolved": "18.0.1", - "contentHash": "O+utSr97NAJowIQT/OVp3Lh9QgW/wALVTP4RG1m2AfFP4IyJmJz0ZBmFJUsRQiAPgq6IRC0t8AAzsiPIsaUDEA==" - }, - "Microsoft.Testing.Extensions.Telemetry": { - "type": "Transitive", - "resolved": "2.0.2", - "contentHash": "H580BvHyuADoWzlH9zRk5fqVyGucm6mhph+k40CQc9O4ie+Buxa4Pk9Q92BEClqIICqi25J7fuMII9qFYYgKtw==", - "dependencies": { - "Microsoft.ApplicationInsights": "2.23.0", - "Microsoft.Testing.Platform": "2.0.2" - } - }, - "Microsoft.Testing.Extensions.TrxReport.Abstractions": { - "type": "Transitive", - "resolved": "2.0.2", - "contentHash": "MrHYdPZ1CiyYp5bfjzNSghfVwl/I9osMazcZMAbwZY0BhR32i70YLf4zSXECvU2qt2PvDdrjYpGRgBscFbjDpw==", - "dependencies": { - "Microsoft.Testing.Platform": "2.0.2" - } - }, - "Microsoft.Testing.Extensions.VSTestBridge": { - "type": "Transitive", - "resolved": "2.0.2", - "contentHash": "6WSUZyv71NmF1bhFWpNht2bskVWL/5Lcu9qxDUnnboYRiujh9w4swn/cPSbVCSGXwyMq9uKRlI9zZ+ReBO8e+Q==", - "dependencies": { - "Microsoft.TestPlatform.AdapterUtilities": "18.0.1", - "Microsoft.TestPlatform.ObjectModel": "18.0.1", - "Microsoft.Testing.Extensions.Telemetry": "2.0.2", - "Microsoft.Testing.Extensions.TrxReport.Abstractions": "2.0.2", - "Microsoft.Testing.Platform": "2.0.2" - } - }, - "Microsoft.Testing.Platform": { - "type": "Transitive", - "resolved": "2.0.2", - "contentHash": "43NCOTEENtdc9fmlzX9KHQR14AZEYek5r4jOJlWPhTyV1+aYAQYl4x773nYXU5TKxV6+rMuniJ7wcj9C9qrP1A==" - }, - "Microsoft.Testing.Platform.MSBuild": { - "type": "Transitive", - "resolved": "2.0.2", - "contentHash": "2zKkQKaUoaKgb/3AekboWOdLMh4upCo1nLWQnjGzp8r9YjiNOZRrzTsJQ3A4U03AcbH0evlIvFDKYSUqmTVuug==", - "dependencies": { - "Microsoft.Testing.Platform": "2.0.2" - } - }, - "Microsoft.TestPlatform.AdapterUtilities": { - "type": "Transitive", - "resolved": "18.0.1", - "contentHash": "gXIugDKnACB8p93+9dFnMdE7vvs0ZrjjDltdGC4VylbKK7gPegWYASGjryVkIDvFr56Ulx4UDIKsB71qYHJBWg==" - }, - "Microsoft.TestPlatform.ObjectModel": { - "type": "Transitive", - "resolved": "18.0.1", - "contentHash": "qT/mwMcLF9BieRkzOBPL2qCopl8hQu6A1P7JWAoj/FMu5i9vds/7cjbJ/LLtaiwWevWLAeD5v5wjQJ/l6jvhWQ==" - }, - "Microsoft.TestPlatform.TestHost": { - "type": "Transitive", - "resolved": "18.0.1", - "contentHash": "uDJKAEjFTaa2wHdWlfo6ektyoh+WD4/Eesrwb4FpBFKsLGehhACVnwwTI4qD3FrIlIEPlxdXg3SyrYRIcO+RRQ==", - "dependencies": { - "Microsoft.TestPlatform.ObjectModel": "18.0.1", - "Newtonsoft.Json": "13.0.3" - } - }, - "MSTest.Analyzers": { - "type": "Transitive", - "resolved": "4.0.2", - "contentHash": "83PHm/97WR6XuciUicakLXSPDFubMsphUHxQHgkUfHcF8rOjpnlKSjRazhuvcGeqy2co8ZudUNbTM+u5e5Ujow==" - }, "Newtonsoft.Json": { - "type": "Transitive", - "resolved": "13.0.3", - "contentHash": "HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ==" + "type": "Direct", + "requested": "[13.0.4, )", + "resolved": "13.0.4", + "contentHash": "pdgNNMai3zv51W5aq268sujXUyx7SNdE2bj1wZcWjAQrKMFZV260lbqYop1d2GM67JI1huLRwxo9ZqnfF/lC6A==" } } } diff --git a/__tests__/e2e-test-csproj/test.csproj b/__tests__/e2e-test-csproj/test.csproj index 218f6dcf5..5d39267b7 100644 --- a/__tests__/e2e-test-csproj/test.csproj +++ b/__tests__/e2e-test-csproj/test.csproj @@ -1,6 +1,7 @@ + Exe $(TEST_TARGET_FRAMEWORK) false true @@ -8,9 +9,7 @@ - - - + diff --git a/__tests__/verify-dotnet.ps1 b/__tests__/verify-dotnet.ps1 index 48339cfea..183e86a7e 100755 --- a/__tests__/verify-dotnet.ps1 +++ b/__tests__/verify-dotnet.ps1 @@ -104,7 +104,7 @@ foreach ($version in $Versions) } Write-Host "Testing compiled C# project with $version .NET version." - & $dotnet test --no-build + & $dotnet run --no-build if ($LASTEXITCODE -ne 0) { throw "Testing process is not successful, exit code: $LASTEXITCODE" diff --git a/dist/setup/index.js b/dist/setup/index.js index c58f52754..3e501593f 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -79246,9 +79246,23 @@ function getVersionFromGlobalJson(globalJsonPath) { if (globalJson.sdk && globalJson.sdk.version) { version = globalJson.sdk.version; const rollForward = globalJson.sdk.rollForward; - if (rollForward && rollForward === 'latestFeature') { - const [major, minor] = version.split('.'); - version = `${major}.${minor}`; + if (rollForward) { + const [major, minor, featurePatch] = version.split('.'); + const feature = featurePatch.substring(0, 1); + switch (rollForward) { + case 'latestMajor': + version = ''; + break; + case 'latestMinor': + version = `${major}`; + break; + case 'latestFeature': + version = `${major}.${minor}`; + break; + case 'latestPatch': + version = `${major}.${minor}.${feature}xx`; + break; + } } } return version; diff --git a/src/setup-dotnet.ts b/src/setup-dotnet.ts index 4950f8fb3..969adbc08 100644 --- a/src/setup-dotnet.ts +++ b/src/setup-dotnet.ts @@ -207,9 +207,27 @@ function getVersionFromGlobalJson(globalJsonPath: string): string { if (globalJson.sdk && globalJson.sdk.version) { version = globalJson.sdk.version; const rollForward = globalJson.sdk.rollForward; - if (rollForward && rollForward === 'latestFeature') { - const [major, minor] = version.split('.'); - version = `${major}.${minor}`; + if (rollForward) { + const [major, minor, featurePatch] = version.split('.'); + const feature = featurePatch.substring(0, 1); + + switch (rollForward) { + case 'latestMajor': + version = ''; + break; + + case 'latestMinor': + version = `${major}`; + break; + + case 'latestFeature': + version = `${major}.${minor}`; + break; + + case 'latestPatch': + version = `${major}.${minor}.${feature}xx`; + break; + } } } return version;