diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildACppCliProject.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildACppCliProject.cs index b929f6c33ffd..e1c4156ae6bd 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildACppCliProject.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildACppCliProject.cs @@ -256,7 +256,7 @@ private void RecordProperties(string projectPath, XDocument project, string[] pr } } - public Dictionary GetPropertyValues(string testRoot, string project, string configuration = "Debug", string targetFramework = null) + public Dictionary GetPropertyValues(string testRoot, string project, string targetFramework = null, string configuration = "Debug") { var propertyValues = new Dictionary(); diff --git a/src/Tests/Microsoft.NET.Sdk.Web.Tests/PublishTests.cs b/src/Tests/Microsoft.NET.Sdk.Web.Tests/PublishTests.cs index 65925ac057d2..b1216aee1719 100644 --- a/src/Tests/Microsoft.NET.Sdk.Web.Tests/PublishTests.cs +++ b/src/Tests/Microsoft.NET.Sdk.Web.Tests/PublishTests.cs @@ -20,7 +20,7 @@ public PublishTests(ITestOutputHelper log) : base(log) { } - [Theory()] + [Theory] [MemberData(nameof(SupportedTfms))] public void TrimmingOptions_Are_Defaulted_Correctly_On_Trimmed_Apps(string targetFramework) { @@ -29,11 +29,16 @@ public void TrimmingOptions_Are_Defaulted_Correctly_On_Trimmed_Apps(string targe var testProject = CreateTestProjectForILLinkTesting(targetFramework, projectName); testProject.AdditionalProperties["PublishTrimmed"] = "true"; + testProject.AdditionalProperties["RuntimeIdentifier"] = rid; + testProject.PropertiesToRecord.Add("TrimMode"); var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: projectName + targetFramework); var publishCommand = new PublishCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name)); - publishCommand.Execute($"/p:RuntimeIdentifier={rid}").Should().Pass(); + publishCommand.Execute().Should().Pass(); + + var buildProperties = testProject.GetPropertyValues(testAsset.TestRoot, targetFramework); + buildProperties["TrimMode"].Should().Be("partial"); string outputDirectory = publishCommand.GetOutputDirectory(targetFramework: targetFramework, runtimeIdentifier: rid).FullName; string runtimeConfigFile = Path.Combine(outputDirectory, $"{projectName}.runtimeconfig.json"); @@ -46,7 +51,7 @@ public void TrimmingOptions_Are_Defaulted_Correctly_On_Trimmed_Apps(string targe .Should().BeTrue(); } - [Theory()] + [Theory] [MemberData(nameof(SupportedTfms))] public void TrimmingOptions_Are_Defaulted_Correctly_On_Aot_Apps(string targetFramework) { @@ -55,16 +60,26 @@ public void TrimmingOptions_Are_Defaulted_Correctly_On_Aot_Apps(string targetFra var testProject = CreateTestProjectForILLinkTesting(targetFramework, projectName); testProject.AdditionalProperties["PublishAOT"] = "true"; + testProject.AdditionalProperties["RuntimeIdentifier"] = rid; + testProject.PropertiesToRecord.Add("PublishTrimmed"); + testProject.PropertiesToRecord.Add("TrimMode"); + testProject.PropertiesToRecord.Add("PublishIISAssets"); var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: projectName + targetFramework); var publishCommand = new PublishCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name)); - publishCommand.Execute($"/p:RuntimeIdentifier={rid}").Should().Pass(); + publishCommand.Execute().Should().Pass(); + + var buildProperties = testProject.GetPropertyValues(testAsset.TestRoot, targetFramework); + buildProperties["PublishTrimmed"].Should().Be("true"); + buildProperties["TrimMode"].Should().Be(""); + buildProperties["PublishIISAssets"].Should().Be("false"); - string outputDirectory = publishCommand.GetIntermediateDirectory(targetFramework: targetFramework, runtimeIdentifier: rid).FullName; + string outputDirectory = publishCommand.GetIntermediateDirectory(targetFramework, runtimeIdentifier: rid).FullName; string responseFile = Path.Combine(outputDirectory, "native", $"{projectName}.ilc.rsp"); var responseFileContents = File.ReadLines(responseFile); responseFileContents.Should().Contain("--feature:Microsoft.AspNetCore.EnsureJsonTrimmability=true"); + File.Exists(Path.Combine(outputDirectory, "web.config")).Should().BeFalse(); } public static IEnumerable SupportedTfms { get; } = new List diff --git a/src/Tests/Microsoft.NET.TestFramework/ProjectConstruction/TestProject.cs b/src/Tests/Microsoft.NET.TestFramework/ProjectConstruction/TestProject.cs index bb2cc00c4141..11d978947895 100644 --- a/src/Tests/Microsoft.NET.TestFramework/ProjectConstruction/TestProject.cs +++ b/src/Tests/Microsoft.NET.TestFramework/ProjectConstruction/TestProject.cs @@ -474,7 +474,7 @@ public void RecordProperties(params string[] propertyNames) /// A dictionary of property keys to property value strings, case sensitive. /// Only properties added to the member will be observed. /// - public Dictionary GetPropertyValues(string testRoot, string configuration = "Debug", string targetFramework = null) + public Dictionary GetPropertyValues(string testRoot, string targetFramework = null, string configuration = "Debug") { var propertyValues = new Dictionary(); diff --git a/src/WebSdk/Publish/Targets/Microsoft.NET.Sdk.Publish.targets b/src/WebSdk/Publish/Targets/Microsoft.NET.Sdk.Publish.targets index 24a4350b5126..2b073e3ea42b 100644 --- a/src/WebSdk/Publish/Targets/Microsoft.NET.Sdk.Publish.targets +++ b/src/WebSdk/Publish/Targets/Microsoft.NET.Sdk.Publish.targets @@ -36,6 +36,7 @@ Copyright (C) Microsoft Corporation. All rights reserved. And '$(RuntimeIdentifier)' != '' And !$(RuntimeIdentifier.StartsWith('win')) And '$(PublishIISAssets)' == ''">false + false @@ -87,7 +88,8 @@ Copyright (C) Microsoft Corporation. All rights reserved. EFSQLScripts - partial + + partial