Skip to content

Version.txt should use file version from assembly custom attributes not FileVersionInfo #4505

Closed
@r0ss88

Description

@r0ss88

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.

var versionInfo = FileVersionInfo.GetVersionInfo(typeof(RepositoryWriter).Assembly.Location);
using (var ent = rep.CreateEntry(DirTrainingInfo, "Version.txt"))
using (var writer = Utils.OpenWriter(ent.Stream))
writer.WriteLine(versionInfo.ProductVersion);

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Priority of the issue for triage purpose: Needs to be fixed at some point.bugSomething isn't workingloadsaveBugs related loading and saving data or models

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions