Skip to content

Commit 3dff232

Browse files
[dotnet] Enable generation of runtime configuration file (#17840)
Set the GenerateRuntimeConfigurationFiles (GRCF) property to true to avoid warnings at build time + add test for change. Diving deeper into the fix... - This warning only occurs with .NET apps which is why GRCF is only updated in the dotnet directory and not msbuild (legacy) - After examining the binlog (see issue), it was found that the GRCF was contingent upon the HasRuntimeOutput property, which is only defined for executable projects. And in this case, the user's project output type is library thus both the RuntimeOutput and consequently GRCF properties were not enabled. - By setting the GRCF to true we can address the original warning of concern while ensuring the rest of the projects's behavior is not altered in mysterious ways (i.e. by touching the RuntimeOutput property or the project output type instead, these changes could have extraneous effects). Fixes #17543 --------- Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
1 parent 32dd911 commit 3dff232

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

dotnet/targets/Xamarin.Shared.Sdk.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
* https://github.com/dotnet/sdk/blob/c5a58bc6c3eb2b236b314e6d17a89a537459890c/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets#L102
5151
-->
5252
<_IsTrimmingEnabled>true</_IsTrimmingEnabled>
53+
<!-- The GRCF property is contingent upon the HasRuntimeOutput property, which is only defined for executable projects. So, explicitly define GRCF for extension projects to avoid warnings at build time. -->
54+
<GenerateRuntimeConfigurationFiles Condition="'$(IsAppExtension)' == 'true'">true</GenerateRuntimeConfigurationFiles>
5355
</PropertyGroup>
5456

5557
<!-- Set the default RuntimeIdentifier if not already specified. -->

tests/dotnet/UnitTests/ProjectTest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,10 @@ public void BuildProjectsWithExtensions (ApplePlatform platform)
917917

918918
var extensionPath = Path.Combine (Path.GetDirectoryName (consumingProjectDir)!, "bin", "Debug", platform.ToFramework (), GetDefaultRuntimeIdentifier (platform), "MySimpleApp.app", GetPlugInsRelativePath (platform), "ExtensionProject.appex");
919919
Assert.That (Directory.Exists (extensionPath), $"App extension directory does not exist: {extensionPath}");
920+
921+
var pathToSearch = Path.Combine (Path.GetDirectoryName (consumingProjectDir)!, "bin", "Debug");
922+
string [] configFiles = Directory.GetFiles (pathToSearch, "*.runtimeconfig.*", SearchOption.AllDirectories);
923+
Assert.AreNotEqual (0, configFiles.Length, "runtimeconfig.json file does not exist");
920924
}
921925

922926
[TestCase (ApplePlatform.iOS, "iossimulator-x64;iossimulator-arm64")]

0 commit comments

Comments
 (0)