-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Improve .NET Core version APIs #28701
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
The |
@loop-evgeny - also note that hack won't work in any "hammer servicing" scenarios. (I can't find great documentation on what "hammer servicing" is except for https://github.com/dotnet/core-setup/blob/be4e2eb3709ab5b307ff581f222fd2a4c7a2dc94/Documentation/design-docs/host-probing.md#probing-paths explains it a little. Basically, it is an ability for .NET Core assemblies to be patched without shipping a whole new |
Hammer servicing works on per file granularity. The only way to detect it is to look at file version of the particular file you are interested in. None of the APIs discussed here or related issues would help you with that. |
@jkotas - I was referring to @loop-evgeny's "hack" above:
If |
FYI: I updated the issue with an actual proposal. |
This is all fixed now. |
I validated with the latest master build that |
Great to see this fixed! Could I just confirm that this will work even for self-contained deployments? |
Yes, it will work for self-contained deployments. |
From this morning's master build at dotnet/core-sdk. The new changes are in place. C:\testapps\versioninfo>\Users\rlander\Downloads\dotnet-sdk-latest-win-x64\dotnet.exe run
.NET Core version:
Environment.Version: 3.0.0
RuntimeInformation.FrameworkDescription: .NET Core 3.0.0-preview4-27425-5
CoreCLR Build: 3.0.0-preview4.27425.72
CoreCLR Hash: 84f0ae886cc659fabd8d8b499861383bb801fa08
CoreFX Build: 3.0.0-preview4.19123.2
CoreFX Hash: 327def063eb5eddb723edcee84815d9495b4021c If anyone is unsure what to do with the hashes, try these two links, using the hashes above: Note: The links render in an unfortunate way for this purpose. Hover over the links (or just click on them) and you'll see that the linked hashes match the hashes above. It is now very easy to discover the commit that a given binary was built from and you can go and check it out. |
Same thing with a self-contained build: C:\testapps\versioninfo\bin\Debug\netcoreapp3.0\win-x64>versioninfo.exe
.NET Core version:
Environment.Version: 3.0.0
RuntimeInformation.FrameworkDescription: .NET Core 3.0.0-preview4-27425-5
CoreCLR Build: 3.0.0-preview4.27425.72
CoreCLR Hash: 84f0ae886cc659fabd8d8b499861383bb801fa08
CoreFX Build: 3.0.0-preview4.19123.2
CoreFX Hash: 327def063eb5eddb723edcee84815d9495b4021c |
There should be APIs to get the actual .NET Version and the commit SHA for .NET Core. The version APIs have been a weak point of the product since .NET Core 1.0. If we're going to change existing behavior a major version would be a good time!
In particular, Environment.Version and RuntimeInformation.FrameworkDescription seem nearly useless in the majority of cases. It is particularly cute that they return different values. At least they agree on 4.x!
The OS Version and Bitness APIs are included for completeness. The OS version APIs could likely be improved in some way, but I don't have a specific need for that.
This is what I can produce today:
Code: https://gist.github.com/richlander/f5849c6967c66d699301f75101906f99/8f73418f7260e207b415ff1a48233cd26094be05
I updated the code, and made it more focused on the key scenario and switched to approved patterns (modulo the fact that my code will crash if the AssemblyInformationalVersionAttribute string is not maintained):
Existing behavior:
Code: https://gist.github.com/richlander/f5849c6967c66d699301f75101906f99
Desired behavior for a preview:
Desired behavior for a release build:
Note: I have documented this with CoreFX since it has implemented the new format for AssemblyInformationalVersionAttribute. CoreCLR has not done that yet, but will. If both were in place, I'd include both in my sample.
Note: There is no way to get this information for the actual CoreCLR runtime. The build and hash values for System.Private.CoreLib.dll and CoreCLR are expected to be uniform 99% of the time.
The text was updated successfully, but these errors were encountered: