Closed dawedawe closed 10 months ago
Yep! This would do the base-level support - though MSBuild properties can be passed via -p
in a number of different formats. You can see the tests we have in the SDK for our own parsing of the various formats here. I think simple key=value pairs are the most common, but automated tools especially love to use the more complex formats.
Thanks for the pointer. These should all work now with -p
or -p:
or --property
.
If the following mapping to MSBuild properties is correct, I think this PR is ready for review (not sure about OS):
-r
maps to RuntimeIdentifier
-a
maps to Platform
--os
maps to OS
--os
and --arch
map to different components of a RuntimeIdentifier. Take linux-x64
for example - the linux
portion is the OS
, and the x64
portion is the arch
. This isn't a hard-and-fast rule, however - the Runtime Identifier linux-musl-x64
has an os
of linux-musl
and an arch
of x64
.
The dotnet CLI errors if arch/os are provided at the same time as -r, and it 'fills in' any missing pieces of the final RuntimeIdentifier from arch/os with the arch/os of the current SDK. So a user specifying --arch arm64
on a linux device would end up passing -p RuntimeIdentifier=linux-arm64
to the build.
Ah okay sorry, I had some bigger misunderstanding then. So I need to find a way how to query programatically the correct string values for os and arch then...
The 'correct' way to get the RID for the currently running SDK is here - but it is very, very gross.
So System.Runtime.InteropServices.RuntimeInformation.RuntimeIdentifier
can be wrong in some cases?
oh, great idea - that should be fine for your needs. I think the SDK has some layering problem where it can't necessarily rely on that.
Ok, thanks a lot for all your help here!
With the RuntimeIdentifier being constructed with --arch and --os if given, I hope this is ready now.
@baronfel Is that roughly what you had in mind in #84 ?
With it we can do things like: