cleanup code, added version to commandline interface, updated MSTest nuget packages.

This commit is contained in:
2018-05-18 10:38:59 +02:00
parent cf4cc2cd93
commit 17e12093f8
10 changed files with 79 additions and 37 deletions

View File

@ -15,17 +15,17 @@ namespace KattekerCreator
private readonly string _description;
private readonly string _productName;
public AssemblyFileInfo(string fileName, string tempDir)
public AssemblyFileInfo(ApplicationArguments appArguments, string tempDir)
{
FileInfo = new FileInfo(fileName);
FileInfo = new FileInfo(appArguments.ProgramFile);
using (var resourceInfo = new ResourceInfo())
{
resourceInfo.Load(fileName);
resourceInfo.Load(appArguments.ProgramFile);
if (resourceInfo.ResourceTypes.All(x => x.ResourceType != Kernel32.ResourceTypes.RT_VERSION)) return;
var versionResource = (VersionResource) resourceInfo[Kernel32.ResourceTypes.RT_VERSION].First();
var stringFileInfo = ((StringFileInfo) versionResource[nameof(StringFileInfo)]).Strings
.FirstOrDefault().Value;
AssemblyIconPath = GetAssemblyIcon(fileName, tempDir);
AssemblyIconPath = GetAssemblyIcon(appArguments.ProgramFile, tempDir);
if (stringFileInfo.Strings.ContainsKey("CompanyName"))
_company = stringFileInfo.Strings["CompanyName"].StringValue.TrimEnd('\0');
if (stringFileInfo.Strings.ContainsKey("FileDescription"))
@ -35,14 +35,13 @@ namespace KattekerCreator
if (stringFileInfo.Strings.ContainsKey("ProductName"))
_productName = stringFileInfo.Strings["ProductName"].StringValue.TrimEnd('\0');
if (!stringFileInfo.Strings.ContainsKey("ProductVersion")) return;
AssemblyVersion =
GetSemanticVersion(stringFileInfo.Strings["ProductVersion"].StringValue.TrimEnd('\0'));
AssemblyVersion = appArguments.Version != null ? GetSemanticVersion(appArguments.Version) : GetSemanticVersion(stringFileInfo.Strings["ProductVersion"].StringValue.TrimEnd('\0'));
}
}
public string AssemblyIconPath { get; }
public SemVersion AssemblyVersion { get; private set; }
public SemVersion AssemblyVersion { get; }
public string Company => _company ?? string.Empty;