ionide / FSharp.Analyzers.SDK

Library for building custom analyzers for F# / FSAC
http://ionide.io/FSharp.Analyzers.SDK/
MIT License
74 stars 21 forks source link

Support MSBuild properties on the CLI #152

Closed dawedawe closed 10 months ago

dawedawe commented 10 months ago

@baronfel Is that roughly what you had in mind in #84 ?

With it we can do things like:

-p Configuration=Release -p DefineConstants="MYDEF" ...
baronfel commented 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.

dawedawe commented 10 months ago

Thanks for the pointer. These should all work now with -p or -p: or --property.

dawedawe commented 10 months ago

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

baronfel commented 10 months ago

--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.

dawedawe commented 10 months ago

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...

baronfel commented 10 months ago

The 'correct' way to get the RID for the currently running SDK is here - but it is very, very gross.

dawedawe commented 10 months ago

So System.Runtime.InteropServices.RuntimeInformation.RuntimeIdentifier can be wrong in some cases?

baronfel commented 10 months ago

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.

dawedawe commented 10 months ago

Ok, thanks a lot for all your help here!

dawedawe commented 10 months ago

With the RuntimeIdentifier being constructed with --arch and --os if given, I hope this is ready now.