Replaced CommonMark.Net with MarkdownSharp. Smaller and a single file, so there are no Nuget dependencies.

This commit is contained in:
Holger Börchers 2018-03-23 08:23:39 +01:00
parent 715e93985d
commit 6fafdd3090
10 changed files with 1812 additions and 54 deletions

View File

@ -9,7 +9,7 @@ namespace KattekerCreator
public PathFragments(string path)
{
_fragments = path.Split(Path.PathSeparator);
_fragments = path.Split(Path.DirectorySeparatorChar);
}
public int FragmentLength => _fragments.Length;
@ -18,7 +18,7 @@ namespace KattekerCreator
public override int GetHashCode() => (_fragments != null ? _fragments.GetHashCode() : 0);
public override string ToString() => string.Join(Path.PathSeparator.ToString(), _fragments.Take(_fragments.Length - 1));
public override string ToString() => string.Join(Path.DirectorySeparatorChar.ToString(), _fragments.Take(_fragments.Length - 1));
protected bool Equals(PathFragments other) => Equals(_fragments, other._fragments);
}

View File

@ -69,14 +69,11 @@ namespace KattekerCreator
//Start makensis.exe
var setupFilePath = CompileSetupScript(templateFile);
//Copy to Output-Folder
if (CopyToOutputFolder(setupFilePath))
{
//Create/Modify RELEASE File
var releaseEntry = AddPackageToReleaseFile(setupFilePath);
//Copy installer as setup.exe
CopyAsSetup(setupFilePath, releaseEntry);
}
CopyToOutputFolder(setupFilePath);
//Create/Modify RELEASE File
var releaseEntry = AddPackageToReleaseFile(setupFilePath);
//Copy installer as setup.exe
CopyAsSetup(setupFilePath, releaseEntry);
return 0;
}
@ -103,31 +100,20 @@ namespace KattekerCreator
}
}
private bool CopyToOutputFolder(string setupFilePath)
private void CopyToOutputFolder(string setupFilePath)
{
try
if (setupFilePath == null) throw new ArgumentNullException(nameof(setupFilePath));
var setupFile = Path.GetFileName(setupFilePath);
if (string.IsNullOrEmpty(setupFile)) throw new ArgumentException();
if (!File.Exists(setupFilePath)) throw new FileNotFoundException(setupFile);
if (!Directory.Exists(_appArguments.OutputDir)) Directory.CreateDirectory(_appArguments.OutputDir);
if (!string.IsNullOrEmpty(_appArguments.ChangeLog))
{
if (setupFilePath == null) throw new ArgumentNullException(nameof(setupFilePath));
var setupFile = Path.GetFileName(setupFilePath);
if (string.IsNullOrEmpty(setupFile)) throw new ArgumentException();
if (!File.Exists(setupFilePath)) throw new FileNotFoundException(setupFile);
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, Path.GetFileName(_appArguments.ChangeLog) ?? throw new InvalidOperationException()), true);
}
if (!Directory.Exists(_appArguments.OutputDir)) Directory.CreateDirectory(_appArguments.OutputDir);
File.Copy(setupFilePath, Path.Combine(_appArguments.OutputDir, setupFile), true);
return true;
}
catch (Exception e)
{
Log.WriteErrorLine(e.Message);
return false;
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);
}
File.Copy(setupFilePath, Path.Combine(_appArguments.OutputDir, setupFile), true);
}
private static string CompileSetupScript(string templateFile)

View File

@ -8,10 +8,11 @@
Title="MainWindow"
Width="800"
Height="450"
Background="DarkBlue"
Background="BlueViolet"
ContentRendered="MainWindow_OnContentRendered"
mc:Ignorable="d">
<StackPanel>
<Button Margin="10" FontSize="24" Content="Update" Click="ButtonBase_OnClick"></Button>
<TextBlock Text=":-(" FontSize="60" HorizontalAlignment="Center" />
</StackPanel>
</Window>

View File

@ -49,5 +49,5 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.36.0")]
[assembly: AssemblyFileVersion("1.0.36.0")]
[assembly: AssemblyVersion("1.0.42")]
[assembly: AssemblyFileVersion("1.0.42")]

View File

@ -7,7 +7,7 @@ namespace Katteker.Gui
{
internal static class ChangelogHelper
{
private static string GenerateHtmlifyChangelog(string text, string extension)
private static string GenerateChangelogAsHtml(string text, string extension)
{
string result;
switch (extension)
@ -17,7 +17,7 @@ namespace Katteker.Gui
result = plainText.Replace(Environment.NewLine, "<br />");
break;
case ".md":
result = CommonMark.CommonMarkConverter.Convert(text);
result = new MarkdownSharp.Markdown().Transform(text);
break;
default:
result = text;
@ -39,23 +39,23 @@ namespace Katteker.Gui
using (var response = await webReq.GetResponseAsync().ConfigureAwait(false))
using (var sr = new StreamReader(response.GetResponseStream()))
{
return GenerateHtmlifyChangelog(await sr.ReadToEndAsync().ConfigureAwait(false),
return GenerateChangelogAsHtml(await sr.ReadToEndAsync().ConfigureAwait(false),
Path.GetExtension(filename));
}
}
catch (WebException)
{
var changelogFilename = Path.GetFileName(filename);
if (changelogFilename == null) return GenerateHtmlifyChangelog("Changelog not found", ".txt");
if (changelogFilename == null) return GenerateChangelogAsHtml("Changelog not found", ".txt");
var currentChangelogPath = Path.Combine(Environment.CurrentDirectory, changelogFilename);
if (File.Exists(currentChangelogPath))
{
return GenerateHtmlifyChangelog(File.ReadAllText(currentChangelogPath), Path.GetExtension(filename));
return GenerateChangelogAsHtml(File.ReadAllText(currentChangelogPath), Path.GetExtension(filename));
}
}
}
return GenerateHtmlifyChangelog("Changelog not found", ".txt");
return GenerateChangelogAsHtml("Changelog not found", ".txt");
}
}
}

View File

@ -34,9 +34,6 @@
<DocumentationFile>bin\Release\Katteker.Gui.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="CommonMark, Version=0.1.0.0, Culture=neutral, PublicKeyToken=001ef8810438905d, processorArchitecture=MSIL">
<HintPath>..\packages\CommonMark.NET.0.15.1\lib\net45\CommonMark.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
<Reference Include="System.Core" />
@ -46,6 +43,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="ChangelogHelper.cs" />
<Compile Include="MarkdownSharp.cs" />
<Compile Include="Wrapper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
@ -62,7 +60,6 @@
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">

File diff suppressed because it is too large Load Diff

View File

@ -31,6 +31,5 @@ using System.Runtime.InteropServices;
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyVersion("1.0.0")]
[assembly: AssemblyFileVersion("1.0.0")]

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommonMark.NET" version="0.15.1" targetFramework="net45" />
</packages>

View File

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0")]
[assembly: AssemblyFileVersion("1.0.0")]