From 617171a4ec5df510be39711360c1e20e75b2dc10 Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Tue, 6 May 2025 00:09:17 -0700 Subject: [PATCH 01/30] Set additional environment variables --- .../Workload/Restore/GivenDotnetWorkloadRestore.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs b/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs index 28a388b9055a..f6e7e9b0138b 100644 --- a/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs +++ b/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs @@ -17,6 +17,7 @@ public void ProjectsThatDoNotSupportWorkloadsAreNotInspected() { var testDir = _testAssetsManager.CreateTestDirectory().Path; var cliHome = Path.Combine(testDir, ".home"); + var metadataDir = Path.Combine(testDir, ".metadata"); var projectPath = _testAssetsManager @@ -27,6 +28,8 @@ public void ProjectsThatDoNotSupportWorkloadsAreNotInspected() new DotnetWorkloadCommand(Log, "restore") .WithWorkingDirectory(projectPath) .WithEnvironmentVariable("DOTNET_CLI_HOME", cliHome) + .WithEnvironmentVariable("DOTNET_WORKLOAD_METADATA_DIR", metadataDir) + .WithEnvironmentVariable("DOTNET_SKIP_WORKLOAD_VERIFICATION", "true") .Execute() .Should() // if we did try to restore the dcproj in this TestAsset we would fail, so passing means we didn't! @@ -38,6 +41,7 @@ public void ProjectsThatDoNotSupportWorkloadsAndAreTransitivelyReferencedDoNotBr { var testDir = _testAssetsManager.CreateTestDirectory().Path; var cliHome = Path.Combine(testDir, ".home"); + var metadataDir = Path.Combine(testDir, ".metadata"); var projectPath = _testAssetsManager @@ -48,6 +52,8 @@ public void ProjectsThatDoNotSupportWorkloadsAndAreTransitivelyReferencedDoNotBr new DotnetWorkloadCommand(Log, "restore") .WithWorkingDirectory(projectPath) .WithEnvironmentVariable("DOTNET_CLI_HOME", cliHome) + .WithEnvironmentVariable("DOTNET_WORKLOAD_METADATA_DIR", metadataDir) + .WithEnvironmentVariable("DOTNET_SKIP_WORKLOAD_VERIFICATION", "true") .Execute() .Should() // if we did try to restore the esproj in this TestAsset we would fail, so passing means we didn't! From f36523bdb76b1d3947a281e3ac263d92810d01ff Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Wed, 7 May 2025 23:29:09 -0700 Subject: [PATCH 02/30] Attempt to enable local DOTNET_CLI_HOME to avoid read-only filesystem errors --- .../Restore/GivenDotnetWorkloadRestore.cs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs b/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs index f6e7e9b0138b..d672ea77ac92 100644 --- a/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs +++ b/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +๏ปฟ// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace Microsoft.DotNet.Cli.Workload.Restore.Tests; @@ -15,9 +15,9 @@ public GivenDotnetWorkloadRestore(ITestOutputHelper log) : base(log) [Fact] public void ProjectsThatDoNotSupportWorkloadsAreNotInspected() { - var testDir = _testAssetsManager.CreateTestDirectory().Path; - var cliHome = Path.Combine(testDir, ".home"); - var metadataDir = Path.Combine(testDir, ".metadata"); + var cliHome = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); + Directory.CreateDirectory(cliHome); + File.Create(Path.Combine(cliHome, "userlocal")).Dispose(); var projectPath = _testAssetsManager @@ -28,8 +28,6 @@ public void ProjectsThatDoNotSupportWorkloadsAreNotInspected() new DotnetWorkloadCommand(Log, "restore") .WithWorkingDirectory(projectPath) .WithEnvironmentVariable("DOTNET_CLI_HOME", cliHome) - .WithEnvironmentVariable("DOTNET_WORKLOAD_METADATA_DIR", metadataDir) - .WithEnvironmentVariable("DOTNET_SKIP_WORKLOAD_VERIFICATION", "true") .Execute() .Should() // if we did try to restore the dcproj in this TestAsset we would fail, so passing means we didn't! @@ -39,9 +37,9 @@ public void ProjectsThatDoNotSupportWorkloadsAreNotInspected() [Fact] public void ProjectsThatDoNotSupportWorkloadsAndAreTransitivelyReferencedDoNotBreakTheBuild() { - var testDir = _testAssetsManager.CreateTestDirectory().Path; - var cliHome = Path.Combine(testDir, ".home"); - var metadataDir = Path.Combine(testDir, ".metadata"); + var cliHome = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); + Directory.CreateDirectory(cliHome); + File.Create(Path.Combine(cliHome, "userlocal")).Dispose(); var projectPath = _testAssetsManager @@ -52,8 +50,6 @@ public void ProjectsThatDoNotSupportWorkloadsAndAreTransitivelyReferencedDoNotBr new DotnetWorkloadCommand(Log, "restore") .WithWorkingDirectory(projectPath) .WithEnvironmentVariable("DOTNET_CLI_HOME", cliHome) - .WithEnvironmentVariable("DOTNET_WORKLOAD_METADATA_DIR", metadataDir) - .WithEnvironmentVariable("DOTNET_SKIP_WORKLOAD_VERIFICATION", "true") .Execute() .Should() // if we did try to restore the esproj in this TestAsset we would fail, so passing means we didn't! From 463da3587b30a37032c6c591fff9d83cd33bf5ba Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Thu, 8 May 2025 01:16:22 -0700 Subject: [PATCH 03/30] Set full path --- .../Restore/GivenDotnetWorkloadRestore.cs | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs b/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs index d672ea77ac92..118c7643f705 100644 --- a/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs +++ b/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs @@ -17,7 +17,7 @@ public void ProjectsThatDoNotSupportWorkloadsAreNotInspected() { var cliHome = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); Directory.CreateDirectory(cliHome); - File.Create(Path.Combine(cliHome, "userlocal")).Dispose(); + CreateUserLocalFileForCurrentSdk(cliHome); var projectPath = _testAssetsManager @@ -39,7 +39,7 @@ public void ProjectsThatDoNotSupportWorkloadsAndAreTransitivelyReferencedDoNotBr { var cliHome = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); Directory.CreateDirectory(cliHome); - File.Create(Path.Combine(cliHome, "userlocal")).Dispose(); + CreateUserLocalFileForCurrentSdk(cliHome); var projectPath = _testAssetsManager @@ -55,4 +55,20 @@ public void ProjectsThatDoNotSupportWorkloadsAndAreTransitivelyReferencedDoNotBr // if we did try to restore the esproj in this TestAsset we would fail, so passing means we didn't! .Pass(); } + + private void CreateUserLocalFileForCurrentSdk(string cliHome) + { + var result = new DotnetCommand(Log, "--version").Execute(); + if (result.ExitCode != 0 || string.IsNullOrWhiteSpace(result.StdOut)) + { + throw new Exception("Failed to get dotnet version"); + } + var sdkVersion = result.StdOut.Trim(); + var version = Version.Parse(sdkVersion.Split('-')[0]); + var featureBand = $"{version.Major}.{version.Minor}.{(version.Build / 100) * 100}"; + + var userlocalPath = Path.Combine(cliHome, ".dotnet", "metadata", "workloads", featureBand); + Directory.CreateDirectory(userlocalPath); + File.Create(Path.Combine(userlocalPath, "userlocal")).Dispose(); + } } From 437c64d061cda1aa54a1540111312426801cc758 Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Thu, 8 May 2025 20:11:28 -0700 Subject: [PATCH 04/30] Add more logs --- .../Restore/GivenDotnetWorkloadRestore.cs | 41 +++++++++++++++---- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs b/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs index 118c7643f705..af2e873c8c4c 100644 --- a/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs +++ b/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs @@ -41,6 +41,10 @@ public void ProjectsThatDoNotSupportWorkloadsAndAreTransitivelyReferencedDoNotBr Directory.CreateDirectory(cliHome); CreateUserLocalFileForCurrentSdk(cliHome); + Log.WriteLine($"[DEBUG] DOTNET_CLI_HOME = {Environment.GetEnvironmentVariable("DOTNET_CLI_HOME")}"); + Log.WriteLine($"[DEBUG] HOME = {Environment.GetEnvironmentVariable("HOME")}"); + Log.WriteLine($"[DEBUG] DOTNET_ROOT = {Environment.GetEnvironmentVariable("DOTNET_ROOT")}"); + var projectPath = _testAssetsManager .CopyTestAsset(TransitiveReferenceNoWorkloadsAssetName) @@ -48,12 +52,12 @@ public void ProjectsThatDoNotSupportWorkloadsAndAreTransitivelyReferencedDoNotBr .Path; new DotnetWorkloadCommand(Log, "restore") - .WithWorkingDirectory(projectPath) - .WithEnvironmentVariable("DOTNET_CLI_HOME", cliHome) - .Execute() - .Should() - // if we did try to restore the esproj in this TestAsset we would fail, so passing means we didn't! - .Pass(); + .WithWorkingDirectory(projectPath) + .WithEnvironmentVariable("DOTNET_ROOT", cliHome) + .Execute() + .Should() + // if we did try to restore the esproj in this TestAsset we would fail, so passing means we didn't! + .Pass(); } private void CreateUserLocalFileForCurrentSdk(string cliHome) @@ -67,8 +71,29 @@ private void CreateUserLocalFileForCurrentSdk(string cliHome) var version = Version.Parse(sdkVersion.Split('-')[0]); var featureBand = $"{version.Major}.{version.Minor}.{(version.Build / 100) * 100}"; - var userlocalPath = Path.Combine(cliHome, ".dotnet", "metadata", "workloads", featureBand); + var userlocalPath = Path.Combine(cliHome, "metadata", "workloads", featureBand); Directory.CreateDirectory(userlocalPath); - File.Create(Path.Combine(userlocalPath, "userlocal")).Dispose(); + + var userlocalFile = Path.Combine(userlocalPath, "userlocal"); + File.Create(userlocalFile).Dispose(); + + Log.WriteLine($"[DEBUG] Directory exists({userlocalPath}): {Directory.Exists(userlocalPath)}"); + Log.WriteLine($"[DEBUG] File exists({userlocalFile}): {File.Exists(userlocalFile)}"); + Log.WriteLine($"[DEBUG] userlocal path writable: {IsDirectoryWritable(userlocalPath)}"); + } + + private bool IsDirectoryWritable(string path) + { + try + { + var testFile = Path.Combine(path, Path.GetRandomFileName()); + File.WriteAllText(testFile, "test"); + File.Delete(testFile); + return true; + } + catch + { + return false; + } } } From 606eb024314db9fbc2b8f9aff70420c4458db101 Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Thu, 8 May 2025 23:12:38 -0700 Subject: [PATCH 05/30] User DOTNET_CLI_HOME --- .../CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs b/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs index af2e873c8c4c..7b8efc3aac07 100644 --- a/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs +++ b/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs @@ -53,7 +53,7 @@ public void ProjectsThatDoNotSupportWorkloadsAndAreTransitivelyReferencedDoNotBr new DotnetWorkloadCommand(Log, "restore") .WithWorkingDirectory(projectPath) - .WithEnvironmentVariable("DOTNET_ROOT", cliHome) + .WithEnvironmentVariable("DOTNET_CLI_HOME", cliHome) .Execute() .Should() // if we did try to restore the esproj in this TestAsset we would fail, so passing means we didn't! From c6b29d33a4168658aced27cd425edefcd3561295 Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Fri, 9 May 2025 01:33:42 -0700 Subject: [PATCH 06/30] fix --- .../Restore/GivenDotnetWorkloadRestore.cs | 41 ++++++++----------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs b/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs index 7b8efc3aac07..145f37265cfd 100644 --- a/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs +++ b/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs @@ -15,7 +15,7 @@ public GivenDotnetWorkloadRestore(ITestOutputHelper log) : base(log) [Fact] public void ProjectsThatDoNotSupportWorkloadsAreNotInspected() { - var cliHome = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); + var cliHome = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName(), ".dotnet"); Directory.CreateDirectory(cliHome); CreateUserLocalFileForCurrentSdk(cliHome); @@ -28,6 +28,11 @@ public void ProjectsThatDoNotSupportWorkloadsAreNotInspected() new DotnetWorkloadCommand(Log, "restore") .WithWorkingDirectory(projectPath) .WithEnvironmentVariable("DOTNET_CLI_HOME", cliHome) + .WithEnvironmentVariable("HOME", cliHome) + .WithEnvironmentVariable("DOTNET_ROOT", cliHome) + .WithEnvironmentVariable("DOTNETSDK_WORKLOAD_MANIFEST_ROOTS", Path.Combine(cliHome, "sdk-manifests")) + .WithEnvironmentVariable("DOTNETSDK_WORKLOAD_PACK_ROOTS", Path.Combine(cliHome, "packs")) + .WithEnvironmentVariable("DOTNETSDK_WORKLOAD_METADATA_ROOT", Path.Combine(cliHome, "metadata")) .Execute() .Should() // if we did try to restore the dcproj in this TestAsset we would fail, so passing means we didn't! @@ -41,10 +46,6 @@ public void ProjectsThatDoNotSupportWorkloadsAndAreTransitivelyReferencedDoNotBr Directory.CreateDirectory(cliHome); CreateUserLocalFileForCurrentSdk(cliHome); - Log.WriteLine($"[DEBUG] DOTNET_CLI_HOME = {Environment.GetEnvironmentVariable("DOTNET_CLI_HOME")}"); - Log.WriteLine($"[DEBUG] HOME = {Environment.GetEnvironmentVariable("HOME")}"); - Log.WriteLine($"[DEBUG] DOTNET_ROOT = {Environment.GetEnvironmentVariable("DOTNET_ROOT")}"); - var projectPath = _testAssetsManager .CopyTestAsset(TransitiveReferenceNoWorkloadsAssetName) @@ -54,6 +55,11 @@ public void ProjectsThatDoNotSupportWorkloadsAndAreTransitivelyReferencedDoNotBr new DotnetWorkloadCommand(Log, "restore") .WithWorkingDirectory(projectPath) .WithEnvironmentVariable("DOTNET_CLI_HOME", cliHome) + .WithEnvironmentVariable("HOME", cliHome) + .WithEnvironmentVariable("DOTNET_ROOT", cliHome) + .WithEnvironmentVariable("DOTNETSDK_WORKLOAD_MANIFEST_ROOTS", Path.Combine(cliHome, "sdk-manifests")) + .WithEnvironmentVariable("DOTNETSDK_WORKLOAD_PACK_ROOTS", Path.Combine(cliHome, "packs")) + .WithEnvironmentVariable("DOTNETSDK_WORKLOAD_METADATA_ROOT", Path.Combine(cliHome, "metadata")) .Execute() .Should() // if we did try to restore the esproj in this TestAsset we would fail, so passing means we didn't! @@ -71,29 +77,14 @@ private void CreateUserLocalFileForCurrentSdk(string cliHome) var version = Version.Parse(sdkVersion.Split('-')[0]); var featureBand = $"{version.Major}.{version.Minor}.{(version.Build / 100) * 100}"; + Directory.CreateDirectory(Path.Combine(cliHome, "sdk-manifests")); + Directory.CreateDirectory(Path.Combine(cliHome, "packs")); + + File.Create(Path.Combine(cliHome, "userlocal")).Dispose(); + var userlocalPath = Path.Combine(cliHome, "metadata", "workloads", featureBand); Directory.CreateDirectory(userlocalPath); - var userlocalFile = Path.Combine(userlocalPath, "userlocal"); File.Create(userlocalFile).Dispose(); - - Log.WriteLine($"[DEBUG] Directory exists({userlocalPath}): {Directory.Exists(userlocalPath)}"); - Log.WriteLine($"[DEBUG] File exists({userlocalFile}): {File.Exists(userlocalFile)}"); - Log.WriteLine($"[DEBUG] userlocal path writable: {IsDirectoryWritable(userlocalPath)}"); - } - - private bool IsDirectoryWritable(string path) - { - try - { - var testFile = Path.Combine(path, Path.GetRandomFileName()); - File.WriteAllText(testFile, "test"); - File.Delete(testFile); - return true; - } - catch - { - return false; - } } } From f154121f3a965b240decf00695b861925f14ff4e Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Sun, 11 May 2025 23:42:41 -0700 Subject: [PATCH 07/30] fix --- .../Workload/Restore/GivenDotnetWorkloadRestore.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs b/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs index 145f37265cfd..c64b015802b0 100644 --- a/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs +++ b/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs @@ -30,10 +30,11 @@ public void ProjectsThatDoNotSupportWorkloadsAreNotInspected() .WithEnvironmentVariable("DOTNET_CLI_HOME", cliHome) .WithEnvironmentVariable("HOME", cliHome) .WithEnvironmentVariable("DOTNET_ROOT", cliHome) + .WithEnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0") .WithEnvironmentVariable("DOTNETSDK_WORKLOAD_MANIFEST_ROOTS", Path.Combine(cliHome, "sdk-manifests")) .WithEnvironmentVariable("DOTNETSDK_WORKLOAD_PACK_ROOTS", Path.Combine(cliHome, "packs")) .WithEnvironmentVariable("DOTNETSDK_WORKLOAD_METADATA_ROOT", Path.Combine(cliHome, "metadata")) - .Execute() + .Execute("--verbosity", "diag") .Should() // if we did try to restore the dcproj in this TestAsset we would fail, so passing means we didn't! .Pass(); @@ -57,10 +58,11 @@ public void ProjectsThatDoNotSupportWorkloadsAndAreTransitivelyReferencedDoNotBr .WithEnvironmentVariable("DOTNET_CLI_HOME", cliHome) .WithEnvironmentVariable("HOME", cliHome) .WithEnvironmentVariable("DOTNET_ROOT", cliHome) + .WithEnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0") .WithEnvironmentVariable("DOTNETSDK_WORKLOAD_MANIFEST_ROOTS", Path.Combine(cliHome, "sdk-manifests")) .WithEnvironmentVariable("DOTNETSDK_WORKLOAD_PACK_ROOTS", Path.Combine(cliHome, "packs")) .WithEnvironmentVariable("DOTNETSDK_WORKLOAD_METADATA_ROOT", Path.Combine(cliHome, "metadata")) - .Execute() + .Execute("--verbosity", "diag") .Should() // if we did try to restore the esproj in this TestAsset we would fail, so passing means we didn't! .Pass(); @@ -68,6 +70,10 @@ public void ProjectsThatDoNotSupportWorkloadsAndAreTransitivelyReferencedDoNotBr private void CreateUserLocalFileForCurrentSdk(string cliHome) { + + log.WriteLine($"[Debug] IsRunningInContainer = {Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER")}"); + log.WriteLine($"[Debug] OSDescription = {RuntimeInformation.OSDescription}"); + var result = new DotnetCommand(Log, "--version").Execute(); if (result.ExitCode != 0 || string.IsNullOrWhiteSpace(result.StdOut)) { From ee7b3db69de6bab4ec344de44dad9492fbbba6fa Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Sun, 11 May 2025 23:47:01 -0700 Subject: [PATCH 08/30] Capital letters --- .../Workload/Restore/GivenDotnetWorkloadRestore.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs b/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs index c64b015802b0..21e37cf49c61 100644 --- a/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs +++ b/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs @@ -47,6 +47,9 @@ public void ProjectsThatDoNotSupportWorkloadsAndAreTransitivelyReferencedDoNotBr Directory.CreateDirectory(cliHome); CreateUserLocalFileForCurrentSdk(cliHome); + Log.WriteLine($"[Debug] IsRunningInContainer = {Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER")}"); + Log.WriteLine($"[Debug] OSDescription = {RuntimeInformation.OSDescription}"); + var projectPath = _testAssetsManager .CopyTestAsset(TransitiveReferenceNoWorkloadsAssetName) @@ -70,10 +73,6 @@ public void ProjectsThatDoNotSupportWorkloadsAndAreTransitivelyReferencedDoNotBr private void CreateUserLocalFileForCurrentSdk(string cliHome) { - - log.WriteLine($"[Debug] IsRunningInContainer = {Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER")}"); - log.WriteLine($"[Debug] OSDescription = {RuntimeInformation.OSDescription}"); - var result = new DotnetCommand(Log, "--version").Execute(); if (result.ExitCode != 0 || string.IsNullOrWhiteSpace(result.StdOut)) { From 5b931159ac7254893d40184dcbf25f148cd4cba9 Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Mon, 12 May 2025 03:39:44 -0700 Subject: [PATCH 09/30] Update --- .../Restore/GivenDotnetWorkloadRestore.cs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs b/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs index 21e37cf49c61..7aa0bec3b3b1 100644 --- a/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs +++ b/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs @@ -71,6 +71,42 @@ public void ProjectsThatDoNotSupportWorkloadsAndAreTransitivelyReferencedDoNotBr .Pass(); } + [Fact] + public void ProjectsThatDoNotSupportWorkloadsAndAreTransitivelyReferencedDoNotBreakTheBuild1() + { + + var cliHome = Environment.GetEnvironmentVariable("DOTNET_CLI_HOME"); + if (string.IsNullOrEmpty(cliHome)) + { + throw new InvalidOperationException("DOTNET_CLI_HOME is not set in the environment."); + } + var result = new DotnetCommand(Log, "--version").Execute(); + if (result.ExitCode != 0 || string.IsNullOrWhiteSpace(result.StdOut)) + { + throw new Exception("Failed to get dotnet version"); + } + var sdkVersion = result.StdOut.Trim(); + var version = Version.Parse(sdkVersion.Split('-')[0]); + var featureBand = $"{version.Major}.{version.Minor}.{(version.Build / 100) * 100}"; + + var userlocalPath = Path.Combine(cliHome, "metadata", "workloads", featureBand); + Directory.CreateDirectory(userlocalPath); + File.Create(Path.Combine(userlocalPath, "userlocal")).Dispose(); + + var projectPath = + _testAssetsManager + .CopyTestAsset(TransitiveReferenceNoWorkloadsAssetName) + .WithSource() + .Path; + + new DotnetWorkloadCommand(Log, "restore") + .WithWorkingDirectory(projectPath) + .Execute("--verbosity", "diag") + .Should() + // if we did try to restore the esproj in this TestAsset we would fail, so passing means we didn't! + .Pass(); + } + private void CreateUserLocalFileForCurrentSdk(string cliHome) { var result = new DotnetCommand(Log, "--version").Execute(); From 1609ba241d1c13a38da847c60ce97561aa00ea73 Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Mon, 12 May 2025 19:42:49 -0700 Subject: [PATCH 10/30] update --- .../Restore/GivenDotnetWorkloadRestore.cs | 106 ++++++++++-------- 1 file changed, 57 insertions(+), 49 deletions(-) diff --git a/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs b/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs index 7aa0bec3b3b1..106df57c2e9b 100644 --- a/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs +++ b/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs @@ -15,7 +15,12 @@ public GivenDotnetWorkloadRestore(ITestOutputHelper log) : base(log) [Fact] public void ProjectsThatDoNotSupportWorkloadsAreNotInspected() { - var cliHome = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName(), ".dotnet"); + var Home = Environment.GetEnvironmentVariable("DOTNET_CLI_HOME"); + if (string.IsNullOrEmpty(cliHome)) + { + throw new InvalidOperationException("DOTNET_CLI_HOME is not set in the environment."); + } + var cliHome = Path.Combine(Home, ".dotnet"); Directory.CreateDirectory(cliHome); CreateUserLocalFileForCurrentSdk(cliHome); @@ -28,12 +33,6 @@ public void ProjectsThatDoNotSupportWorkloadsAreNotInspected() new DotnetWorkloadCommand(Log, "restore") .WithWorkingDirectory(projectPath) .WithEnvironmentVariable("DOTNET_CLI_HOME", cliHome) - .WithEnvironmentVariable("HOME", cliHome) - .WithEnvironmentVariable("DOTNET_ROOT", cliHome) - .WithEnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0") - .WithEnvironmentVariable("DOTNETSDK_WORKLOAD_MANIFEST_ROOTS", Path.Combine(cliHome, "sdk-manifests")) - .WithEnvironmentVariable("DOTNETSDK_WORKLOAD_PACK_ROOTS", Path.Combine(cliHome, "packs")) - .WithEnvironmentVariable("DOTNETSDK_WORKLOAD_METADATA_ROOT", Path.Combine(cliHome, "metadata")) .Execute("--verbosity", "diag") .Should() // if we did try to restore the dcproj in this TestAsset we would fail, so passing means we didn't! @@ -43,11 +42,15 @@ public void ProjectsThatDoNotSupportWorkloadsAreNotInspected() [Fact] public void ProjectsThatDoNotSupportWorkloadsAndAreTransitivelyReferencedDoNotBreakTheBuild() { - var cliHome = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); + var Home = Environment.GetEnvironmentVariable("DOTNET_CLI_HOME"); + if (string.IsNullOrEmpty(cliHome)) + { + throw new InvalidOperationException("DOTNET_CLI_HOME is not set in the environment."); + } Directory.CreateDirectory(cliHome); CreateUserLocalFileForCurrentSdk(cliHome); - Log.WriteLine($"[Debug] IsRunningInContainer = {Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER")}"); + IsRunningInContainer(); Log.WriteLine($"[Debug] OSDescription = {RuntimeInformation.OSDescription}"); var projectPath = @@ -59,27 +62,14 @@ public void ProjectsThatDoNotSupportWorkloadsAndAreTransitivelyReferencedDoNotBr new DotnetWorkloadCommand(Log, "restore") .WithWorkingDirectory(projectPath) .WithEnvironmentVariable("DOTNET_CLI_HOME", cliHome) - .WithEnvironmentVariable("HOME", cliHome) - .WithEnvironmentVariable("DOTNET_ROOT", cliHome) - .WithEnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0") - .WithEnvironmentVariable("DOTNETSDK_WORKLOAD_MANIFEST_ROOTS", Path.Combine(cliHome, "sdk-manifests")) - .WithEnvironmentVariable("DOTNETSDK_WORKLOAD_PACK_ROOTS", Path.Combine(cliHome, "packs")) - .WithEnvironmentVariable("DOTNETSDK_WORKLOAD_METADATA_ROOT", Path.Combine(cliHome, "metadata")) .Execute("--verbosity", "diag") .Should() // if we did try to restore the esproj in this TestAsset we would fail, so passing means we didn't! .Pass(); } - [Fact] - public void ProjectsThatDoNotSupportWorkloadsAndAreTransitivelyReferencedDoNotBreakTheBuild1() + private void CreateUserLocalFileForCurrentSdk(string cliHome) { - - var cliHome = Environment.GetEnvironmentVariable("DOTNET_CLI_HOME"); - if (string.IsNullOrEmpty(cliHome)) - { - throw new InvalidOperationException("DOTNET_CLI_HOME is not set in the environment."); - } var result = new DotnetCommand(Log, "--version").Execute(); if (result.ExitCode != 0 || string.IsNullOrWhiteSpace(result.StdOut)) { @@ -93,39 +83,57 @@ public void ProjectsThatDoNotSupportWorkloadsAndAreTransitivelyReferencedDoNotBr Directory.CreateDirectory(userlocalPath); File.Create(Path.Combine(userlocalPath, "userlocal")).Dispose(); - var projectPath = - _testAssetsManager - .CopyTestAsset(TransitiveReferenceNoWorkloadsAssetName) - .WithSource() - .Path; - - new DotnetWorkloadCommand(Log, "restore") - .WithWorkingDirectory(projectPath) - .Execute("--verbosity", "diag") - .Should() - // if we did try to restore the esproj in this TestAsset we would fail, so passing means we didn't! - .Pass(); + var userlocalPath1 = Path.Combine(cliHome, "metadata", "workloads", featureBand, "installertype"); + Directory.CreateDirectory(userlocalPath1); + File.Create(Path.Combine(userlocalPath1, "userlocal")).Dispose(); } - private void CreateUserLocalFileForCurrentSdk(string cliHome) + bool IsRunningInContainer() { - var result = new DotnetCommand(Log, "--version").Execute(); - if (result.ExitCode != 0 || string.IsNullOrWhiteSpace(result.StdOut)) + // Check the DOTNET_RUNNING_IN_CONTAINER environment variable + var envVar = Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER"); + Log.WriteLine($"[Debug] DOTNET_RUNNING_IN_CONTAINER = {(envVar ?? "null")}"); + if (!string.IsNullOrEmpty(envVar) && envVar.Equals("true", StringComparison.OrdinalIgnoreCase)) { - throw new Exception("Failed to get dotnet version"); + Log.WriteLine("[Debug] Container detected via DOTNET_RUNNING_IN_CONTAINER environment variable."); + return true; } - var sdkVersion = result.StdOut.Trim(); - var version = Version.Parse(sdkVersion.Split('-')[0]); - var featureBand = $"{version.Major}.{version.Minor}.{(version.Build / 100) * 100}"; - Directory.CreateDirectory(Path.Combine(cliHome, "sdk-manifests")); - Directory.CreateDirectory(Path.Combine(cliHome, "packs")); + // Check for the presence of /.dockerenv file (common in Docker containers) + if (File.Exists("/.dockerenv")) + { + Log.WriteLine("[Debug] Container detected via /.dockerenv file."); + return true; + } - File.Create(Path.Combine(cliHome, "userlocal")).Dispose(); + // Check for the presence of /run/.containerenv file (used in some container runtimes) + if (File.Exists("/run/.containerenv")) + { + Log.WriteLine("[Debug] Container detected via /run/.containerenv file."); + return true; + } - var userlocalPath = Path.Combine(cliHome, "metadata", "workloads", featureBand); - Directory.CreateDirectory(userlocalPath); - var userlocalFile = Path.Combine(userlocalPath, "userlocal"); - File.Create(userlocalFile).Dispose(); + // Inspect /proc/1/cgroup for container-related keywords + try + { + var lines = File.ReadAllLines("/proc/1/cgroup"); + foreach (var line in lines) + { + Log.WriteLine($"[Debug] /proc/1/cgroup line: {line}"); + if (line.Contains("docker") || line.Contains("kubepods") || line.Contains("containerd")) + { + Log.WriteLine("[Debug] Container detected via /proc/1/cgroup content."); + return true; + } + } + } + catch (Exception ex) + { + Log.WriteLine($"[Debug] Failed to read /proc/1/cgroup: {ex.Message}"); + } + + // No container indicators found + Log.WriteLine("[Debug] No container indicators found. Assuming not running in a container."); + return false; } } From e0893a6681942d8d5ac68dfa6b6966e9e5cc4eb9 Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Mon, 12 May 2025 20:00:11 -0700 Subject: [PATCH 11/30] update --- .../Workload/Restore/GivenDotnetWorkloadRestore.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs b/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs index 106df57c2e9b..e25978b0944c 100644 --- a/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs +++ b/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs @@ -16,7 +16,7 @@ public GivenDotnetWorkloadRestore(ITestOutputHelper log) : base(log) public void ProjectsThatDoNotSupportWorkloadsAreNotInspected() { var Home = Environment.GetEnvironmentVariable("DOTNET_CLI_HOME"); - if (string.IsNullOrEmpty(cliHome)) + if (string.IsNullOrEmpty(Home)) { throw new InvalidOperationException("DOTNET_CLI_HOME is not set in the environment."); } @@ -43,7 +43,7 @@ public void ProjectsThatDoNotSupportWorkloadsAreNotInspected() public void ProjectsThatDoNotSupportWorkloadsAndAreTransitivelyReferencedDoNotBreakTheBuild() { var Home = Environment.GetEnvironmentVariable("DOTNET_CLI_HOME"); - if (string.IsNullOrEmpty(cliHome)) + if (string.IsNullOrEmpty(Home)) { throw new InvalidOperationException("DOTNET_CLI_HOME is not set in the environment."); } From 2f62d1fff4ebfa61669af2e3fda2710bb6add849 Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Mon, 12 May 2025 20:14:33 -0700 Subject: [PATCH 12/30] Update --- .../Workload/Restore/GivenDotnetWorkloadRestore.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs b/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs index e25978b0944c..d8dc02093916 100644 --- a/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs +++ b/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs @@ -47,8 +47,8 @@ public void ProjectsThatDoNotSupportWorkloadsAndAreTransitivelyReferencedDoNotBr { throw new InvalidOperationException("DOTNET_CLI_HOME is not set in the environment."); } - Directory.CreateDirectory(cliHome); - CreateUserLocalFileForCurrentSdk(cliHome); + Directory.CreateDirectory(Home); + CreateUserLocalFileForCurrentSdk(Home); IsRunningInContainer(); Log.WriteLine($"[Debug] OSDescription = {RuntimeInformation.OSDescription}"); @@ -61,7 +61,7 @@ public void ProjectsThatDoNotSupportWorkloadsAndAreTransitivelyReferencedDoNotBr new DotnetWorkloadCommand(Log, "restore") .WithWorkingDirectory(projectPath) - .WithEnvironmentVariable("DOTNET_CLI_HOME", cliHome) + .WithEnvironmentVariable("DOTNET_CLI_HOME", Home) .Execute("--verbosity", "diag") .Should() // if we did try to restore the esproj in this TestAsset we would fail, so passing means we didn't! From 47c7eb695dd27a766328fe1857ff78d524a11c1f Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Mon, 12 May 2025 22:57:54 -0700 Subject: [PATCH 13/30] skip --- .../Restore/GivenDotnetWorkloadRestore.cs | 94 ++----------------- 1 file changed, 10 insertions(+), 84 deletions(-) diff --git a/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs b/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs index d8dc02093916..46bb1f2d8d46 100644 --- a/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs +++ b/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs @@ -15,14 +15,11 @@ public GivenDotnetWorkloadRestore(ITestOutputHelper log) : base(log) [Fact] public void ProjectsThatDoNotSupportWorkloadsAreNotInspected() { - var Home = Environment.GetEnvironmentVariable("DOTNET_CLI_HOME"); - if (string.IsNullOrEmpty(Home)) + if(IsRunningInContainer()) { - throw new InvalidOperationException("DOTNET_CLI_HOME is not set in the environment."); + // Skipping test in containerized: DOTNET_ROOT is read-only, causing workload restore to fail due to inability to write metadata. + return; } - var cliHome = Path.Combine(Home, ".dotnet"); - Directory.CreateDirectory(cliHome); - CreateUserLocalFileForCurrentSdk(cliHome); var projectPath = _testAssetsManager @@ -32,8 +29,7 @@ public void ProjectsThatDoNotSupportWorkloadsAreNotInspected() new DotnetWorkloadCommand(Log, "restore") .WithWorkingDirectory(projectPath) - .WithEnvironmentVariable("DOTNET_CLI_HOME", cliHome) - .Execute("--verbosity", "diag") + .Execute() .Should() // if we did try to restore the dcproj in this TestAsset we would fail, so passing means we didn't! .Pass(); @@ -42,16 +38,11 @@ public void ProjectsThatDoNotSupportWorkloadsAreNotInspected() [Fact] public void ProjectsThatDoNotSupportWorkloadsAndAreTransitivelyReferencedDoNotBreakTheBuild() { - var Home = Environment.GetEnvironmentVariable("DOTNET_CLI_HOME"); - if (string.IsNullOrEmpty(Home)) + if(IsRunningInContainer()) { - throw new InvalidOperationException("DOTNET_CLI_HOME is not set in the environment."); + // Skipping test in containerized: DOTNET_ROOT is read-only, causing workload restore to fail due to inability to write metadata. + return; } - Directory.CreateDirectory(Home); - CreateUserLocalFileForCurrentSdk(Home); - - IsRunningInContainer(); - Log.WriteLine($"[Debug] OSDescription = {RuntimeInformation.OSDescription}"); var projectPath = _testAssetsManager @@ -61,79 +52,14 @@ public void ProjectsThatDoNotSupportWorkloadsAndAreTransitivelyReferencedDoNotBr new DotnetWorkloadCommand(Log, "restore") .WithWorkingDirectory(projectPath) - .WithEnvironmentVariable("DOTNET_CLI_HOME", Home) - .Execute("--verbosity", "diag") + .Execute() .Should() // if we did try to restore the esproj in this TestAsset we would fail, so passing means we didn't! .Pass(); } - private void CreateUserLocalFileForCurrentSdk(string cliHome) + private bool IsRunningInContainer() { - var result = new DotnetCommand(Log, "--version").Execute(); - if (result.ExitCode != 0 || string.IsNullOrWhiteSpace(result.StdOut)) - { - throw new Exception("Failed to get dotnet version"); - } - var sdkVersion = result.StdOut.Trim(); - var version = Version.Parse(sdkVersion.Split('-')[0]); - var featureBand = $"{version.Major}.{version.Minor}.{(version.Build / 100) * 100}"; - - var userlocalPath = Path.Combine(cliHome, "metadata", "workloads", featureBand); - Directory.CreateDirectory(userlocalPath); - File.Create(Path.Combine(userlocalPath, "userlocal")).Dispose(); - - var userlocalPath1 = Path.Combine(cliHome, "metadata", "workloads", featureBand, "installertype"); - Directory.CreateDirectory(userlocalPath1); - File.Create(Path.Combine(userlocalPath1, "userlocal")).Dispose(); - } - - bool IsRunningInContainer() - { - // Check the DOTNET_RUNNING_IN_CONTAINER environment variable - var envVar = Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER"); - Log.WriteLine($"[Debug] DOTNET_RUNNING_IN_CONTAINER = {(envVar ?? "null")}"); - if (!string.IsNullOrEmpty(envVar) && envVar.Equals("true", StringComparison.OrdinalIgnoreCase)) - { - Log.WriteLine("[Debug] Container detected via DOTNET_RUNNING_IN_CONTAINER environment variable."); - return true; - } - - // Check for the presence of /.dockerenv file (common in Docker containers) - if (File.Exists("/.dockerenv")) - { - Log.WriteLine("[Debug] Container detected via /.dockerenv file."); - return true; - } - - // Check for the presence of /run/.containerenv file (used in some container runtimes) - if (File.Exists("/run/.containerenv")) - { - Log.WriteLine("[Debug] Container detected via /run/.containerenv file."); - return true; - } - - // Inspect /proc/1/cgroup for container-related keywords - try - { - var lines = File.ReadAllLines("/proc/1/cgroup"); - foreach (var line in lines) - { - Log.WriteLine($"[Debug] /proc/1/cgroup line: {line}"); - if (line.Contains("docker") || line.Contains("kubepods") || line.Contains("containerd")) - { - Log.WriteLine("[Debug] Container detected via /proc/1/cgroup content."); - return true; - } - } - } - catch (Exception ex) - { - Log.WriteLine($"[Debug] Failed to read /proc/1/cgroup: {ex.Message}"); - } - - // No container indicators found - Log.WriteLine("[Debug] No container indicators found. Assuming not running in a container."); - return false; + return File.Exists("/.dockerenv") && RuntimeInformation.OSDescription.Contains("Ubuntu"); } } From cba79657a625293e11ca86e82c6ea1aa4959968a Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Sun, 18 May 2025 19:42:33 -0700 Subject: [PATCH 14/30] Enable other containers for testing --- .../templates/jobs/sdk-job-matrix.yml | 31 +++++++------------ 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/eng/pipelines/templates/jobs/sdk-job-matrix.yml b/eng/pipelines/templates/jobs/sdk-job-matrix.yml index 28d3380458a5..208bc4a90bbf 100644 --- a/eng/pipelines/templates/jobs/sdk-job-matrix.yml +++ b/eng/pipelines/templates/jobs/sdk-job-matrix.yml @@ -34,38 +34,29 @@ parameters: osProperties: $(linuxOsPortableProperties) runTests: true - categoryName: ContainerBased - container: fedora39 - # No fedora Helix container is available, so use the ubuntu one instead. - helixTargetContainer: $(helixTargetContainerPrefix)ubuntu-22.04-helix-amd64 + container: fedora42 + helixTargetContainer: $(helixTargetContainerPrefix)fedora-42-helix-amd64 osProperties: $(linuxOsPortableProperties) - # Skipping all container-based testing for now. - # See: https://github.com/dotnet/sdk/issues/40935 - runTests: false + runTests: true - categoryName: ContainerBased container: centosStream9 - helixTargetContainer: $(helixTargetContainerPrefix)centos-stream9-helix + helixTargetContainer: $(helixTargetContainerPrefix)centos-stream-10-helix-amd64 osProperties: /p:OSName=linux - # Skipping all container-based testing for now. - # See: https://github.com/dotnet/sdk/issues/40935 - runTests: false + runTests: true - categoryName: ContainerBased - container: debian12Amd64 - helixTargetContainer: $(helixTargetContainerPrefix)debian-11-helix-amd64 + container: debian13Amd64 + helixTargetContainer: $(helixTargetContainerPrefix)debian-13-helix-amd64 osProperties: /p:OSName=linux /p:BuildSdkDeb=true - # Skipping all container-based testing for now. - # See: https://github.com/dotnet/sdk/issues/40935 - runTests: false + runTests: true - categoryName: ContainerBased - container: alpine319WithNode - helixTargetContainer: $(helixTargetContainerPrefix)alpine-3.18-helix-amd64 + container: alpine321Amd64 + helixTargetContainer: $(helixTargetContainerPrefix)alpine-3.21-helix-amd64 runtimeIdentifier: linux-musl-x64 # Use HostOSName when running on alpine. osProperties: /p:HostOSName=linux-musl # SBOM generation is not supported for alpine. enableSbom: false - # Skipping all container-based testing for now. - # See: https://github.com/dotnet/sdk/issues/40935 - runTests: false + runTests: true - categoryName: TemplateEngine osProperties: $(linuxOsPortableProperties) testProjects: $(Build.SourcesDirectory)/test/Microsoft.TemplateEngine.Cli.UnitTests/Microsoft.TemplateEngine.Cli.UnitTests.csproj;$(Build.SourcesDirectory)/test/dotnet-new.IntegrationTests/dotnet-new.IntegrationTests.csproj From 033e097994efe281a83a0536b84dd6aef6cb5c62 Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Sun, 18 May 2025 23:16:13 -0700 Subject: [PATCH 15/30] Update --- .vsts-pr.yml | 20 +++++++++---------- .../templates/jobs/sdk-job-matrix.yml | 8 ++++---- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.vsts-pr.yml b/.vsts-pr.yml index 2478c07d6590..5b0c67ca5584 100644 --- a/.vsts-pr.yml +++ b/.vsts-pr.yml @@ -27,16 +27,16 @@ variables: resources: containers: - - container: alpine319WithNode - image: mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.19-WithNode - - container: centosStream9 - image: mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream9 - - container: debian12Amd64 - image: mcr.microsoft.com/dotnet-buildtools/prereqs:debian-12-gcc14-amd64 - - container: fedora39 - image: mcr.microsoft.com/dotnet-buildtools/prereqs:fedora-39 - - container: ubuntu2204DebPkg - image: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-22.04-debpkg + - container: alpine321 + image: mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.21-helix-amd64 + - container: centosStream10 + image: mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream-10-helix-amd64 + - container: debian13 + image: mcr.microsoft.com/dotnet-buildtools/prereqs:debian-13-helix-amd64 + - container: fedora42 + image: mcr.microsoft.com/dotnet-buildtools/prereqs:fedora-42-helix-amd64 + - container: ubuntu2204 + image: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-22.04-helix-amd64 stages: ############### BUILD STAGE ############### diff --git a/eng/pipelines/templates/jobs/sdk-job-matrix.yml b/eng/pipelines/templates/jobs/sdk-job-matrix.yml index 208bc4a90bbf..c113489d2d65 100644 --- a/eng/pipelines/templates/jobs/sdk-job-matrix.yml +++ b/eng/pipelines/templates/jobs/sdk-job-matrix.yml @@ -29,7 +29,7 @@ parameters: # Don't run the tests on arm64. Only perform the build itself. runTests: false - categoryName: ContainerBased - container: ubuntu2204DebPkg + container: ubuntu2204 helixTargetContainer: $(helixTargetContainerPrefix)ubuntu-22.04-helix-amd64 osProperties: $(linuxOsPortableProperties) runTests: true @@ -39,17 +39,17 @@ parameters: osProperties: $(linuxOsPortableProperties) runTests: true - categoryName: ContainerBased - container: centosStream9 + container: centosStream10 helixTargetContainer: $(helixTargetContainerPrefix)centos-stream-10-helix-amd64 osProperties: /p:OSName=linux runTests: true - categoryName: ContainerBased - container: debian13Amd64 + container: debian13 helixTargetContainer: $(helixTargetContainerPrefix)debian-13-helix-amd64 osProperties: /p:OSName=linux /p:BuildSdkDeb=true runTests: true - categoryName: ContainerBased - container: alpine321Amd64 + container: alpine321 helixTargetContainer: $(helixTargetContainerPrefix)alpine-3.21-helix-amd64 runtimeIdentifier: linux-musl-x64 # Use HostOSName when running on alpine. From 3f8bc0a1265777bf4321d0a2f8f243e7c7328230 Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Sun, 18 May 2025 23:42:32 -0700 Subject: [PATCH 16/30] Update --- .vsts-ci.yml | 6 +++--- .vsts-pr.yml | 20 +++++++++---------- .../templates/jobs/sdk-job-matrix.yml | 18 ++++++++--------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.vsts-ci.yml b/.vsts-ci.yml index d6421f73acc2..ccf52b58ab47 100644 --- a/.vsts-ci.yml +++ b/.vsts-ci.yml @@ -69,9 +69,9 @@ extends: centosStream9: image: mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream9 debian12Amd64: - image: mcr.microsoft.com/dotnet-buildtools/prereqs:debian-12-gcc14-amd64 - fedora39: - image: mcr.microsoft.com/dotnet-buildtools/prereqs:fedora-39 + image: mcr.microsoft.com/dotnet-buildtools/prereqs:debian-12-gcc15-amd64 + fedora40: + image: mcr.microsoft.com/dotnet-buildtools/prereqs:fedora-40 mariner20CrossArm: image: mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-cross-arm sdl: diff --git a/.vsts-pr.yml b/.vsts-pr.yml index 5b0c67ca5584..4b9cbf007a7e 100644 --- a/.vsts-pr.yml +++ b/.vsts-pr.yml @@ -27,16 +27,16 @@ variables: resources: containers: - - container: alpine321 - image: mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.21-helix-amd64 - - container: centosStream10 - image: mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream-10-helix-amd64 - - container: debian13 - image: mcr.microsoft.com/dotnet-buildtools/prereqs:debian-13-helix-amd64 - - container: fedora42 - image: mcr.microsoft.com/dotnet-buildtools/prereqs:fedora-42-helix-amd64 - - container: ubuntu2204 - image: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-22.04-helix-amd64 + - container: alpine319WithNode + image: mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.19-WithNode + - container: centosStream9 + image: mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream9 + - container: debian12Amd64 + image: mcr.microsoft.com/dotnet-buildtools/prereqs:debian-12-gcc15-amd64 + - container: fedora40 + image: mcr.microsoft.com/dotnet-buildtools/prereqs:fedora-40 + - container: ubuntu2204DebPkg + image: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-22.04-debpkg stages: ############### BUILD STAGE ############### diff --git a/eng/pipelines/templates/jobs/sdk-job-matrix.yml b/eng/pipelines/templates/jobs/sdk-job-matrix.yml index c113489d2d65..ce7b693c7dc0 100644 --- a/eng/pipelines/templates/jobs/sdk-job-matrix.yml +++ b/eng/pipelines/templates/jobs/sdk-job-matrix.yml @@ -29,28 +29,28 @@ parameters: # Don't run the tests on arm64. Only perform the build itself. runTests: false - categoryName: ContainerBased - container: ubuntu2204 + container: ubuntu2204DebPkg helixTargetContainer: $(helixTargetContainerPrefix)ubuntu-22.04-helix-amd64 osProperties: $(linuxOsPortableProperties) runTests: true - categoryName: ContainerBased - container: fedora42 - helixTargetContainer: $(helixTargetContainerPrefix)fedora-42-helix-amd64 + container: fedora40 + helixTargetContainer: $(helixTargetContainerPrefix)fedora-41-helix-amd64 osProperties: $(linuxOsPortableProperties) runTests: true - categoryName: ContainerBased - container: centosStream10 - helixTargetContainer: $(helixTargetContainerPrefix)centos-stream-10-helix-amd64 + container: centosStream9 + helixTargetContainer: $(helixTargetContainerPrefix)centos-stream-9-helix-amd64 osProperties: /p:OSName=linux runTests: true - categoryName: ContainerBased - container: debian13 - helixTargetContainer: $(helixTargetContainerPrefix)debian-13-helix-amd64 + container: debian12Amd64 + helixTargetContainer: $(helixTargetContainerPrefix)debian-11-helix-amd64 osProperties: /p:OSName=linux /p:BuildSdkDeb=true runTests: true - categoryName: ContainerBased - container: alpine321 - helixTargetContainer: $(helixTargetContainerPrefix)alpine-3.21-helix-amd64 + container: alpine319WithNode + helixTargetContainer: $(helixTargetContainerPrefix)alpine-3.18-helix-amd64 runtimeIdentifier: linux-musl-x64 # Use HostOSName when running on alpine. osProperties: /p:HostOSName=linux-musl From 4d17a9391445360d2e11fd9e90b9d1c7c5c77325 Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Mon, 19 May 2025 01:11:25 -0700 Subject: [PATCH 17/30] Update --- .vsts-ci.yml | 4 ++-- .vsts-pr.yml | 4 ++-- eng/pipelines/templates/jobs/sdk-job-matrix.yml | 2 +- test/Microsoft.NET.TestFramework/EnvironmentInfo.cs | 10 ++++++++++ .../Workload/Restore/GivenDotnetWorkloadRestore.cs | 2 +- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.vsts-ci.yml b/.vsts-ci.yml index ccf52b58ab47..fbb32c7a9e81 100644 --- a/.vsts-ci.yml +++ b/.vsts-ci.yml @@ -70,8 +70,8 @@ extends: image: mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream9 debian12Amd64: image: mcr.microsoft.com/dotnet-buildtools/prereqs:debian-12-gcc15-amd64 - fedora40: - image: mcr.microsoft.com/dotnet-buildtools/prereqs:fedora-40 + fedora41: + image: mcr.microsoft.com/dotnet-buildtools/prereqs:fedora-41 mariner20CrossArm: image: mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-cross-arm sdl: diff --git a/.vsts-pr.yml b/.vsts-pr.yml index 4b9cbf007a7e..2166a87cff9a 100644 --- a/.vsts-pr.yml +++ b/.vsts-pr.yml @@ -33,8 +33,8 @@ resources: image: mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream9 - container: debian12Amd64 image: mcr.microsoft.com/dotnet-buildtools/prereqs:debian-12-gcc15-amd64 - - container: fedora40 - image: mcr.microsoft.com/dotnet-buildtools/prereqs:fedora-40 + - container: fedora41 + image: mcr.microsoft.com/dotnet-buildtools/prereqs:fedora-41 - container: ubuntu2204DebPkg image: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-22.04-debpkg diff --git a/eng/pipelines/templates/jobs/sdk-job-matrix.yml b/eng/pipelines/templates/jobs/sdk-job-matrix.yml index ce7b693c7dc0..75c8e35df768 100644 --- a/eng/pipelines/templates/jobs/sdk-job-matrix.yml +++ b/eng/pipelines/templates/jobs/sdk-job-matrix.yml @@ -34,7 +34,7 @@ parameters: osProperties: $(linuxOsPortableProperties) runTests: true - categoryName: ContainerBased - container: fedora40 + container: fedora41 helixTargetContainer: $(helixTargetContainerPrefix)fedora-41-helix-amd64 osProperties: $(linuxOsPortableProperties) runTests: true diff --git a/test/Microsoft.NET.TestFramework/EnvironmentInfo.cs b/test/Microsoft.NET.TestFramework/EnvironmentInfo.cs index a1ef8b832be7..89372f5314d6 100644 --- a/test/Microsoft.NET.TestFramework/EnvironmentInfo.cs +++ b/test/Microsoft.NET.TestFramework/EnvironmentInfo.cs @@ -139,6 +139,16 @@ public static bool SupportsTargetFramework(string targetFramework) } } } + else if (osId.Equals("debian", StringComparison.OrdinalIgnoreCase)) + { + if (osVersion.Major >= 11) + { + if (nugetFramework.Version < new Version(2, 0, 0, 0)) + { + return false; + } + } + } else if (osId.Equals("rhel", StringComparison.OrdinalIgnoreCase)) { if (osVersion.Major == 6) diff --git a/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs b/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs index 46bb1f2d8d46..e12459e03f0d 100644 --- a/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs +++ b/test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs @@ -60,6 +60,6 @@ public void ProjectsThatDoNotSupportWorkloadsAndAreTransitivelyReferencedDoNotBr private bool IsRunningInContainer() { - return File.Exists("/.dockerenv") && RuntimeInformation.OSDescription.Contains("Ubuntu"); + return File.Exists("/.dockerenv") && (RuntimeInformation.OSDescription.Contains("Ubuntu") || RuntimeInformation.OSDescription.Contains("Debian")); } } From 8e22e90b5a43eec06a49b97387d341329695e0ab Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Mon, 19 May 2025 19:36:16 -0700 Subject: [PATCH 18/30] debug --- test/Microsoft.NET.TestFramework/EnvironmentInfo.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/Microsoft.NET.TestFramework/EnvironmentInfo.cs b/test/Microsoft.NET.TestFramework/EnvironmentInfo.cs index 89372f5314d6..51ef4d60be3e 100644 --- a/test/Microsoft.NET.TestFramework/EnvironmentInfo.cs +++ b/test/Microsoft.NET.TestFramework/EnvironmentInfo.cs @@ -103,6 +103,9 @@ public static bool SupportsTargetFramework(string targetFramework) } else if (Version.TryParse(versionString, out Version? osVersion)) { + Console.WriteLine($"[DEBUG] osId: {osId}"); + Console.WriteLine($"[DEBUG] osVersion: {osVersion}"); + Console.WriteLine($"[DEBUG] osVersion.Major: {osVersion.Major}"); if (osId.Equals("fedora", StringComparison.OrdinalIgnoreCase)) { if (osVersion.Major <= 27) @@ -140,7 +143,7 @@ public static bool SupportsTargetFramework(string targetFramework) } } else if (osId.Equals("debian", StringComparison.OrdinalIgnoreCase)) - { + { if (osVersion.Major >= 11) { if (nugetFramework.Version < new Version(2, 0, 0, 0)) From 8f9f9d262be0db4c16040707f0ebc541c54daccd Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Mon, 19 May 2025 20:56:39 -0700 Subject: [PATCH 19/30] update --- .../EnvironmentInfo.cs | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/test/Microsoft.NET.TestFramework/EnvironmentInfo.cs b/test/Microsoft.NET.TestFramework/EnvironmentInfo.cs index 51ef4d60be3e..200292717175 100644 --- a/test/Microsoft.NET.TestFramework/EnvironmentInfo.cs +++ b/test/Microsoft.NET.TestFramework/EnvironmentInfo.cs @@ -101,11 +101,15 @@ public static bool SupportsTargetFramework(string targetFramework) return false; } } + else if (osId.Equals("debian", StringComparison.OrdinalIgnoreCase)) + { + if (nugetFramework.Version < new Version(2, 0, 0, 0)) + { + return false; + } + } else if (Version.TryParse(versionString, out Version? osVersion)) { - Console.WriteLine($"[DEBUG] osId: {osId}"); - Console.WriteLine($"[DEBUG] osVersion: {osVersion}"); - Console.WriteLine($"[DEBUG] osVersion.Major: {osVersion.Major}"); if (osId.Equals("fedora", StringComparison.OrdinalIgnoreCase)) { if (osVersion.Major <= 27) @@ -142,16 +146,6 @@ public static bool SupportsTargetFramework(string targetFramework) } } } - else if (osId.Equals("debian", StringComparison.OrdinalIgnoreCase)) - { - if (osVersion.Major >= 11) - { - if (nugetFramework.Version < new Version(2, 0, 0, 0)) - { - return false; - } - } - } else if (osId.Equals("rhel", StringComparison.OrdinalIgnoreCase)) { if (osVersion.Major == 6) From edefedcf865ddad6943220e2994fa2557baf80f6 Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Mon, 19 May 2025 20:59:13 -0700 Subject: [PATCH 20/30] update --- .vsts-ci.yml | 4 ++-- .vsts-pr.yml | 4 ++-- eng/pipelines/templates/jobs/sdk-job-matrix.yml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.vsts-ci.yml b/.vsts-ci.yml index fbb32c7a9e81..6ab58854063b 100644 --- a/.vsts-ci.yml +++ b/.vsts-ci.yml @@ -70,8 +70,8 @@ extends: image: mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream9 debian12Amd64: image: mcr.microsoft.com/dotnet-buildtools/prereqs:debian-12-gcc15-amd64 - fedora41: - image: mcr.microsoft.com/dotnet-buildtools/prereqs:fedora-41 + fedora39: + image: mcr.microsoft.com/dotnet-buildtools/prereqs:fedora-39 mariner20CrossArm: image: mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-cross-arm sdl: diff --git a/.vsts-pr.yml b/.vsts-pr.yml index 2166a87cff9a..60d2d4f865f3 100644 --- a/.vsts-pr.yml +++ b/.vsts-pr.yml @@ -33,8 +33,8 @@ resources: image: mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream9 - container: debian12Amd64 image: mcr.microsoft.com/dotnet-buildtools/prereqs:debian-12-gcc15-amd64 - - container: fedora41 - image: mcr.microsoft.com/dotnet-buildtools/prereqs:fedora-41 + - container: fedora39 + image: mcr.microsoft.com/dotnet-buildtools/prereqs:fedora-39 - container: ubuntu2204DebPkg image: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-22.04-debpkg diff --git a/eng/pipelines/templates/jobs/sdk-job-matrix.yml b/eng/pipelines/templates/jobs/sdk-job-matrix.yml index 75c8e35df768..b7476125f18b 100644 --- a/eng/pipelines/templates/jobs/sdk-job-matrix.yml +++ b/eng/pipelines/templates/jobs/sdk-job-matrix.yml @@ -34,13 +34,13 @@ parameters: osProperties: $(linuxOsPortableProperties) runTests: true - categoryName: ContainerBased - container: fedora41 + container: fedora39 helixTargetContainer: $(helixTargetContainerPrefix)fedora-41-helix-amd64 osProperties: $(linuxOsPortableProperties) runTests: true - categoryName: ContainerBased container: centosStream9 - helixTargetContainer: $(helixTargetContainerPrefix)centos-stream-9-helix-amd64 + helixTargetContainer: $(helixTargetContainerPrefix)centos-stream-9-helix osProperties: /p:OSName=linux runTests: true - categoryName: ContainerBased From 98ca74f8af77e468eb650c84b1f57d22629ccb23 Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Mon, 19 May 2025 21:00:02 -0700 Subject: [PATCH 21/30] update --- eng/pipelines/templates/jobs/sdk-job-matrix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/jobs/sdk-job-matrix.yml b/eng/pipelines/templates/jobs/sdk-job-matrix.yml index b7476125f18b..0e0824384317 100644 --- a/eng/pipelines/templates/jobs/sdk-job-matrix.yml +++ b/eng/pipelines/templates/jobs/sdk-job-matrix.yml @@ -40,7 +40,7 @@ parameters: runTests: true - categoryName: ContainerBased container: centosStream9 - helixTargetContainer: $(helixTargetContainerPrefix)centos-stream-9-helix + helixTargetContainer: $(helixTargetContainerPrefix)centos-stream9-helix osProperties: /p:OSName=linux runTests: true - categoryName: ContainerBased From 44c5e79d1cf3ae782270a22228e84170aefc284b Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Tue, 20 May 2025 20:19:03 -0700 Subject: [PATCH 22/30] update --- build/RunTestsOnHelix.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build/RunTestsOnHelix.sh b/build/RunTestsOnHelix.sh index 640138d7d8f7..3de70f3a88c3 100644 --- a/build/RunTestsOnHelix.sh +++ b/build/RunTestsOnHelix.sh @@ -1,5 +1,11 @@ #!/usr/bin/env bash +echo "๐Ÿ“ฆ Installing dependencies for CentOS..." +yum install -y zlib-devel libunwind || { + echo "โŒ Failed to install required packages. Please check your permissions or network." + exit 1 +} + # make NuGet network operations more robust export NUGET_ENABLE_EXPERIMENTAL_HTTP_RETRY=true export NUGET_EXPERIMENTAL_MAX_NETWORK_TRY_COUNT=6 From a61a00187c60b081535bd9073eb30affdae1b520 Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Tue, 20 May 2025 22:40:24 -0700 Subject: [PATCH 23/30] update --- build/RunTestsOnHelix.sh | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/build/RunTestsOnHelix.sh b/build/RunTestsOnHelix.sh index 3de70f3a88c3..29f9c7a8a326 100644 --- a/build/RunTestsOnHelix.sh +++ b/build/RunTestsOnHelix.sh @@ -1,12 +1,33 @@ #!/usr/bin/env bash -echo "๐Ÿ“ฆ Installing dependencies for CentOS..." -yum install -y zlib-devel libunwind || { - echo "โŒ Failed to install required packages. Please check your permissions or network." - exit 1 +install_dependencies() { + echo "๐Ÿ“ฆ Installing dependencies..." + if [ -f /etc/os-release ]; then + . /etc/os-release + case "$ID" in + ubuntu|debian) + apt-get update && apt-get install -y zlib1g-dev libunwind8 + ;; + centos|rhel) + yum install -y zlib-devel libunwind + ;; + fedora) + dnf install -y zlib-devel libunwind + ;; + alpine) + apk add --no-cache zlib-dev libunwind + ;; + *) + echo "โš ๏ธ Unsupported OS: $ID. Please install dependencies manually." + ;; + esac + else + echo "โš ๏ธ /etc/os-release not found. Cannot determine OS." + fi } -# make NuGet network operations more robust +install_dependencies + export NUGET_ENABLE_EXPERIMENTAL_HTTP_RETRY=true export NUGET_EXPERIMENTAL_MAX_NETWORK_TRY_COUNT=6 export NUGET_EXPERIMENTAL_NETWORK_RETRY_DELAY_MILLISECONDS=1000 From a7d089e9572e78b79c8990923c3fac5743fbd3b2 Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Tue, 20 May 2025 23:15:02 -0700 Subject: [PATCH 24/30] update --- .vsts-ci.yml | 6 +++--- .vsts-pr.yml | 4 ++-- eng/pipelines/templates/jobs/sdk-job-matrix.yml | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.vsts-ci.yml b/.vsts-ci.yml index 6ab58854063b..e02fd371273e 100644 --- a/.vsts-ci.yml +++ b/.vsts-ci.yml @@ -64,8 +64,8 @@ extends: template: v1/1ES.Official.PipelineTemplate.yml@1esPipelines parameters: containers: - alpine319WithNode: - image: mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.19-WithNode + alpine321Amd64: + image: mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.21-amd64 centosStream9: image: mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream9 debian12Amd64: @@ -242,7 +242,7 @@ extends: runTests: false ### MUSL ### - categoryName: Musl - container: alpine319WithNode + container: alpine321Amd64 runtimeIdentifier: linux-musl-x64 publishArgument: $(_publishArgument) officialBuildProperties: $(_officialBuildProperties) diff --git a/.vsts-pr.yml b/.vsts-pr.yml index 60d2d4f865f3..c45c899a5c47 100644 --- a/.vsts-pr.yml +++ b/.vsts-pr.yml @@ -27,8 +27,8 @@ variables: resources: containers: - - container: alpine319WithNode - image: mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.19-WithNode + - container: alpine321Amd64 + image: mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.21-amd64 - container: centosStream9 image: mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream9 - container: debian12Amd64 diff --git a/eng/pipelines/templates/jobs/sdk-job-matrix.yml b/eng/pipelines/templates/jobs/sdk-job-matrix.yml index 0e0824384317..1773f43ad967 100644 --- a/eng/pipelines/templates/jobs/sdk-job-matrix.yml +++ b/eng/pipelines/templates/jobs/sdk-job-matrix.yml @@ -49,8 +49,8 @@ parameters: osProperties: /p:OSName=linux /p:BuildSdkDeb=true runTests: true - categoryName: ContainerBased - container: alpine319WithNode - helixTargetContainer: $(helixTargetContainerPrefix)alpine-3.18-helix-amd64 + container: alpine321Amd64 + helixTargetContainer: $(helixTargetContainerPrefix)alpine-3.21-helix-amd64 runtimeIdentifier: linux-musl-x64 # Use HostOSName when running on alpine. osProperties: /p:HostOSName=linux-musl From 7df93091786d1adf31444eb4e21589275b39eb7c Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Wed, 21 May 2025 01:24:12 -0700 Subject: [PATCH 25/30] update --- build/RunTestsOnHelix.sh | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/build/RunTestsOnHelix.sh b/build/RunTestsOnHelix.sh index 29f9c7a8a326..4b22f4e19f15 100644 --- a/build/RunTestsOnHelix.sh +++ b/build/RunTestsOnHelix.sh @@ -2,20 +2,41 @@ install_dependencies() { echo "๐Ÿ“ฆ Installing dependencies..." + if [ -f /etc/os-release ]; then + echo "๐Ÿ” Detected /etc/os-release" . /etc/os-release + echo "๐Ÿงพ OS Info: ID=$ID, VERSION_ID=$VERSION_ID, PRETTY_NAME=$PRETTY_NAME" + case "$ID" in ubuntu|debian) - apt-get update && apt-get install -y zlib1g-dev libunwind8 + echo "๐Ÿ“ฆ Using apt-get to install dependencies..." + sudo apt-get update + sudo apt-get install -y zlib1g-dev libunwind8 clang lld || { + echo "โŒ Failed to install dependencies with apt-get" + exit 1 + } ;; centos|rhel) - yum install -y zlib-devel libunwind + echo "๐Ÿ“ฆ Using yum to install dependencies..." + sudo yum install -y zlib-devel libunwind clang lld || { + echo "โŒ Failed to install dependencies with yum" + exit 1 + } ;; fedora) - dnf install -y zlib-devel libunwind + echo "๐Ÿ“ฆ Using dnf to install dependencies..." + sudo dnf install -y zlib-devel libunwind clang lld || { + echo "โŒ Failed to install dependencies with dnf" + exit 1 + } ;; alpine) - apk add --no-cache zlib-dev libunwind + echo "๐Ÿ“ฆ Using apk to install dependencies..." + sudo apk add --no-cache zlib-dev libunwind clang lld || { + echo "โŒ Failed to install dependencies with apk" + exit 1 + } ;; *) echo "โš ๏ธ Unsupported OS: $ID. Please install dependencies manually." @@ -24,6 +45,12 @@ install_dependencies() { else echo "โš ๏ธ /etc/os-release not found. Cannot determine OS." fi + + echo "โœ… Dependency installation complete." + echo "๐Ÿ” Verifying installed tools..." + command -v clang && clang --version || echo "โŒ clang not found" + command -v gcc && gcc --version || echo "โŒ gcc not found" + command -v lld || echo "โŒ lld not found" } install_dependencies From 3b8329e99e308e90e7ebe742901a48fa3bf89056 Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Wed, 21 May 2025 02:47:55 -0700 Subject: [PATCH 26/30] update --- .vsts-ci.yml | 6 +-- .vsts-pr.yml | 4 +- build/RunTestsOnHelix.sh | 47 ++++++------------- .../templates/jobs/sdk-job-matrix.yml | 4 +- 4 files changed, 21 insertions(+), 40 deletions(-) diff --git a/.vsts-ci.yml b/.vsts-ci.yml index e02fd371273e..6ab58854063b 100644 --- a/.vsts-ci.yml +++ b/.vsts-ci.yml @@ -64,8 +64,8 @@ extends: template: v1/1ES.Official.PipelineTemplate.yml@1esPipelines parameters: containers: - alpine321Amd64: - image: mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.21-amd64 + alpine319WithNode: + image: mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.19-WithNode centosStream9: image: mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream9 debian12Amd64: @@ -242,7 +242,7 @@ extends: runTests: false ### MUSL ### - categoryName: Musl - container: alpine321Amd64 + container: alpine319WithNode runtimeIdentifier: linux-musl-x64 publishArgument: $(_publishArgument) officialBuildProperties: $(_officialBuildProperties) diff --git a/.vsts-pr.yml b/.vsts-pr.yml index c45c899a5c47..60d2d4f865f3 100644 --- a/.vsts-pr.yml +++ b/.vsts-pr.yml @@ -27,8 +27,8 @@ variables: resources: containers: - - container: alpine321Amd64 - image: mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.21-amd64 + - container: alpine319WithNode + image: mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.19-WithNode - container: centosStream9 image: mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream9 - container: debian12Amd64 diff --git a/build/RunTestsOnHelix.sh b/build/RunTestsOnHelix.sh index 4b22f4e19f15..d4cd866e74a6 100644 --- a/build/RunTestsOnHelix.sh +++ b/build/RunTestsOnHelix.sh @@ -1,60 +1,41 @@ #!/usr/bin/env bash install_dependencies() { - echo "๐Ÿ“ฆ Installing dependencies..." + echo "Installing dependencies..." if [ -f /etc/os-release ]; then - echo "๐Ÿ” Detected /etc/os-release" . /etc/os-release - echo "๐Ÿงพ OS Info: ID=$ID, VERSION_ID=$VERSION_ID, PRETTY_NAME=$PRETTY_NAME" + echo "Detected OS: $ID $VERSION_ID" case "$ID" in - ubuntu|debian) - echo "๐Ÿ“ฆ Using apt-get to install dependencies..." - sudo apt-get update - sudo apt-get install -y zlib1g-dev libunwind8 clang lld || { - echo "โŒ Failed to install dependencies with apt-get" - exit 1 - } - ;; centos|rhel) - echo "๐Ÿ“ฆ Using yum to install dependencies..." - sudo yum install -y zlib-devel libunwind clang lld || { - echo "โŒ Failed to install dependencies with yum" - exit 1 - } + sudo dnf install -y epel-release + sudo dnf config-manager --set-enabled crb + sudo dnf install -y zlib-devel clang lld libicu libunwind || exit 1 ;; fedora) - echo "๐Ÿ“ฆ Using dnf to install dependencies..." - sudo dnf install -y zlib-devel libunwind clang lld || { - echo "โŒ Failed to install dependencies with dnf" - exit 1 - } + sudo dnf install -y zlib-devel libunwind clang lld libicu || exit 1 ;; alpine) - echo "๐Ÿ“ฆ Using apk to install dependencies..." - sudo apk add --no-cache zlib-dev libunwind clang lld || { - echo "โŒ Failed to install dependencies with apk" - exit 1 - } + sudo apk add --no-cache zlib-dev libunwind libunwind-devel clang lld icu-libs || exit 1 ;; *) - echo "โš ๏ธ Unsupported OS: $ID. Please install dependencies manually." + echo "Unsupported OS: $ID. Please install dependencies manually." ;; esac else - echo "โš ๏ธ /etc/os-release not found. Cannot determine OS." + echo "/etc/os-release not found. Cannot determine OS." fi - echo "โœ… Dependency installation complete." - echo "๐Ÿ” Verifying installed tools..." - command -v clang && clang --version || echo "โŒ clang not found" - command -v gcc && gcc --version || echo "โŒ gcc not found" - command -v lld || echo "โŒ lld not found" + echo "Verifying installed tools..." + command -v clang && clang --version || echo "clang not found" + command -v gcc && gcc --version || echo "gcc not found" + command -v lld || echo "lld not found" } install_dependencies + export NUGET_ENABLE_EXPERIMENTAL_HTTP_RETRY=true export NUGET_EXPERIMENTAL_MAX_NETWORK_TRY_COUNT=6 export NUGET_EXPERIMENTAL_NETWORK_RETRY_DELAY_MILLISECONDS=1000 diff --git a/eng/pipelines/templates/jobs/sdk-job-matrix.yml b/eng/pipelines/templates/jobs/sdk-job-matrix.yml index 1773f43ad967..0e0824384317 100644 --- a/eng/pipelines/templates/jobs/sdk-job-matrix.yml +++ b/eng/pipelines/templates/jobs/sdk-job-matrix.yml @@ -49,8 +49,8 @@ parameters: osProperties: /p:OSName=linux /p:BuildSdkDeb=true runTests: true - categoryName: ContainerBased - container: alpine321Amd64 - helixTargetContainer: $(helixTargetContainerPrefix)alpine-3.21-helix-amd64 + container: alpine319WithNode + helixTargetContainer: $(helixTargetContainerPrefix)alpine-3.18-helix-amd64 runtimeIdentifier: linux-musl-x64 # Use HostOSName when running on alpine. osProperties: /p:HostOSName=linux-musl From b978376adeddcd2494c2d6f75dcaec4609b4b13a Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Thu, 22 May 2025 02:47:31 -0700 Subject: [PATCH 27/30] update --- build/RunTestsOnHelix.sh | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/build/RunTestsOnHelix.sh b/build/RunTestsOnHelix.sh index d4cd866e74a6..024b43cd33bf 100644 --- a/build/RunTestsOnHelix.sh +++ b/build/RunTestsOnHelix.sh @@ -9,28 +9,27 @@ install_dependencies() { case "$ID" in centos|rhel) - sudo dnf install -y epel-release - sudo dnf config-manager --set-enabled crb - sudo dnf install -y zlib-devel clang lld libicu libunwind || exit 1 + sudo dnf install -y epel-release || { echo "Failed to install epel-release"; exit 1; } + sudo dnf config-manager --set-enabled crb || { echo "Failed to enable CRB repository"; exit 1; } + sudo dnf install -y zlib-devel libunwind || { echo "Failed to install dependencies"; exit 1; } ;; fedora) - sudo dnf install -y zlib-devel libunwind clang lld libicu || exit 1 + sudo dnf install -y clang || { echo "Failed to install clang"; exit 1; } ;; alpine) - sudo apk add --no-cache zlib-dev libunwind libunwind-devel clang lld icu-libs || exit 1 + sudo apk add --no-cache clang || { echo "Failed to install clang"; exit 1; } ;; *) echo "Unsupported OS: $ID. Please install dependencies manually." + exit 1 ;; esac else echo "/etc/os-release not found. Cannot determine OS." + exit 1 fi - echo "Verifying installed tools..." - command -v clang && clang --version || echo "clang not found" - command -v gcc && gcc --version || echo "gcc not found" - command -v lld || echo "lld not found" + echo "Dependencies installation complete." } install_dependencies From a2968dee9690fc81301ab36e70ba565cda16121b Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Thu, 22 May 2025 03:08:37 -0700 Subject: [PATCH 28/30] update --- build/RunTestsOnHelix.sh | 37 +++-------------------------------- build/install_dependencies.sh | 37 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 34 deletions(-) create mode 100644 build/install_dependencies.sh diff --git a/build/RunTestsOnHelix.sh b/build/RunTestsOnHelix.sh index 024b43cd33bf..8585a1bec316 100644 --- a/build/RunTestsOnHelix.sh +++ b/build/RunTestsOnHelix.sh @@ -1,40 +1,9 @@ #!/usr/bin/env bash -install_dependencies() { - echo "Installing dependencies..." - - if [ -f /etc/os-release ]; then - . /etc/os-release - echo "Detected OS: $ID $VERSION_ID" - - case "$ID" in - centos|rhel) - sudo dnf install -y epel-release || { echo "Failed to install epel-release"; exit 1; } - sudo dnf config-manager --set-enabled crb || { echo "Failed to enable CRB repository"; exit 1; } - sudo dnf install -y zlib-devel libunwind || { echo "Failed to install dependencies"; exit 1; } - ;; - fedora) - sudo dnf install -y clang || { echo "Failed to install clang"; exit 1; } - ;; - alpine) - sudo apk add --no-cache clang || { echo "Failed to install clang"; exit 1; } - ;; - *) - echo "Unsupported OS: $ID. Please install dependencies manually." - exit 1 - ;; - esac - else - echo "/etc/os-release not found. Cannot determine OS." - exit 1 - fi - - echo "Dependencies installation complete." -} - -install_dependencies - +# This script prepares required dependencies for running .NET SDK tests on Helix. +source "$(dirname "$0")/install_dependencies.sh" +# make NuGet network operations more robust export NUGET_ENABLE_EXPERIMENTAL_HTTP_RETRY=true export NUGET_EXPERIMENTAL_MAX_NETWORK_TRY_COUNT=6 export NUGET_EXPERIMENTAL_NETWORK_RETRY_DELAY_MILLISECONDS=1000 diff --git a/build/install_dependencies.sh b/build/install_dependencies.sh new file mode 100644 index 000000000000..3d1ab787343c --- /dev/null +++ b/build/install_dependencies.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# In Helix test environments or containerized build environments, .NET SDK tests often fail due to missing system dependencies. +# This script automatically detects the operating system and installs the required dependencies to improve test stability and reduce issues caused by environment differences. + +install_dependencies() { + echo "Installing dependencies..." + + if [ -f /etc/os-release ]; then + . /etc/os-release + echo "Detected OS: $ID $VERSION_ID" + + case "$ID" in + centos|rhel) + sudo dnf install -y epel-release || { echo "Failed to install epel-release"; exit 1; } + sudo dnf config-manager --set-enabled crb || { echo "Failed to enable CRB repository"; exit 1; } + sudo dnf install -y zlib-devel libunwind || { echo "Failed to install dependencies"; exit 1; } + ;; + fedora) + sudo dnf install -y clang || { echo "Failed to install clang"; exit 1; } + ;; + alpine) + sudo apk add --no-cache clang || { echo "Failed to install clang"; exit 1; } + ;; + *) + echo "Unsupported OS: $ID. Please install dependencies manually." + exit 1 + ;; + esac + else + echo "/etc/os-release not found. Cannot determine OS." + exit 1 + fi + + echo "Dependencies installation complete." +} + +install_dependencies From e578d6c3f743bf6983fe3344ab3b283a7e74e8bc Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Thu, 22 May 2025 20:06:56 -0700 Subject: [PATCH 29/30] update --- build/RunTestsOnHelix.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/RunTestsOnHelix.sh b/build/RunTestsOnHelix.sh index 8585a1bec316..a010a5d644b8 100644 --- a/build/RunTestsOnHelix.sh +++ b/build/RunTestsOnHelix.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # This script prepares required dependencies for running .NET SDK tests on Helix. -source "$(dirname "$0")/install_dependencies.sh" +source ./install_dependencies.sh # make NuGet network operations more robust export NUGET_ENABLE_EXPERIMENTAL_HTTP_RETRY=true From 1d07ffad2db4235ed87fc2ab4a118ed6d0d923dc Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Thu, 22 May 2025 22:35:03 -0700 Subject: [PATCH 30/30] update --- build/RunTestsOnHelix.sh | 35 +++++++++++++++++++++++++++++++-- build/install_dependencies.sh | 37 ----------------------------------- 2 files changed, 33 insertions(+), 39 deletions(-) delete mode 100644 build/install_dependencies.sh diff --git a/build/RunTestsOnHelix.sh b/build/RunTestsOnHelix.sh index a010a5d644b8..18616577fce4 100644 --- a/build/RunTestsOnHelix.sh +++ b/build/RunTestsOnHelix.sh @@ -1,7 +1,38 @@ #!/usr/bin/env bash -# This script prepares required dependencies for running .NET SDK tests on Helix. -source ./install_dependencies.sh +install_dependencies() { + echo "Installing dependencies..." + + if [ -f /etc/os-release ]; then + . /etc/os-release + echo "Detected OS: $ID $VERSION_ID" + + case "$ID" in + centos|rhel) + sudo dnf install -y epel-release || { echo "Failed to install epel-release"; exit 1; } + sudo dnf config-manager --set-enabled crb || { echo "Failed to enable CRB repository"; exit 1; } + sudo dnf install -y zlib-devel libunwind || { echo "Failed to install dependencies"; exit 1; } + ;; + fedora) + sudo dnf install -y clang || { echo "Failed to install clang"; exit 1; } + ;; + alpine) + sudo apk add --no-cache clang || { echo "Failed to install clang"; exit 1; } + ;; + *) + echo "Unsupported OS: $ID. Please install dependencies manually." + exit 1 + ;; + esac + else + echo "/etc/os-release not found. Cannot determine OS." + exit 1 + fi + + echo "Dependencies installation complete." +} + +install_dependencies # make NuGet network operations more robust export NUGET_ENABLE_EXPERIMENTAL_HTTP_RETRY=true diff --git a/build/install_dependencies.sh b/build/install_dependencies.sh deleted file mode 100644 index 3d1ab787343c..000000000000 --- a/build/install_dependencies.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash -# In Helix test environments or containerized build environments, .NET SDK tests often fail due to missing system dependencies. -# This script automatically detects the operating system and installs the required dependencies to improve test stability and reduce issues caused by environment differences. - -install_dependencies() { - echo "Installing dependencies..." - - if [ -f /etc/os-release ]; then - . /etc/os-release - echo "Detected OS: $ID $VERSION_ID" - - case "$ID" in - centos|rhel) - sudo dnf install -y epel-release || { echo "Failed to install epel-release"; exit 1; } - sudo dnf config-manager --set-enabled crb || { echo "Failed to enable CRB repository"; exit 1; } - sudo dnf install -y zlib-devel libunwind || { echo "Failed to install dependencies"; exit 1; } - ;; - fedora) - sudo dnf install -y clang || { echo "Failed to install clang"; exit 1; } - ;; - alpine) - sudo apk add --no-cache clang || { echo "Failed to install clang"; exit 1; } - ;; - *) - echo "Unsupported OS: $ID. Please install dependencies manually." - exit 1 - ;; - esac - else - echo "/etc/os-release not found. Cannot determine OS." - exit 1 - fi - - echo "Dependencies installation complete." -} - -install_dependencies