Skip to content

Commit e1cd792

Browse files
committed
tests and versions amendments
1 parent aa997d8 commit e1cd792

File tree

3 files changed

+16
-21
lines changed

3 files changed

+16
-21
lines changed

src/Containers/packaging/build/Microsoft.NET.Build.Containers.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<!-- A flag representing this package existing in a project. -->
44
<SDKContainerSupportEnabled>true</SDKContainerSupportEnabled>
55
<ContainerTaskFolderName>tasks</ContainerTaskFolderName>
6-
<ContainerTaskFramework Condition="'$(MSBuildRuntimeType)' == 'Core'">net7.0</ContainerTaskFramework>
6+
<ContainerTaskFramework Condition="'$(MSBuildRuntimeType)' == 'Core'">net8.0</ContainerTaskFramework>
77
<ContainerTaskFramework Condition="'$(MSBuildRuntimeType)' == 'Full'">net472</ContainerTaskFramework>
88
<ContainerizeFolderName>containerize</ContainerizeFolderName>
99
<!--The folder where the custom task will be present. It points to inside the nuget package. -->

src/Tests/Microsoft.NET.Build.Containers.IntegrationTests/CreateNewImageTests.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Microsoft.NET.Build.Containers.UnitTests;
1010
using Microsoft.NET.TestFramework.Assertions;
1111
using Microsoft.NET.TestFramework.Commands;
12+
using Microsoft.NET.TestFramework;
1213

1314
namespace Microsoft.NET.Build.Containers.Tasks.IntegrationTests;
1415

@@ -34,7 +35,7 @@ public void CreateNewImage_Baseline()
3435

3536
newProjectDir.Create();
3637

37-
new DotnetCommand(_testOutput, "new", "console", "-f", "net8.0")
38+
new DotnetCommand(_testOutput, "new", "console", "-f", ToolsetInfo.CurrentTargetFramework)
3839
.WithWorkingDirectory(newProjectDir.FullName)
3940
.Execute()
4041
.Should().Pass();
@@ -50,7 +51,7 @@ public void CreateNewImage_Baseline()
5051
task.BaseImageTag = "7.0";
5152

5253
task.OutputRegistry = "localhost:5010";
53-
task.PublishDirectory = Path.Combine(newProjectDir.FullName, "bin", "Release", "net7.0", "linux-arm64", "publish");
54+
task.PublishDirectory = Path.Combine(newProjectDir.FullName, "bin", "Release", ToolsetInfo.CurrentTargetFramework, "linux-arm64", "publish");
5455
task.ImageName = "dotnet/testimage";
5556
task.ImageTags = new[] { "latest" };
5657
task.WorkingDirectory = "app/";
@@ -74,7 +75,7 @@ public void ParseContainerProperties_EndToEnd()
7475

7576
newProjectDir.Create();
7677

77-
new DotnetCommand(_testOutput, "new", "console", "-f", "net8.0")
78+
new DotnetCommand(_testOutput, "new", "console", "-f", ToolsetInfo.CurrentTargetFramework)
7879
.WithWorkingDirectory(newProjectDir.FullName)
7980
.Execute()
8081
.Should().Pass();
@@ -104,7 +105,7 @@ public void ParseContainerProperties_EndToEnd()
104105
cni.BaseImageTag = pcp.ParsedContainerTag;
105106
cni.ImageName = pcp.NewContainerImageName;
106107
cni.OutputRegistry = "localhost:5010";
107-
cni.PublishDirectory = Path.Combine(newProjectDir.FullName, "bin", "release", "net7.0");
108+
cni.PublishDirectory = Path.Combine(newProjectDir.FullName, "bin", "release", ToolsetInfo.CurrentTargetFramework);
108109
cni.WorkingDirectory = "app/";
109110
cni.Entrypoint = new TaskItem[] { new("ParseContainerProperties_EndToEnd") };
110111
cni.ImageTags = pcp.NewContainerTags;
@@ -130,7 +131,7 @@ public void Tasks_EndToEnd_With_EnvironmentVariable_Validation()
130131

131132
newProjectDir.Create();
132133

133-
new DotnetCommand(_testOutput, "new", "console", "-f", "net8.0")
134+
new DotnetCommand(_testOutput, "new", "console", "-f", ToolsetInfo.CurrentTargetFramework)
134135
.WithWorkingDirectory(newProjectDir.FullName)
135136
.Execute()
136137
.Should().Pass();
@@ -169,7 +170,7 @@ public void Tasks_EndToEnd_With_EnvironmentVariable_Validation()
169170
cni.BaseImageTag = pcp.ParsedContainerTag;
170171
cni.ImageName = pcp.NewContainerImageName;
171172
cni.OutputRegistry = pcp.NewContainerRegistry;
172-
cni.PublishDirectory = Path.Combine(newProjectDir.FullName, "bin", "release", "net7.0", "linux-x64");
173+
cni.PublishDirectory = Path.Combine(newProjectDir.FullName, "bin", "release", ToolsetInfo.CurrentTargetFramework, "linux-x64");
173174
cni.WorkingDirectory = "/app";
174175
cni.Entrypoint = new TaskItem[] { new("/app/Tasks_EndToEnd_With_EnvironmentVariable_Validation") };
175176
cni.ImageTags = pcp.NewContainerTags;

