cleanup, renaming and so on...
This commit is contained in:
parent
64a2c35c0c
commit
c4132b4061
@ -144,7 +144,7 @@ namespace KattekerCreator
|
|||||||
var pathToFile = Path.Combine(_tempDir, Constants.KattekerConfig);
|
var pathToFile = Path.Combine(_tempDir, Constants.KattekerConfig);
|
||||||
var kattekerConfig = new KattekerConfig
|
var kattekerConfig = new KattekerConfig
|
||||||
{
|
{
|
||||||
PublishDir = _appArguments.PublishDir ?? _appArguments.OutputDir,
|
Publish = _appArguments.PublishDir ?? _appArguments.OutputDir,
|
||||||
Changelog = _appArguments.ChangeLog
|
Changelog = _appArguments.ChangeLog
|
||||||
};
|
};
|
||||||
kattekerConfig.WriteToFile(pathToFile);
|
kattekerConfig.WriteToFile(pathToFile);
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<packages>
|
|
||||||
<package id="CommonMark.NET" version="0.15.1" targetFramework="net45" />
|
|
||||||
</packages>
|
|
@ -1,5 +1,8 @@
|
|||||||
namespace Katteker
|
namespace Katteker
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A bunch of constants.
|
||||||
|
/// </summary>
|
||||||
public static class Constants
|
public static class Constants
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
<Compile Include="ReleaseEntry.cs" />
|
<Compile Include="ReleaseEntry.cs" />
|
||||||
<Compile Include="Releases.cs" />
|
<Compile Include="Releases.cs" />
|
||||||
<Compile Include="Utility.cs" />
|
<Compile Include="Utility.cs" />
|
||||||
<Compile Include="VersionExtension.cs" />
|
<Compile Include="VersionUtils.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
@ -4,16 +4,31 @@ using System.Runtime.Serialization.Json;
|
|||||||
|
|
||||||
namespace Katteker
|
namespace Katteker
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Configuration of a Katteker-Deployment
|
||||||
|
/// </summary>
|
||||||
[DataContract]
|
[DataContract]
|
||||||
public class KattekerConfig
|
public class KattekerConfig
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Publish path
|
||||||
|
/// </summary>
|
||||||
[DataMember]
|
[DataMember]
|
||||||
public string PublishDir { get; set; }
|
public string Publish { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Name of the changelog file.
|
||||||
|
/// </summary>
|
||||||
[DataMember]
|
[DataMember]
|
||||||
public string Changelog { get; set; }
|
public string Changelog { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Read file and deserialize content.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">path of the file.</param>
|
||||||
|
/// <returns>this object</returns>
|
||||||
|
/// <exception cref="FileNotFoundException"></exception>
|
||||||
public static KattekerConfig ReadFromFile(string path)
|
public static KattekerConfig ReadFromFile(string path)
|
||||||
{
|
{
|
||||||
if (!File.Exists(path)) throw new FileNotFoundException();
|
if (!File.Exists(path)) throw new FileNotFoundException();
|
||||||
@ -25,6 +40,10 @@ namespace Katteker
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Serialize object and write to file.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">path of the file.</param>
|
||||||
public void WriteToFile(string path)
|
public void WriteToFile(string path)
|
||||||
{
|
{
|
||||||
if (File.Exists(path)) File.Delete(path);
|
if (File.Exists(path)) File.Delete(path);
|
||||||
|
@ -10,7 +10,7 @@ namespace Katteker
|
|||||||
|
|
||||||
public UpdateInfo(string applicationName, Releases releases)
|
public UpdateInfo(string applicationName, Releases releases)
|
||||||
{
|
{
|
||||||
CurrentlyInstalledVersion = new ReleaseEntry(applicationName, VersionExtension.GetCurrentVersion);
|
CurrentlyInstalledVersion = new ReleaseEntry(applicationName, VersionUtils.GetCurrentVersion());
|
||||||
foreach (var release in releases)
|
foreach (var release in releases)
|
||||||
{
|
{
|
||||||
if (applicationName.Equals(release.ApplicationName) && release.Version > CurrentlyInstalledVersion.Version)
|
if (applicationName.Equals(release.ApplicationName) && release.Version > CurrentlyInstalledVersion.Version)
|
||||||
|
@ -53,7 +53,7 @@ namespace Katteker
|
|||||||
public static UpdateManager Create(string urlOrPath = null, string applicationName = null, string rootDirectory = null)
|
public static UpdateManager Create(string urlOrPath = null, string applicationName = null, string rootDirectory = null)
|
||||||
{
|
{
|
||||||
_config = ReadConfigFile();
|
_config = ReadConfigFile();
|
||||||
urlOrPath = urlOrPath ?? _config.PublishDir;
|
urlOrPath = urlOrPath ?? _config.Publish;
|
||||||
var appName = applicationName ?? Utility.GetApplicationName();
|
var appName = applicationName ?? Utility.GetApplicationName();
|
||||||
var rootAppDirectory = Path.Combine(rootDirectory ?? Utility.GetLocalAppDataDirectory(), appName);
|
var rootAppDirectory = Path.Combine(rootDirectory ?? Utility.GetLocalAppDataDirectory(), appName);
|
||||||
return new UpdateManager(urlOrPath, appName, rootAppDirectory);
|
return new UpdateManager(urlOrPath, appName, rootAppDirectory);
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Reflection;
|
|
||||||
using Semver;
|
|
||||||
|
|
||||||
namespace Katteker
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Extension methods for the App-Version.
|
|
||||||
/// </summary>
|
|
||||||
public static class VersionExtension
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Get the current Version of Application.
|
|
||||||
/// </summary>
|
|
||||||
public static SemVersion GetCurrentVersion
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
var assemblyVersion = Assembly.GetEntryAssembly().GetName().Version.ToString(3);
|
|
||||||
var getCurrentVersion = SemVersion.Parse(assemblyVersion);
|
|
||||||
var informalVersion = Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
|
|
||||||
if (informalVersion != null && SemVersion.TryParse(informalVersion, out var semVersion))
|
|
||||||
return semVersion;
|
|
||||||
return getCurrentVersion;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Convert to cenventional System.Version instance.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="value"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static Version ToSystemVersion(this SemVersion value) => new Version(value.Major, value.Minor, value.Patch, 0);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get the current Version of Application.
|
|
||||||
/// </summary>
|
|
||||||
public static string GetFullVersion => GetCurrentVersion.ToString();
|
|
||||||
}
|
|
||||||
}
|
|
37
Katteker/VersionUtils.cs
Normal file
37
Katteker/VersionUtils.cs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
using Semver;
|
||||||
|
|
||||||
|
namespace Katteker
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Utils for the App-Version.
|
||||||
|
/// </summary>
|
||||||
|
public static class VersionUtils
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Get the current Version of Application.
|
||||||
|
/// </summary>
|
||||||
|
public static SemVersion GetCurrentVersion()
|
||||||
|
{
|
||||||
|
var assemblyVersion = Assembly.GetEntryAssembly().GetName().Version.ToString(3);
|
||||||
|
var getCurrentVersion = SemVersion.Parse(assemblyVersion);
|
||||||
|
var informalVersion = Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
|
||||||
|
if (informalVersion != null && SemVersion.TryParse(informalVersion, out var semVersion))
|
||||||
|
return semVersion;
|
||||||
|
return getCurrentVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the System.Version representation of a semantic version.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static Version ToSystemVersion(this SemVersion value) => new Version(value.Major, value.Minor, value.Patch, 0);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the current Version of Application.
|
||||||
|
/// </summary>
|
||||||
|
public static string GetFullVersion => GetCurrentVersion().ToString();
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user