@@ -67,6 +67,27 @@ function _resolve_assembly_name(context)
6767end
6868
6969
70+ -- resolve runtime identifier from user config or auto-detect from target plat/arch
71+ -- e.g. "osx-x64", "osx-arm64", "linux-x64", "win-x64"
72+ function _resolve_runtime_identifier (context )
73+ local rid = _get_target_value (context .target , " csharp.runtime_identifier" )
74+ if rid then
75+ return rid
76+ end
77+ -- auto-detect RID when publish_aot is enabled
78+ local publish_aot = _get_target_value (context .target , " csharp.publish_aot" )
79+ if not publish_aot then
80+ return nil
81+ end
82+ local target = context .target
83+ local plat = target :plat ()
84+ local arch = target :arch ()
85+ local rid_arch = ({x86_64 = " x64" , i386 = " x86" , x64 = " x64" , x86 = " x86" ,
86+ arm64 = " arm64" , [" arm64-v8a" ] = " arm64" , armv7 = " arm" })[arch ] or arch
87+ local rid_os = ({macosx = " osx" , linux = " linux" , windows = " win" , mingw = " win" })[plat ] or plat
88+ return rid_os .. " -" .. rid_arch
89+ end
90+
7091-- register a single-value csharp.* property entry
7192function _register_property (register , suffix , xml , default , extra )
7293 local entry = table .join ({
@@ -128,7 +149,7 @@ function main()
128149 _register_property (register , " generate_documentation_file" , " GenerateDocumentationFile" )
129150 _register_property (register , " documentation_file" , " DocumentationFile" )
130151
131- _register_property ( register , " runtime_identifier " , " RuntimeIdentifier" )
152+ register ({ kind = " property " , xml = " RuntimeIdentifier" , resolve = _resolve_runtime_identifier } )
132153 _register_list_property (register , " runtime_identifiers" , " RuntimeIdentifiers" )
133154 _register_property (register , " self_contained" , " SelfContained" )
134155 _register_property (register , " use_app_host" , " UseAppHost" )
0 commit comments