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 @@ - + + + + + + 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..0125aa300a 100644 --- a/tests/Microsoft.DotNet.Docker.Tests/TestSolution.cs +++ b/tests/Microsoft.DotNet.Docker.Tests/TestSolution.cs @@ -56,7 +56,7 @@ 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"; @@ -66,12 +66,9 @@ private string CreateTestSolutionWithSdkImage(string solutionDir, string appType 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")); }