From 1d3413654c734b2ae8d52c433d49fd4ad0840c71 Mon Sep 17 00:00:00 2001 From: Marc Paine Date: Wed, 10 May 2023 14:55:29 -0700 Subject: [PATCH] Update the publish tests to handle both self contained and not Update the publish tests to target current and net6 Fix the selfcontained logic in the common test method --- test/EndToEnd/ProjectBuildTests.cs | 42 +++++++++++++++++++----------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/test/EndToEnd/ProjectBuildTests.cs b/test/EndToEnd/ProjectBuildTests.cs index dfb829dbb..e134a102d 100644 --- a/test/EndToEnd/ProjectBuildTests.cs +++ b/test/EndToEnd/ProjectBuildTests.cs @@ -86,9 +86,11 @@ namespace EndToEnd.Tests } [WindowsOnlyTheory] - [InlineData("net5.0")] - [InlineData("current")] - public void ItCanPublishArm64Winforms(string TargetFramework) + [InlineData("net6.0", true)] + [InlineData("net6.0", false)] + [InlineData("current", true)] + [InlineData("current", false)] + public void ItCanPublishArm64Winforms(string TargetFramework, bool selfContained) { DirectoryInfo directory = TestAssets.CreateTestDirectory(); string projectDirectory = directory.FullName; @@ -104,7 +106,8 @@ namespace EndToEnd.Tests .Execute(newArgs) .Should().Pass(); - string publishArgs = "-r win-arm64"; + string selfContainedArgs = selfContained ? " --self-contained" : ""; + string publishArgs = "-r win-arm64" + selfContainedArgs; new PublishCommand() .WithWorkingDirectory(projectDirectory) .Execute(publishArgs) @@ -114,14 +117,19 @@ namespace EndToEnd.Tests .Sub("bin").Sub(TargetFramework != "current" ? "Debug" : "Release").GetDirectories().FirstOrDefault() .Sub("win-arm64").Sub("publish"); - selfContainedPublishDir.Should().HaveFilesMatching("System.Windows.Forms.dll", SearchOption.TopDirectoryOnly); + if (selfContained) + { + selfContainedPublishDir.Should().HaveFilesMatching("System.Windows.Forms.dll", SearchOption.TopDirectoryOnly); + } selfContainedPublishDir.Should().HaveFilesMatching($"{directory.Name}.dll", SearchOption.TopDirectoryOnly); } [WindowsOnlyTheory] - [InlineData("net5.0")] - [InlineData("current")] - public void ItCanPublishArm64Wpf(string TargetFramework) + [InlineData("net6.0", true)] + [InlineData("net6.0", false)] + [InlineData("current", true)] + [InlineData("current", false)] + public void ItCanPublishArm64Wpf(string TargetFramework, bool selfContained) { DirectoryInfo directory = TestAssets.CreateTestDirectory(); string projectDirectory = directory.FullName; @@ -138,7 +146,8 @@ namespace EndToEnd.Tests .Execute(newArgs) .Should().Pass(); - string publishArgs = "-r win-arm64"; + string selfContainedArgs = selfContained ? " --self-contained" : ""; + string publishArgs = "-r win-arm64" + selfContainedArgs; new PublishCommand() .WithWorkingDirectory(projectDirectory) .Execute(publishArgs) @@ -148,8 +157,11 @@ namespace EndToEnd.Tests .Sub("bin").Sub(TargetFramework != "current" ? "Debug" : "Release").GetDirectories().FirstOrDefault() .Sub("win-arm64").Sub("publish"); - selfContainedPublishDir.Should().HaveFilesMatching("PresentationCore.dll", SearchOption.TopDirectoryOnly); - selfContainedPublishDir.Should().HaveFilesMatching("PresentationNative_*.dll", SearchOption.TopDirectoryOnly); + if (selfContained) + { + selfContainedPublishDir.Should().HaveFilesMatching("PresentationCore.dll", SearchOption.TopDirectoryOnly); + selfContainedPublishDir.Should().HaveFilesMatching("PresentationNative_*.dll", SearchOption.TopDirectoryOnly); + } selfContainedPublishDir.Should().HaveFilesMatching($"{directory.Name}.dll", SearchOption.TopDirectoryOnly); } @@ -296,7 +308,7 @@ namespace EndToEnd.Tests [InlineData("wpf")] public void ItCanBuildDesktopTemplatesSelfContained(string templateName) { - TestTemplateCreateAndBuild(templateName); + TestTemplateCreateAndBuild(templateName, selfContained: true); } [Theory] @@ -351,7 +363,7 @@ namespace EndToEnd.Tests public void ItCanCreateAndBuildTemplatesWithDefaultFramework(string templateName, string language = "") { string framework = DetectExpectedDefaultFramework(templateName); - TestTemplateCreateAndBuild(templateName, selfContained: true, language: language, framework: framework); + TestTemplateCreateAndBuild(templateName, selfContained: false, language: language, framework: framework); } /// @@ -398,7 +410,7 @@ namespace EndToEnd.Tests public void ItCanCreateAndBuildTemplatesWithDefaultFramework_Windows(string templateName, string language = "") { string framework = DetectExpectedDefaultFramework(templateName); - TestTemplateCreateAndBuild(templateName, selfContained: true, language: language, framework: $"{framework}-windows"); + TestTemplateCreateAndBuild(templateName, selfContained: false, language: language, framework: $"{framework}-windows"); } /// @@ -459,7 +471,7 @@ namespace EndToEnd.Tests if (build) { - string buildArgs = selfContained ? "" : $"-r {RuntimeInformation.RuntimeIdentifier}"; + string buildArgs = selfContained ? $"-r {RuntimeInformation.RuntimeIdentifier} --self-contained" : ""; if (!string.IsNullOrWhiteSpace(framework)) { buildArgs += $" --framework {framework}";