Skip to content
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

Merged
merged 4 commits into from
Mar 28, 2020

Conversation

eerhardt
Copy link
Member

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.

This value returns the Runtime Identifier (RID) of the current machine.

Contributes to dotnet#26780
@Dotnet-GitSync-Bot
Copy link
Collaborator

Note regarding the new-api-needs-documentation label:

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.

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@ViktorHofer
Copy link
Member

ViktorHofer commented Apr 28, 2020

@eerhardt @rainersigwald can we make that property readable from msbuild as a property function?

  • By default, you can only call certain members on certain types – selected to be free of side-effects. Here’s the full list:

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:

<HostArch>$([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant)</HostArch>

@eerhardt
Copy link
Member Author

can we make that property readable from msbuild as a property function?

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:

  Current RID: win10-x64

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.

@ViktorHofer
Copy link
Member

Great, thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Dec 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants