Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/Assets/TestProjects/KitchenSink/TestApp/TestApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<NullabilityInfoContextSupport>false</NullabilityInfoContextSupport>
<CustomResourceTypesSupport>false</CustomResourceTypesSupport>
<UseSystemResourceKeys>true</UseSystemResourceKeys>
<DynamicCodeSupport>true</DynamicCodeSupport>
<BuiltInComInteropSupport>false</BuiltInComInteropSupport>
<_EnableConsumingManagedCodeFromNativeHosting>false</_EnableConsumingManagedCodeFromNativeHosting>
<EnableCppCLIHostActivation>false</EnableCppCLIHostActivation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Copyright (c) .NET Foundation. All rights reserved.
<PublishTrimmed Condition="'$(PublishTrimmed)' == '' And '$(PublishAot)' == 'true'">true</PublishTrimmed>
<_IsTrimmingEnabled Condition="'$(_IsTrimmingEnabled)' == '' And ('$(PublishTrimmed)' == 'true' Or '$(IsTrimmable)' == 'true')">true</_IsTrimmingEnabled>
<_IsTrimmingEnabled Condition="'$(_IsTrimmingEnabled)' == ''">false</_IsTrimmingEnabled>
<DynamicCodeSupport Condition="'$(DynamicCodeSupport)' == '' And '$(PublishAot)' == 'true'">false</DynamicCodeSupport>
</PropertyGroup>

<ItemDefinitionGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,11 @@ Copyright (c) .NET Foundation. All rights reserved.
Value="$(UseSystemResourceKeys)"
Trim="true" />

<RuntimeHostConfigurationOption Include="System.Runtime.CompilerServices.RuntimeFeature.IsDynamicCodeSupported"
Condition="'$(DynamicCodeSupport)' != ''"
Value="$(DynamicCodeSupport)"
Trim="true" />

<RuntimeHostConfigurationOption Include="System.Runtime.InteropServices.BuiltInComInterop.IsSupported"
Condition="'$(BuiltInComInteropSupport)' != ''"
Value="$(BuiltInComInteropSupport)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public void It_publishes_the_project_correctly(string targetFramework, string []
""System.Reflection.NullabilityInfoContext.IsSupported"": false,
""System.Resources.ResourceManager.AllowCustomResourceTypes"": false,
""System.Resources.UseSystemResourceKeys"": true,
""System.Runtime.CompilerServices.RuntimeFeature.IsDynamicCodeSupported"": true,
""System.Runtime.InteropServices.BuiltInComInterop.IsSupported"": false,
""System.Runtime.InteropServices.EnableConsumingManagedCodeFromNativeHosting"": false,
""System.Runtime.InteropServices.EnableCppCLIHostActivation"": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Microsoft.NET.TestFramework.Assertions;
using Microsoft.NET.TestFramework.Commands;
using Microsoft.NET.TestFramework.ProjectConstruction;
using Newtonsoft.Json.Linq;
using Xunit;
using Xunit.Abstractions;
using static Microsoft.NET.Publish.Tests.PublishTestUtils;
Expand Down Expand Up @@ -705,6 +706,31 @@ public void It_publishes_with_implicit_rid_with_NativeAotApp(string targetFramew
}
}

[RequiresMSBuildVersionTheory("17.0.0.32901")]
[InlineData(ToolsetInfo.CurrentTargetFramework)]
public void It_builds_with_dynamiccodesupport_false_when_publishaot_true(string targetFramework)
{
var projectName = "DynamicCodeSupportFalseApp";
var testProject = CreateHelloWorldTestProject(targetFramework, projectName, true);
testProject.AdditionalProperties["PublishAot"] = "true";
var testAsset = _testAssetsManager.CreateTestProject(testProject);

var buildCommand = new BuildCommand(testAsset);
buildCommand
.Execute()
.Should()
.Pass();

string outputDirectory = buildCommand.GetOutputDirectory(targetFramework: targetFramework).FullName;
string runtimeConfigFile = Path.Combine(outputDirectory, $"{projectName}.runtimeconfig.json");
string runtimeConfigContents = File.ReadAllText(runtimeConfigFile);

JObject runtimeConfig = JObject.Parse(runtimeConfigContents);
JToken configProperties = runtimeConfig["runtimeOptions"]["configProperties"];
configProperties["System.Runtime.CompilerServices.RuntimeFeature.IsDynamicCodeSupported"].Value<bool>()
.Should().BeFalse();
}

private void CheckIlcVersions(string projectPath, string targetFramework, string rid, string expectedVersion)
{
// Compiler version matches expected version
Expand Down