Merge branch 'master' of https://git.boerchers.org/holger/Katteker
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7"/>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
|
||||
</startup>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
|
@ -10,6 +10,7 @@ namespace KattekerCreator
|
||||
private string _outputDir;
|
||||
private string _programFile;
|
||||
private string _publishDir;
|
||||
private string _version;
|
||||
|
||||
[DisplayName("Program")]
|
||||
[Description("Path to the program file")]
|
||||
@ -20,11 +21,11 @@ namespace KattekerCreator
|
||||
}
|
||||
|
||||
[DisplayName("Changelog")]
|
||||
[Description("Filename of the changelog file")]
|
||||
[Description("Path of the changelog file")]
|
||||
public string ChangeLog
|
||||
{
|
||||
get => _changeLog;
|
||||
set => SetPropertyIfNotDefault(ref _changeLog, value);
|
||||
set => SetPropertyIfNotDefault(ref _changeLog, Path.GetFullPath(value));
|
||||
}
|
||||
|
||||
[DisplayName("Channel")]
|
||||
@ -51,6 +52,14 @@ namespace KattekerCreator
|
||||
set => SetPropertyIfNotDefault(ref _publishDir, value);
|
||||
}
|
||||
|
||||
[DisplayName("Version")]
|
||||
[Description("Override version number of the application.")]
|
||||
public string Version
|
||||
{
|
||||
get => _version;
|
||||
set => SetPropertyIfNotDefault(ref _version, value);
|
||||
}
|
||||
|
||||
private static bool SetPropertyIfNotDefault<T>(ref T field, T value)
|
||||
{
|
||||
if (Equals(value, field)) return false;
|
||||
|
@ -2,7 +2,6 @@
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Katteker;
|
||||
using Semver;
|
||||
using TsudaKageyu;
|
||||
using Vestris.ResourceLib;
|
||||
@ -16,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"))
|
||||
@ -36,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;
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace KattekerCreator.Helper
|
||||
{
|
||||
@ -9,17 +10,17 @@ namespace KattekerCreator.Helper
|
||||
|
||||
public static void WriteInfoLine(string text)
|
||||
{
|
||||
using (var c = new ConsoleWithOtherColor())
|
||||
using (new ConsoleWithOtherColor())
|
||||
{
|
||||
c.WriteLine($"{Info} [{DateTime.Now:G}] {text}");
|
||||
ConsoleWithOtherColor.WriteLine($"{Info} [{DateTime.Now:G}] {text}");
|
||||
}
|
||||
}
|
||||
|
||||
public static void WriteErrorLine(string text)
|
||||
{
|
||||
using (var c = new ConsoleWithOtherColor(ConsoleColor.DarkRed))
|
||||
using (new ConsoleWithOtherColor(ConsoleColor.DarkRed))
|
||||
{
|
||||
c.WriteLine($"{Error} [{DateTime.Now:G}] {text}");
|
||||
ConsoleWithOtherColor.WriteLine($"{Error} [{DateTime.Now:G}] {text}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -38,13 +39,20 @@ namespace KattekerCreator.Helper
|
||||
Console.ForegroundColor = color;
|
||||
}
|
||||
|
||||
public void WriteLine(string text)
|
||||
public static void WriteLine(string text)
|
||||
{
|
||||
Console.WriteLine(text);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposing) return;
|
||||
if (_defaultColor != null) Console.ForegroundColor = _defaultColor.Value;
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>KattekerCreator</RootNamespace>
|
||||
<AssemblyName>KattekerCreator</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
|
||||
<RestorePackages>true</RestorePackages>
|
||||
|
@ -56,7 +56,7 @@ namespace KattekerCreator
|
||||
//Modify AppStub
|
||||
var appStubFile = ModifyAppStub();
|
||||
//Acquire infos from Executable.
|
||||
_assemblyFileInfo = new AssemblyFileInfo(_appArguments.ProgramFile, _tempDir);
|
||||
_assemblyFileInfo = new AssemblyFileInfo(_appArguments, _tempDir);
|
||||
var configFile = CreateConfigFile();
|
||||
|
||||
//Generate NSIS-Script
|
||||
@ -109,9 +109,10 @@ namespace KattekerCreator
|
||||
if (!Directory.Exists(_appArguments.OutputDir)) Directory.CreateDirectory(_appArguments.OutputDir);
|
||||
if (!string.IsNullOrEmpty(_appArguments.ChangeLog))
|
||||
{
|
||||
var changeLogPath = Path.Combine(Path.GetDirectoryName(_appArguments.ProgramFile), _appArguments.ChangeLog);
|
||||
if (!File.Exists(changeLogPath)) throw new FileNotFoundException(changeLogPath);
|
||||
File.Copy(changeLogPath, Path.Combine(_appArguments.OutputDir, _appArguments.ChangeLog), true);
|
||||
var changeLogFilename = Path.GetFileName(_appArguments.ChangeLog);
|
||||
|
||||
if (!File.Exists(_appArguments.ChangeLog)) throw new FileNotFoundException(_appArguments.ChangeLog);
|
||||
File.Copy(_appArguments.ChangeLog, Path.Combine(_appArguments.OutputDir, changeLogFilename), true);
|
||||
}
|
||||
File.Copy(setupFilePath, Path.Combine(_appArguments.OutputDir, setupFile), true);
|
||||
}
|
||||
@ -145,7 +146,7 @@ namespace KattekerCreator
|
||||
var kattekerConfig = new KattekerConfig
|
||||
{
|
||||
Publish = _appArguments.PublishDir ?? _appArguments.OutputDir,
|
||||
Changelog = _appArguments.ChangeLog
|
||||
Changelog = Path.GetFileName(_appArguments.ChangeLog)
|
||||
};
|
||||
kattekerConfig.WriteToFile(pathToFile);
|
||||
return pathToFile;
|
||||
|
Reference in New Issue
Block a user