Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TJC.ConsoleApplication.Tests/Helpers/VersionHelperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ public void GetVersionUsesConfiguredVersionType(VersionType versionType, string
ConsoleSettings.Instance.VersionType = VersionType.Version;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class VersionArgument(
private static void WriteVersionNumber()
{
var version = Assembly.GetEntryAssembly()?.GetVersion();
ConsoleOutputHandler.WriteLine($"v{version.FormatVersion(ConsoleSettings.Instance.VersionDigits)}");
ConsoleOutputHandler.WriteLine(
$"v{version.FormatVersion(ConsoleSettings.Instance.VersionDigits)}"
);
}
}
12 changes: 7 additions & 5 deletions TJC.ConsoleApplication/Helpers/VersionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ internal static class VersionHelper
return ConsoleSettings.Instance.VersionType switch
{
VersionType.Version => assembly.GetName().Version?.ToString(),
VersionType.InformationalVersion => assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?
.InformationalVersion,
VersionType.FileVersion => assembly.GetCustomAttribute<AssemblyFileVersionAttribute>()?
.Version,
VersionType.InformationalVersion => assembly
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
?.InformationalVersion,
VersionType.FileVersion => assembly
.GetCustomAttribute<AssemblyFileVersionAttribute>()
?.Version,
VersionType.ProductVersion => string.IsNullOrEmpty(assembly.Location)
? null
: FileVersionInfo.GetVersionInfo(assembly.Location).ProductVersion,
Expand All @@ -34,4 +36,4 @@ internal static class VersionHelper

return parsedVersion.ToString(digits);
}
}
}
2 changes: 1 addition & 1 deletion TJC.ConsoleApplication/Settings/VersionType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ public enum VersionType
/// The product version from the file version information.
/// </summary>
ProductVersion,
}
}
Loading