src/Tests/Microsoft.NET.Build.Containers.IntegrationTests/EndToEndTests.cs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ private string BuildLocalApp([CallerMemberName] string testName = "TestName", st
131131
.Execute()
132132
.Should().Pass();
133133

134-
new DotnetCommand(_testOutput, "publish", "-bl", "MinimalTestApp", "-r", rid, "-f", tfm)
134+
new DotnetCommand(_testOutput, "publish", "-bl", "MinimalTestApp", "-r", rid, "-f", tfm, "-c", "Debug")
135135
.WithWorkingDirectory(workingDirectory)
136136
.Execute()
137137
.Should().Pass();
@@ -141,11 +141,12 @@ private string BuildLocalApp([CallerMemberName] string testName = "TestName", st
141141
}
142142

143143
[DockerDaemonAvailableTheory]
144-
[InlineData(false)]
144+
//ignored until is in: https://github.com/dotnet/sdk/pull/31488 to avoid adding Microsoft.NET.Build.Containers v0.4.0 to feeds
145+
//[InlineData(false)]
145146
[InlineData(true)]
146147
public async Task EndToEnd_NoAPI_Web(bool addPackageReference)
147148
{
148-
DirectoryInfo newProjectDir = new DirectoryInfo(Path.Combine(TestSettings.TestArtifactsDirectory, "CreateNewImageTest"));
149+
DirectoryInfo newProjectDir = new DirectoryInfo(Path.Combine(TestSettings.TestArtifactsDirectory, $"CreateNewImageTest_{addPackageReference}"));
149150
DirectoryInfo privateNuGetAssets = new DirectoryInfo(Path.Combine(TestSettings.TestArtifactsDirectory, "ContainerNuGet"));
150151

151152
if (newProjectDir.Exists)
@@ -182,10 +183,7 @@ public async Task EndToEnd_NoAPI_Web(bool addPackageReference)
182183

183184
if (addPackageReference)
184185
{
185-
new DotnetCommand(_testOutput, "new", "nugetconfig")
186-
.WithWorkingDirectory(newProjectDir.FullName)
187-
.Execute()
188-
.Should().Pass();
186+
File.Copy(Path.Combine(TestContext.Current.TestExecutionDirectory, "NuGet.config"), Path.Combine(newProjectDir.FullName, "NuGet.config"));
189187

190188
new DotnetCommand(_testOutput, "nuget", "add", "source", packagedir.FullName, "--name", "local-temp")
191189
.WithEnvironmentVariable("NUGET_PACKAGES", privateNuGetAssets.FullName)
@@ -194,7 +192,7 @@ public async Task EndToEnd_NoAPI_Web(bool addPackageReference)
194192
.Should().Pass();
195193

196194
// Add package to the project
197-
new DotnetCommand(_testOutput, "add", "package", "Microsoft.NET.Build.Containers", "--prerelease", "-f", ToolsetInfo.CurrentTargetFramework)
195+
new DotnetCommand(_testOutput, "add", "package", "Microsoft.NET.Build.Containers", "-f", ToolsetInfo.CurrentTargetFramework, "-v", TestContext.Current.ToolsetUnderTest.SdkVersion)
198196
.WithEnvironmentVariable("NUGET_PACKAGES", privateNuGetAssets.FullName)
199197
.WithWorkingDirectory(newProjectDir.FullName)
200198
.Execute()
@@ -318,18 +316,14 @@ public void EndToEnd_NoAPI_Console()
318316
Assert.Fail("No nupkg found in expected package folder. You may need to rerun the build");
319317
}
320318

321-
322319
new DotnetCommand(_testOutput, "new", "console", "-f", ToolsetInfo.CurrentTargetFramework)
323320
.WithWorkingDirectory(newProjectDir.FullName)
324321
// do not pollute the primary/global NuGet package store with the private package(s)
325322
.WithEnvironmentVariable("NUGET_PACKAGES", privateNuGetAssets.FullName)
326323
.Execute()
327324
.Should().Pass();
328325

329-
new DotnetCommand(_testOutput, "new", "nugetconfig")
330-
.WithWorkingDirectory(newProjectDir.FullName)
331-
.Execute()
332-
.Should().Pass();
326+
File.Copy(Path.Combine(TestContext.Current.TestExecutionDirectory, "NuGet.config"), Path.Combine(newProjectDir.FullName, "NuGet.config"));
333327

334328
new DotnetCommand(_testOutput, "nuget", "add", "source", packagedir.FullName, "--name", "local-temp")
335329
.WithEnvironmentVariable("NUGET_PACKAGES", privateNuGetAssets.FullName)
@@ -338,7 +332,7 @@ public void EndToEnd_NoAPI_Console()
338332
.Should().Pass();
339333

340334
// Add package to the project
341-
new DotnetCommand(_testOutput, "add", "package", "Microsoft.NET.Build.Containers", "--prerelease", "-f", ToolsetInfo.CurrentTargetFramework)
335+
new DotnetCommand(_testOutput, "add", "package", "Microsoft.NET.Build.Containers", "-f", ToolsetInfo.CurrentTargetFramework, "-v", TestContext.Current.ToolsetUnderTest.SdkVersion)
342336
.WithEnvironmentVariable("NUGET_PACKAGES", privateNuGetAssets.FullName)
343337
.WithWorkingDirectory(newProjectDir.FullName)
344338
.Execute()

0 commit comments

Comments
 (0)