diff --git a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAnAotApp.cs b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAnAotApp.cs index f4a88b1db5f8..a9ded850e964 100644 --- a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAnAotApp.cs +++ b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAnAotApp.cs @@ -272,7 +272,7 @@ public void NativeAot_hw_runs_with_PackageReference_PublishAot_is_enabled(string testProject.AdditionalProperties["PublishAot"] = "true"; // This will add a reference to a package that will also be automatically imported by the SDK - testProject.PackageReferences.Add(new TestPackageReference("Microsoft.DotNet.ILCompiler", "7.0.0-rc.1.22416.1")); + testProject.PackageReferences.Add(new TestPackageReference("Microsoft.DotNet.ILCompiler", "7.0.0-rc.2.22456.11")); // Linux symbol files are embedded and require additional steps to be stripped to a separate file // assumes /bin (or /usr/bin) are in the PATH @@ -285,12 +285,10 @@ public void NativeAot_hw_runs_with_PackageReference_PublishAot_is_enabled(string var publishCommand = new PublishCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name)); publishCommand .Execute($"/p:RuntimeIdentifier={rid}") - .Should().Pass(); + .Should().Pass() // Having an explicit package reference will generate a warning - // Comment back after the below issue is fixed - // https://github.com/dotnet/sdk/issues/27533 - //.And.HaveStdOutContaining("warning") - //.And.HaveStdOutContaining("Microsoft.DotNet.ILCompiler"); + .And.HaveStdOutContaining("warning") + .And.HaveStdOutContaining("Microsoft.DotNet.ILCompiler"); var publishDirectory = publishCommand.GetOutputDirectory(targetFramework: targetFramework, runtimeIdentifier: rid).FullName; var sharedLibSuffix = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".dll" : ".so"; @@ -324,7 +322,7 @@ public void NativeAot_hw_runs_with_PackageReference_PublishAot_is_empty(string t var testProject = CreateHelloWorldTestProject(targetFramework, projectName, true); // This will add a reference to a package that will also be automatically imported by the SDK - testProject.PackageReferences.Add(new TestPackageReference("Microsoft.DotNet.ILCompiler", "7.0.0-rc.1.22416.1")); + testProject.PackageReferences.Add(new TestPackageReference("Microsoft.DotNet.ILCompiler", "7.0.0-rc.2.22456.11")); // Linux symbol files are embedded and require additional steps to be stripped to a separate file // assumes /bin (or /usr/bin) are in the PATH @@ -344,9 +342,7 @@ public void NativeAot_hw_runs_with_PackageReference_PublishAot_is_empty(string t var publishedExe = Path.Combine(publishDirectory, $"{testProject.Name}{Constants.ExeSuffix}"); // Not setting PublishAot to true will be a normal publish - // Comment back after the below issue is fixed - // https://github.com/dotnet/sdk/issues/27533 - // File.Exists(publishedDll).Should().BeTrue(); + File.Exists(publishedDll).Should().BeTrue(); var command = new RunExeCommand(Log, publishedExe) .Execute().Should().Pass() @@ -395,20 +391,18 @@ public void NativeAot_hw_runs_with_cross_PackageReference_PublishAot_is_enabled( testProject.AdditionalProperties["PublishAot"] = "true"; // This will add a reference to a package that will also be automatically imported by the SDK - testProject.PackageReferences.Add(new TestPackageReference("Microsoft.DotNet.ILCompiler", "7.0.0-rc.1.22416.1")); - testProject.PackageReferences.Add(new TestPackageReference("runtime.win-x64.Microsoft.DotNet.ILCompiler", "7.0.0-rc.1.22416.1")); + testProject.PackageReferences.Add(new TestPackageReference("Microsoft.DotNet.ILCompiler", "7.0.0-rc.2.22456.11")); + testProject.PackageReferences.Add(new TestPackageReference("runtime.win-x64.Microsoft.DotNet.ILCompiler", "7.0.0-rc.2.22456.11")); var testAsset = _testAssetsManager.CreateTestProject(testProject); var publishCommand = new PublishCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name)); publishCommand .Execute($"/p:RuntimeIdentifier={rid}") - .Should().Pass(); + .Should().Pass() // Having an explicit package reference will generate a warning - // Comment back after the below issue is fixed - // https://github.com/dotnet/sdk/issues/27533 - //.And.HaveStdOutContaining("warning") - //.And.HaveStdOutContaining("Microsoft.DotNet.ILCompiler"); + .And.HaveStdOutContaining("warning") + .And.HaveStdOutContaining("Microsoft.DotNet.ILCompiler"); var publishDirectory = publishCommand.GetOutputDirectory(targetFramework: targetFramework, runtimeIdentifier: rid).FullName; var publishedDll = Path.Combine(publishDirectory, $"{projectName}.dll"); @@ -430,8 +424,8 @@ public void NativeAot_hw_runs_with_cross_PackageReference_PublishAot_is_empty(st var testProject = CreateHelloWorldTestProject(targetFramework, projectName, true); // This will add a reference to a package that will also be automatically imported by the SDK - testProject.PackageReferences.Add(new TestPackageReference("Microsoft.DotNet.ILCompiler", "7.0.0-rc.1.22416.1")); - testProject.PackageReferences.Add(new TestPackageReference("runtime.win-x64.Microsoft.DotNet.ILCompiler", "7.0.0-rc.1.22416.1")); + testProject.PackageReferences.Add(new TestPackageReference("Microsoft.DotNet.ILCompiler", "7.0.0-rc.2.22456.11")); + testProject.PackageReferences.Add(new TestPackageReference("runtime.win-x64.Microsoft.DotNet.ILCompiler", "7.0.0-rc.2.22456.11")); var testAsset = _testAssetsManager.CreateTestProject(testProject); @@ -441,12 +435,56 @@ public void NativeAot_hw_runs_with_cross_PackageReference_PublishAot_is_empty(st .Should().Pass(); // Not setting PublishAot to true will be a normal publish - // Comment back after the below issue is fixed - // https://github.com/dotnet/sdk/issues/27533 var publishDirectory = publishCommand.GetOutputDirectory(targetFramework: targetFramework, runtimeIdentifier: rid).FullName; var publishedDll = Path.Combine(publishDirectory, $"{projectName}.dll"); - // File.Exists(publishedDll).Should().BeTrue(); + File.Exists(publishedDll).Should().BeTrue(); + + } + } + + [RequiresMSBuildVersionTheory("17.0.0.32901")] + [InlineData(ToolsetInfo.CurrentTargetFramework)] + public void NativeAot_hw_fails_with_sdk6_PublishAot_is_enabled(string targetFramework) + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + var projectName = "HellowWorldNativeAotApp"; + var rid = EnvironmentInfo.GetCompatibleRid(targetFramework); + var testProject = CreateHelloWorldTestProject("net6.0", projectName, true); + testProject.AdditionalProperties["PublishAot"] = "true"; + + var testAsset = _testAssetsManager.CreateTestProject(testProject); + + var publishCommand = new PublishCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name)); + publishCommand + .Execute($"/p:RuntimeIdentifier={rid}") + .Should().Fail() + .And.HaveStdOutContaining("error NETSDK1183:"); + } + } + + [RequiresMSBuildVersionTheory("17.0.0.32901")] + [InlineData(ToolsetInfo.CurrentTargetFramework)] + public void NativeAot_hw_fails_with_sdk6_PackageReference_PublishAot_is_enabled(string targetFramework) + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + var projectName = "HellowWorldNativeAotApp"; + var rid = EnvironmentInfo.GetCompatibleRid(targetFramework); + + var testProject = CreateHelloWorldTestProject("net6.0", projectName, true); + testProject.AdditionalProperties["PublishAot"] = "true"; + + testProject.PackageReferences.Add(new TestPackageReference("Microsoft.DotNet.ILCompiler", "7.0.0-rc.2.22456.11")); + + var testAsset = _testAssetsManager.CreateTestProject(testProject); + + var publishCommand = new PublishCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name)); + publishCommand + .Execute($"/p:RuntimeIdentifier={rid}") + .Should().Fail() + .And.HaveStdOutContaining("error NETSDK1183:"); } }