Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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";
Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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");
Expand All @@ -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);

Expand All @@ -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:");
}
}

Expand Down