From 3393b5747b74dd3b0e80cdaacadfab5bb084b15e Mon Sep 17 00:00:00 2001 From: Logan Bussell Date: Fri, 24 Oct 2025 12:45:12 -0700 Subject: [PATCH 1/3] Always use NuGet config during tests --- .../TestScenarios/TestDockerfile.cs | 27 +++---------------- .../TestSolution.cs | 13 ++++----- 2 files changed, 8 insertions(+), 32 deletions(-) diff --git a/tests/Microsoft.DotNet.Docker.Tests/TestScenarios/TestDockerfile.cs b/tests/Microsoft.DotNet.Docker.Tests/TestScenarios/TestDockerfile.cs index 57ae2944dd..7279c0a2b3 100644 --- a/tests/Microsoft.DotNet.Docker.Tests/TestScenarios/TestDockerfile.cs +++ b/tests/Microsoft.DotNet.Docker.Tests/TestScenarios/TestDockerfile.cs @@ -46,8 +46,6 @@ COPY NuGet.config . ? DockerOS.Linux : DockerOS.Windows; - private static bool s_useNuGetConfig = Config.IsNightlyRepo || Config.IsInternal; - private static string[] s_commonArgs = [ "sdk_image", "runtime_image", @@ -132,30 +130,21 @@ COPY tests/ . public static TestDockerfile GetBlazorWasmDockerfile(bool useWasmTools) { - string nugetConfigFileOption = s_useNuGetConfig - ? "--configfile NuGet.config" - : string.Empty; - StringBuilder buildStageBuilder = new( $""" FROM $sdk_image AS {TestDockerfile.BuildStageName} ARG InternalAccessToken ARG port EXPOSE $port + {CopyNuGetConfigCommands} """); - if (s_useNuGetConfig) - { - buildStageBuilder.AppendLine(); - buildStageBuilder.AppendLine(CopyNuGetConfigCommands); - } - if (useWasmTools) { buildStageBuilder.AppendLine(); buildStageBuilder.AppendLine( $""" - RUN dotnet workload install {nugetConfigFileOption} wasm-tools \ + RUN dotnet workload install --configfile NuGet.config wasm-tools \ && . /etc/os-release \ && case $ID in \ alpine) apk add --no-cache python3 ;; \ @@ -210,17 +199,7 @@ ARG rid ARG InternalAccessToken ARG port EXPOSE $port - """); - - if (s_useNuGetConfig) - { - buildStageBuilder.AppendLine(); - buildStageBuilder.AppendLine(CopyNuGetConfigCommands); - } - - buildStageBuilder.AppendLine(); - buildStageBuilder.AppendLine( - $""" + {CopyNuGetConfigCommands} WORKDIR /source/app COPY app/*.csproj . RUN dotnet restore -r {FormatArg("rid")} diff --git a/tests/Microsoft.DotNet.Docker.Tests/TestSolution.cs b/tests/Microsoft.DotNet.Docker.Tests/TestSolution.cs index f83b1e18ba..b50cc4c669 100644 --- a/tests/Microsoft.DotNet.Docker.Tests/TestSolution.cs +++ b/tests/Microsoft.DotNet.Docker.Tests/TestSolution.cs @@ -56,22 +56,19 @@ private string CreateTestSolutionWithSdkImage(string solutionDir, string appType CreateProjectWithSdkImage("xunit", _testProjectDir, testProjectContainerName); File.Copy(Path.Combine(DockerHelper.TestArtifactsDir, "UnitTests.cs"), Path.Combine(_testProjectDir, "UnitTests.cs")); - string nuGetConfigFileName = string.Empty; + string nuGetConfigFileName = "NuGet.config"; if (Config.IsInternal) { - nuGetConfigFileName = "NuGet.config.internal"; + nuGetConfigFileName += "NuGet.config.internal"; } else if (Config.IsNightlyRepo) { nuGetConfigFileName = "NuGet.config.nightly"; } - if (!string.IsNullOrEmpty(nuGetConfigFileName)) - { - File.Copy( - Path.Combine(DockerHelper.TestArtifactsDir, nuGetConfigFileName), - Path.Combine(solutionDir, "NuGet.config")); - } + File.Copy( + Path.Combine(DockerHelper.TestArtifactsDir, nuGetConfigFileName), + Path.Combine(solutionDir, "NuGet.config")); File.Copy(Path.Combine(DockerHelper.TestArtifactsDir, ".dockerignore"), Path.Combine(solutionDir, ".dockerignore")); } From f23a64fcc2b45019567be39136b98bf5061a3405 Mon Sep 17 00:00:00 2001 From: Logan Bussell Date: Fri, 24 Oct 2025 14:06:15 -0700 Subject: [PATCH 2/3] Update test NuGet.config for main branch --- .../TestAppArtifacts/NuGet.config | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/Microsoft.DotNet.Docker.Tests/TestAppArtifacts/NuGet.config b/tests/Microsoft.DotNet.Docker.Tests/TestAppArtifacts/NuGet.config index 5dae513501..bff97919cb 100644 --- a/tests/Microsoft.DotNet.Docker.Tests/TestAppArtifacts/NuGet.config +++ b/tests/Microsoft.DotNet.Docker.Tests/TestAppArtifacts/NuGet.config @@ -1,2 +1,7 @@ - + + + + + + From a3c89ac4ee0d49f9122c6dbc5ec37c15a63a016a Mon Sep 17 00:00:00 2001 From: Logan Bussell Date: Tue, 28 Oct 2025 12:56:11 -0700 Subject: [PATCH 3/3] Correct internal NuGet config filename computation --- tests/Microsoft.DotNet.Docker.Tests/TestSolution.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Microsoft.DotNet.Docker.Tests/TestSolution.cs b/tests/Microsoft.DotNet.Docker.Tests/TestSolution.cs index b50cc4c669..0125aa300a 100644 --- a/tests/Microsoft.DotNet.Docker.Tests/TestSolution.cs +++ b/tests/Microsoft.DotNet.Docker.Tests/TestSolution.cs @@ -59,7 +59,7 @@ private string CreateTestSolutionWithSdkImage(string solutionDir, string appType string nuGetConfigFileName = "NuGet.config"; if (Config.IsInternal) { - nuGetConfigFileName += "NuGet.config.internal"; + nuGetConfigFileName = "NuGet.config.internal"; } else if (Config.IsNightlyRepo) {