Skip to content

Commit 3575679

Browse files
committed
Always use NuGet config during tests
1 parent 477c0aa commit 3575679

File tree

2 files changed

+8
-32
lines changed

2 files changed

+8
-32
lines changed

tests/Microsoft.DotNet.Docker.Tests/TestScenarios/TestDockerfile.cs

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ COPY NuGet.config .
4646
? DockerOS.Linux
4747
: DockerOS.Windows;
4848

49-
private static bool s_useNuGetConfig = Config.IsNightlyRepo || Config.IsInternal;
50-
5149
private static string[] s_commonArgs = [
5250
"sdk_image",
5351
"runtime_image",
@@ -132,30 +130,21 @@ COPY tests/ .
132130

133131
public static TestDockerfile GetBlazorWasmDockerfile(bool useWasmTools)
134132
{
135-
string nugetConfigFileOption = s_useNuGetConfig
136-
? "--configfile NuGet.config"
137-
: string.Empty;
138-
139133
StringBuilder buildStageBuilder = new(
140134
$"""
141135
FROM $sdk_image AS {TestDockerfile.BuildStageName}
142136
ARG InternalAccessToken
143137
ARG port
144138
EXPOSE $port
139+
{CopyNuGetConfigCommands}
145140
""");
146141

147-
if (s_useNuGetConfig)
148-
{
149-
buildStageBuilder.AppendLine();
150-
buildStageBuilder.AppendLine(CopyNuGetConfigCommands);
151-
}
152-
153142
if (useWasmTools)
154143
{
155144
buildStageBuilder.AppendLine();
156145
buildStageBuilder.AppendLine(
157146
$"""
158-
RUN dotnet workload install {nugetConfigFileOption} wasm-tools \
147+
RUN dotnet workload install --configfile NuGet.config wasm-tools \
159148
&& . /etc/os-release \
160149
&& case $ID in \
161150
alpine) apk add --no-cache python3 ;; \
@@ -210,17 +199,7 @@ ARG rid
210199
ARG InternalAccessToken
211200
ARG port
212201
EXPOSE $port
213-
""");
214-
215-
if (s_useNuGetConfig)
216-
{
217-
buildStageBuilder.AppendLine();
218-
buildStageBuilder.AppendLine(CopyNuGetConfigCommands);
219-
}
220-
221-
buildStageBuilder.AppendLine();
222-
buildStageBuilder.AppendLine(
223-
$"""
202+
{CopyNuGetConfigCommands}
224203
WORKDIR /source/app
225204
COPY app/*.csproj .
226205
RUN dotnet restore -r {FormatArg("rid")}

tests/Microsoft.DotNet.Docker.Tests/TestSolution.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,19 @@ private string CreateTestSolutionWithSdkImage(string solutionDir, string appType
5656
CreateProjectWithSdkImage("xunit", _testProjectDir, testProjectContainerName);
5757
File.Copy(Path.Combine(DockerHelper.TestArtifactsDir, "UnitTests.cs"), Path.Combine(_testProjectDir, "UnitTests.cs"));
5858

59-
string nuGetConfigFileName = string.Empty;
59+
string nuGetConfigFileName = "NuGet.config";
6060
if (Config.IsInternal)
6161
{
62-
nuGetConfigFileName = "NuGet.config.internal";
62+
nuGetConfigFileName += "NuGet.config.internal";
6363
}
6464
else if (Config.IsNightlyRepo)
6565
{
6666
nuGetConfigFileName = "NuGet.config.nightly";
6767
}
6868

69-
if (!string.IsNullOrEmpty(nuGetConfigFileName))
70-
{
71-
File.Copy(
72-
Path.Combine(DockerHelper.TestArtifactsDir, nuGetConfigFileName),
73-
Path.Combine(solutionDir, "NuGet.config"));
74-
}
69+
File.Copy(
70+
Path.Combine(DockerHelper.TestArtifactsDir, nuGetConfigFileName),
71+
Path.Combine(solutionDir, "NuGet.config"));
7572

7673
File.Copy(Path.Combine(DockerHelper.TestArtifactsDir, ".dockerignore"), Path.Combine(solutionDir, ".dockerignore"));
7774
}

0 commit comments

Comments
 (0)