-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Version.txt should use file version from assembly custom attributes not FileVersionInfo #4505
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
Comments
…from FileVersionInfo and replace with using assembly custom attributes (dotnet#4505)
thanks @r0ss88 . This seems like a good find but in what scenarios can we be loading this assembly from memory and it will not be present on disk? |
Happy to contribute. In my scenario I am working with a system where assemblies can be loaded from disk or stored in a database. Though in this case they are loaded from disk the assembly is read as bytes then loaded - hence location is blank. |
@codemzs happy new year, any update? |
@codemzs FileVersionInfo is not correct either way. This should be using the AssemblyInformationalVersion attribute (when present). If you use GitVersioning to generate the assembly attributes, it will produce an internal static class that you can reference directly for any information you need. Other version generation tools may do something similar. Otherwise, an approach like I used for ANTLR's code generator can be used: |
The changes made in issue #3132 have introduced a bug due to relying on a physical location for the assembly. If the Microsoft.ML.Core assembly is loaded from memory the assembly.location will be empty. Using FileVersionInfo.GetVersionInfo relies on a physical path - so an argument exception is thrown inside System.IO.Path since the supplied path is empty.
machinelearning/src/Microsoft.ML.Core/Data/Repository.cs
Lines 308 to 311 in 37ed336
Instead of using FileVersionInfo.GetVersionInfo the assembly custom attributes should be used, for example:
var productVersion = assembly.CustomAttributes.FirstOrDefault(a => a.AttributeType == typeof(AssemblyFileVersionAttribute)).ConstructorArguments.First();
This will return the same product string version as the FileVersionInfo.GetVersionInfo does.
The text was updated successfully, but these errors were encountered: