Skip to content

Commit

Permalink
Fix versioning on linux (and hopefully macos), change versioning to f…
Browse files Browse the repository at this point in the history
…ull semver (Major.Minor.Build.Revision), update version number to 0.2.1.1
  • Loading branch information
TraceEntertains committed Sep 3, 2024
1 parent 161ae41 commit 439462c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 25 deletions.
36 changes: 12 additions & 24 deletions tns2tool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,26 @@ public class Program
{
public static byte VersionMajor { get; private set; } = 0;
public static byte VersionMinor { get; private set; } = 0;
public static byte VersionBuild { get; private set; } = 0;
public static byte VersionRevision { get; private set; } = 0;
public static string InformationalVersion { get; private set; } = "";

public static string GetFileVersion()
{
return $"{VersionMajor}.{VersionMinor}";
return $"{VersionMajor}.{VersionMinor}.{VersionBuild}.{VersionRevision}";
}

static void PopulateVersionInfo()
{
Version version = Assembly.GetEntryAssembly()!.GetName().Version!;
Assembly entryAssembly = Assembly.GetEntryAssembly()!;
Version version = entryAssembly.GetName().Version!;

VersionMajor = (byte)version.Major;
VersionMinor = (byte)version.Minor;
VersionBuild = (byte)version.Build;
VersionRevision = (byte)version.Revision;

try
{
InformationalVersion =
FileVersionInfo.GetVersionInfo(Environment.ProcessPath!).ProductVersion!;
}
#if DEBUG
catch (Exception ex)
{

Console.WriteLine("Error getting InformationalVersion: " + ex.Message);
#else
catch
{
#endif
// fallback informational version, hopefully we never need this
InformationalVersion = $"{VersionMajor}.{VersionMinor}.{VersionRevision}";
}
InformationalVersion = entryAssembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()!.InformationalVersion;
}

static void Main(string[] args)
Expand Down Expand Up @@ -78,7 +66,7 @@ static void Main(string[] args)
return;
}

ProcessFile(option, inputFile, isGzip, outputPath: null);
ProcessFile(option, inputFile, isGzip, null);
}
else if (args[1] == "-inPath")
{
Expand All @@ -102,7 +90,7 @@ static void Main(string[] args)
}
}

static void ProcessFile(string option, string inputFile, bool isGzip, string outputPath)
static void ProcessFile(string option, string inputFile, bool isGzip, string? outputPath)
{
try
{
Expand Down Expand Up @@ -155,12 +143,12 @@ static void ProcessDirectory(string option, string inputPath, bool isGzip)
}

// Function to generate the output file name based on the input file and the output path
static string GetOutputFileName(string inputFile, string outputPath, string newExtension)
static string GetOutputFileName(string inputFile, string? outputPath, string newExtension)
{
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(inputFile);
string directory = outputPath ?? Path.GetDirectoryName(inputFile);
string? directory = outputPath ?? Path.GetDirectoryName(inputFile);

return Path.Combine(directory, $"{fileNameWithoutExtension}{newExtension}");
return Path.Combine(directory!, $"{fileNameWithoutExtension}{newExtension}");
}

// Function to determine the output file extension based on the content
Expand Down
2 changes: 1 addition & 1 deletion tns2tool/tns2tool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.2.1</Version>
<Version>0.2.1.1</Version>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<Configurations>Debug;Release;FullRelease</Configurations>
<RuntimeIdentifiers>win-x64;osx-x64;linux-x64</RuntimeIdentifiers>
Expand Down

0 comments on commit 439462c

Please sign in to comment.