Compare commits

..

No commits in common. "26343921f731eb6e6a76f32711ffdd5661979f76" and "f7800dfb113e721ec1c5964f124ac4b3d2a246a4" have entirely different histories.

2 changed files with 28 additions and 43 deletions

View File

@ -10,7 +10,7 @@ namespace KattekerCreator
{ {
public class Program public class Program
{ {
private const string Executable = @"C:\Program Files (x86)\NSIS\makensis.exe"; private const string _executable = @"C:\Program Files (x86)\NSIS\makensis.exe";
private readonly string _baseDirectory = AppDomain.CurrentDomain.BaseDirectory; private readonly string _baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
private ApplicationArguments _appArguments; private ApplicationArguments _appArguments;
private AssemblyFileInfo _assemblyFileInfo; private AssemblyFileInfo _assemblyFileInfo;
@ -119,13 +119,13 @@ namespace KattekerCreator
private static string CompileSetupScript(string templateFile) private static string CompileSetupScript(string templateFile)
{ {
if (!File.Exists(Executable)) throw new FileNotFoundException("NSIS not installed properly."); if (!File.Exists(_executable)) throw new FileNotFoundException("NSIS not installed properly.");
int exitcode; int exitcode;
using (var p = new Process()) using (var p = new Process())
{ {
p.StartInfo = new ProcessStartInfo p.StartInfo = new ProcessStartInfo
{ {
FileName = Executable, FileName = _executable,
Arguments = $"\"{templateFile}\"", Arguments = $"\"{templateFile}\"",
UseShellExecute = false UseShellExecute = false
}; };
@ -133,10 +133,10 @@ namespace KattekerCreator
p.Start(); p.Start();
p.WaitForExit(); p.WaitForExit();
exitcode = p.ExitCode; exitcode = p.ExitCode;
Log.WriteInfoLine($"{Path.GetFileName(Executable)} has exited with Exitcode: {exitcode} (Took: {sw.ElapsedMilliseconds}ms)"); Log.WriteInfoLine($"{Path.GetFileName(_executable)} has exited with Exitcode: {exitcode} (Took: {sw.ElapsedMilliseconds}ms)");
} }
if (exitcode != 0) throw new Exception($"{Path.GetFileName(Executable)} has exited with Exitcode: {exitcode}"); if (exitcode != 0) throw new Exception($"{Path.GetFileName(_executable)} has exited with Exitcode: {exitcode}");
return Path.ChangeExtension(templateFile, "exe"); return Path.ChangeExtension(templateFile, "exe");
} }

View File

@ -48,16 +48,7 @@ namespace Katteker
{ {
if (!path.EndsWith("/", StringComparison.Ordinal)) if (!path.EndsWith("/", StringComparison.Ordinal))
path += "/"; path += "/";
var changelog = await ReadFromRemoteFile(path + filename) ?? ReadFromLocalFile(filename); var webReq = WebRequest.Create(path + filename);
return changelog;
}
return null;
}
private static async Task<string> ReadFromRemoteFile(string path)
{
var webReq = WebRequest.Create(path);
try try
{ {
using (var response = await webReq.GetResponseAsync().ConfigureAwait(false)) using (var response = await webReq.GetResponseAsync().ConfigureAwait(false))
@ -67,30 +58,24 @@ namespace Katteker
} }
} }
catch (Exception) catch (Exception)
{
// ignore;
}
return null;
}
private static string ReadFromLocalFile(string filename)
{ {
try try
{ {
var changelogFilename = Path.GetFileName(filename); var changelogFilename = Path.GetFileName(filename);
if (changelogFilename == null) return null; if (changelogFilename == null) return null;
var currentChangelogPath = Path.Combine(Environment.CurrentDirectory, changelogFilename); var currentChangelogPath = Path.Combine(Environment.CurrentDirectory, changelogFilename);
if (File.Exists(currentChangelogPath)) if (File.Exists(currentChangelogPath))
{ {
return File.ReadAllText(currentChangelogPath); return File.ReadAllText(currentChangelogPath);
} }
} }
catch (Exception) catch (Exception)
{ {
// ignore; // ignore;
} }
}
}
return null; return null;
} }