-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add RuntimeInformation.RuntimeIdentifier #34206
Conversation
This value returns the Runtime Identifier (RID) of the current machine. Contributes to dotnet#26780
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
...ntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/RuntimeInformation.cs
Outdated
Show resolved
Hide resolved
...ntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/RuntimeInformation.cs
Show resolved
Hide resolved
...ntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/RuntimeInformation.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime.InteropServices.RuntimeInformation/tests/RuntimeIdentifierTests.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
@eerhardt @rainersigwald can we make that property readable from msbuild as a property function?
from https://devblogs.microsoft.com/visualstudio/msbuild-property-functions/. Sounds to me like we need to "white-list" that property? That information could be outdated as I see that we are reading other properties from RuntimeInformation already:
|
It is already possible today (since this property is on RuntimeInformation): <PropertyGroup>
<MyRid>$([System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier)</MyRid>
</PropertyGroup>
<Target Name="PostBuild"
AfterTargets="Build">
<Message Text="Current RID: $(MyRid)" Importance="high" />
</Target> On my machine outputs:
However, note that this will only work from MSBuild running on .NET 5 and above, since this API is only available there. It won't work on .NET Core 3.x, nor will it work on MSBuild running on .NET Framework. |
Great, thanks! |
This value returns the Runtime Identifier (RID) of the current machine.
Contributes to #26780
Most of the tests are disabled because we use an old host to run our tests. When we update to a host with the new code, the tests can be enabled. I'll keep #26780 open until the tests are enabled.