Compare commits

..

No commits in common. "3e7f8c5a231c651b2fd675a3598e390c12b7b4ce" and "c7b026ce157a3c6de1fd9dc2902870fc3be5641a" have entirely different histories.

14 changed files with 89 additions and 127 deletions

View File

@ -1,28 +0,0 @@
using System;
using System.Threading;
namespace KattekerCreator.Helper
{
public class TemporaryDirectory : IDisposable
{
public string Path { get; }
public TemporaryDirectory(string path)
{
Path = path;
}
void IDisposable.Dispose()
{
try
{
Thread.Sleep(100);
System.IO.Directory.Delete(Path, true);
}
catch
{
//ignore.
}
}
}
}

View File

@ -19,7 +19,7 @@ namespace KattekerCreator.Helper
return false; return false;
} }
public static TemporaryDirectory CreateTempDirectory() public static string CreateTempDirectory()
{ {
string result; string result;
do do
@ -29,7 +29,7 @@ namespace KattekerCreator.Helper
} while (Directory.Exists(result)); } while (Directory.Exists(result));
Directory.CreateDirectory(result); Directory.CreateDirectory(result);
return new TemporaryDirectory(result); return result;
} }
public static bool IsFilesizeWrong(string filename) public static bool IsFilesizeWrong(string filename)

View File

@ -52,7 +52,6 @@
<Compile Include="ApplicationArguments.cs" /> <Compile Include="ApplicationArguments.cs" />
<Compile Include="AssemblyFileInfo.cs" /> <Compile Include="AssemblyFileInfo.cs" />
<Compile Include="Helper\Log.cs" /> <Compile Include="Helper\Log.cs" />
<Compile Include="Helper\TemporaryDirectory.cs" />
<Compile Include="IconExtractor\IconExtractor.cs" /> <Compile Include="IconExtractor\IconExtractor.cs" />
<Compile Include="IconExtractor\IconUtil.cs" /> <Compile Include="IconExtractor\IconUtil.cs" />
<Compile Include="IconExtractor\NativeMethods.cs" /> <Compile Include="IconExtractor\NativeMethods.cs" />

View File

@ -10,12 +10,11 @@ namespace KattekerCreator
{ {
public class Program public class Program
{ {
//private const string MakeNsis = @"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 string MakeNsis => Path.Combine(_baseDirectory, "NSIS", "makensis.exe");
private ApplicationArguments _appArguments; private ApplicationArguments _appArguments;
private AssemblyFileInfo _assemblyFileInfo; private AssemblyFileInfo _assemblyFileInfo;
private TemporaryDirectory _tempDir; private string _tempDir;
private Releases _releases; private Releases _releases;
private static int Main(string[] args) private static int Main(string[] args)
@ -51,33 +50,31 @@ namespace KattekerCreator
_appArguments = parser.GetObject(); _appArguments = parser.GetObject();
//Create tempdir //Create tempdir
using (_tempDir = Utils.CreateTempDirectory()) _tempDir = Utils.CreateTempDirectory();
{ _releases = new Releases(_appArguments.OutputDir);
_releases = new Releases(_appArguments.OutputDir); parser.ShowProgramArguments();
parser.ShowProgramArguments(); //Modify AppStub
//Modify AppStub var appStubFile = ModifyAppStub();
var appStubFile = ModifyAppStub(); //Acquire infos from Executable.
//Acquire infos from Executable. _assemblyFileInfo = new AssemblyFileInfo(_appArguments, _tempDir);
_assemblyFileInfo = new AssemblyFileInfo(_appArguments, _tempDir.Path); var configFile = CreateConfigFile();
var configFile = CreateConfigFile();
//Generate NSIS-Script //Generate NSIS-Script
var additionalFiles = new[] var additionalFiles = new[]
{ {
new PhysicalFile(appStubFile, Path.GetFileName(_appArguments.ProgramFile)), new PhysicalFile(appStubFile, Path.GetFileName(_appArguments.ProgramFile)),
new PhysicalFile(configFile, Path.Combine($"app-{_assemblyFileInfo.AssemblyVersion}", Path.GetFileName(configFile) ?? string.Empty)) new PhysicalFile(configFile, Path.Combine($"app-{_assemblyFileInfo.AssemblyVersion}", Path.GetFileName(configFile) ?? string.Empty))
}; };
var templateFile = GenerateNsisTemplate(additionalFiles); var templateFile = GenerateNsisTemplate(additionalFiles);
//Start makensis.exe //Start makensis.exe
var setupFilePath = CompileSetupScript(templateFile); var setupFilePath = CompileSetupScript(templateFile);
//Copy to Output-Folder //Copy to Output-Folder
CopyToOutputFolder(setupFilePath); CopyToOutputFolder(setupFilePath);
//Create/Modify RELEASE File //Create/Modify RELEASE File
var releaseEntry = AddPackageToReleaseFile(setupFilePath); var releaseEntry = AddPackageToReleaseFile(setupFilePath);
//Copy installer as setup.exe //Copy installer as setup.exe
CopyAsSetup(setupFilePath, releaseEntry); CopyAsSetup(setupFilePath, releaseEntry);
return 0; return 0;
}
} }
private void CopyAsSetup(string setupFilePath, ReleaseEntry releaseEntry) private void CopyAsSetup(string setupFilePath, ReleaseEntry releaseEntry)
@ -120,15 +117,15 @@ namespace KattekerCreator
File.Copy(setupFilePath, Path.Combine(_appArguments.OutputDir, setupFile), true); File.Copy(setupFilePath, Path.Combine(_appArguments.OutputDir, setupFile), true);
} }
private string CompileSetupScript(string templateFile) private static string CompileSetupScript(string templateFile)
{ {
if (!File.Exists(MakeNsis)) 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 = MakeNsis, FileName = Executable,
Arguments = $"\"{templateFile}\"", Arguments = $"\"{templateFile}\"",
UseShellExecute = false UseShellExecute = false
}; };
@ -136,21 +133,20 @@ namespace KattekerCreator
p.Start(); p.Start();
p.WaitForExit(); p.WaitForExit();
exitcode = p.ExitCode; exitcode = p.ExitCode;
Log.WriteInfoLine($"{Path.GetFileName(MakeNsis)} 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(MakeNsis)} 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");
} }
private string CreateConfigFile() private string CreateConfigFile()
{ {
var pathToFile = Path.Combine(_tempDir.Path, Constants.KattekerConfig); var pathToFile = Path.Combine(_tempDir, Constants.KattekerConfig);
var kattekerConfig = new KattekerConfig var kattekerConfig = new KattekerConfig
{ {
Publish = _appArguments.PublishDir ?? _appArguments.OutputDir, Publish = _appArguments.PublishDir ?? _appArguments.OutputDir,
Changelog = Path.GetFileName(_appArguments.ChangeLog), Changelog = Path.GetFileName(_appArguments.ChangeLog)
Channel = _appArguments.Channel
}; };
kattekerConfig.WriteToFile(pathToFile); kattekerConfig.WriteToFile(pathToFile);
return pathToFile; return pathToFile;
@ -159,7 +155,7 @@ namespace KattekerCreator
private string ModifyAppStub() private string ModifyAppStub()
{ {
var baseFile = new FileInfo(Path.Combine(_baseDirectory, Constants.ExecutionStub)); var baseFile = new FileInfo(Path.Combine(_baseDirectory, Constants.ExecutionStub));
var targetFile = baseFile.CopyTo(Path.Combine(_tempDir.Path, Constants.ExecutionStub)); var targetFile = baseFile.CopyTo(Path.Combine(_tempDir, Constants.ExecutionStub));
Utils.CopyResources(_appArguments.ProgramFile, targetFile.FullName); Utils.CopyResources(_appArguments.ProgramFile, targetFile.FullName);
return targetFile.FullName; return targetFile.FullName;
} }
@ -170,7 +166,7 @@ namespace KattekerCreator
{ {
try try
{ {
var outFile = Path.Combine(_tempDir.Path, GenerateFilename(_assemblyFileInfo.ProductName, _assemblyFileInfo.AssemblyVersion.ToString(), "nsi")); var outFile = Path.Combine(_tempDir, GenerateFilename(_assemblyFileInfo.ProductName, _assemblyFileInfo.AssemblyVersion.ToString(), "nsi"));
var setupTmpl = new SetupTmpl var setupTmpl = new SetupTmpl
{ {
Executable = _assemblyFileInfo.FileInfo.Name, Executable = _assemblyFileInfo.FileInfo.Name,

View File

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

View File

@ -34,9 +34,6 @@
<DocumentationFile>bin\Release\Katteker.UserInterface.xml</DocumentationFile> <DocumentationFile>bin\Release\Katteker.UserInterface.xml</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Katteker, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Katteker.1.1.0\lib\net45\Katteker.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
@ -62,7 +59,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="app.config" /> <None Include="app.config" />
<None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
@ -74,6 +70,12 @@
<DependentUpon>UpdateWindow.cs</DependentUpon> <DependentUpon>UpdateWindow.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Katteker\Katteker.csproj">
<Project>{a45e1c59-ba9e-452c-a5e2-50de49d53e92}</Project>
<Name>Katteker</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup> <PropertyGroup>
<PostBuildEvent> <PostBuildEvent>

View File

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

View File

@ -90,27 +90,30 @@ namespace Katteker
} }
changelogContent = changelogContent.ChangelogAsHtml(Path.GetExtension(Changelog)); changelogContent = changelogContent.ChangelogAsHtml(Path.GetExtension(Changelog));
InvokeOnGui(() => changelogBrowser.DocumentText = changelogContent); Invoke(new Action(() => changelogBrowser.DocumentText = changelogContent));
if (_entry == null) if (_entry == null)
{ {
WriteTitle(Resources.No_update_available); Invoke(new Action(() => { WriteTitle(Resources.No_update_available); }));
} }
else else
{ {
var latest = _entry.Version; var latest = _entry.Version;
WriteTitle(Resources.You_can_update_to_Version + latest); Invoke(new Action(() =>
InvokeOnGui(() => updBtn.Visible = true); {
WriteTitle(Resources.You_can_update_to_Version + latest);
updBtn.Visible = true;
}));
} }
} }
private async void UpdBtn_Click(object sender, EventArgs e) private async void UpdBtn_Click(object sender, EventArgs e)
{ {
InvokeOnGui(() => progressBar1.Visible = true); Invoke(new Action(() => progressBar1.Visible = true));
try try
{ {
var progress = new Progress<int>(x => InvokeOnGui(() => progressBar1.Value = x)); var progress = new Progress<int>(x => Invoke(new Action(() => { progressBar1.Value = x; })));
await _updateManager.UpdateAppAsync(progress).ConfigureAwait(false); await _updateManager.UpdateAppAsync(progress).ConfigureAwait(false);
WriteTitle(Resources.You_re_up_to_date); WriteTitle(Resources.You_re_up_to_date);
@ -121,12 +124,8 @@ namespace Katteker
MessageBoxIcon.Question); MessageBoxIcon.Question);
if (messResult == DialogResult.Yes) if (messResult == DialogResult.Yes)
{ {
InvokeOnGui(() => DialogResult = DialogResult.OK;
{ Close();
DialogResult = DialogResult.OK;
Close();
});
return;
} }
} }
catch (Exception ex) catch (Exception ex)
@ -135,34 +134,23 @@ namespace Katteker
Resources.Updater, MessageBoxButtons.OK, MessageBoxIcon.Error); Resources.Updater, MessageBoxButtons.OK, MessageBoxIcon.Error);
WriteTitle(Resources.Updater); WriteTitle(Resources.Updater);
} }
finally
InvokeOnGui(() =>
{ {
progressBar1.Visible = false; Invoke(new Action(() =>
updBtn.Visible = false; {
}); progressBar1.Visible = false;
updBtn.Visible = false;
}));
}
} }
private void WriteTitle(string text) private void WriteTitle(string text)
{ {
InvokeOnGui(() => Invoke(new Action(() =>
{ {
Text = text; Text = text;
titlebar.Text = text; titlebar.Text = text;
}); }));
}
private void InvokeOnGui(Action action)
{
if (Disposing || IsDisposed) return;
if (InvokeRequired)
{
Invoke(action);
}
else
{
action();
}
} }
} }
} }

View File

@ -1,4 +1,5 @@
using System.Linq; using System;
using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
@ -12,6 +13,7 @@ namespace Katteker
public static class UserInterface public static class UserInterface
{ {
private static UpdateManager _manager; private static UpdateManager _manager;
private static Action _restartApp;
/// <summary> /// <summary>
/// Checks for Updates. /// Checks for Updates.
@ -38,7 +40,8 @@ namespace Katteker
} }
var releases = (await _manager.CheckForUpdateAsync().ConfigureAwait(false)).ToArray(); var releases = (await _manager.CheckForUpdateAsync().ConfigureAwait(false)).ToArray();
if (releases.Length > 0 || !isStartup) _restartApp = () => _manager.RestartApp();
if (releases.Any() || !isStartup)
{ {
var thread = new Thread(ThreadProcess); var thread = new Thread(ThreadProcess);
thread.SetApartmentState(ApartmentState.STA); thread.SetApartmentState(ApartmentState.STA);
@ -55,7 +58,7 @@ namespace Katteker
var dialogResult = window.ShowDialog(); var dialogResult = window.ShowDialog();
if (dialogResult == DialogResult.OK) if (dialogResult == DialogResult.OK)
{ {
_manager.RestartApp(); _restartApp?.Invoke();
} }
} }
} }

View File

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

View File

@ -60,21 +60,33 @@
<Content Include="testdata\Example.exe"> <Content Include="testdata\Example.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="testdata\Example.pdb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="testdata\Example.vshost.exe"> <Content Include="testdata\Example.vshost.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="testdata\Katteker.dll"> <Content Include="testdata\Katteker.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="testdata\Katteker.pdb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="testdata\Katteker.UserInterface.dll"> <Content Include="testdata\Katteker.UserInterface.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="testdata\Katteker.UserInterface.pdb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="testdata\Katteker.UserInterface.xml"> <Content Include="testdata\Katteker.UserInterface.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="testdata\Microsoft.Practices.ServiceLocation.dll"> <Content Include="testdata\Microsoft.Practices.ServiceLocation.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="testdata\Microsoft.Practices.ServiceLocation.pdb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="testdata\Microsoft.Practices.ServiceLocation.xml"> <Content Include="testdata\Microsoft.Practices.ServiceLocation.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>

View File

@ -20,11 +20,6 @@ namespace Katteker
/// </summary> /// </summary>
public string Changelog { get; set; } public string Changelog { get; set; }
/// <summary>
/// Channel of the application. (Alpha, Beta and so on...)
/// </summary>
public string Channel { get; set; }
/// <summary> /// <summary>
/// Read file and deserialize content. /// Read file and deserialize content.
/// </summary> /// </summary>

View File

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

View File

@ -55,8 +55,7 @@ namespace Katteker
_config = ReadConfigFile(); _config = ReadConfigFile();
urlOrPath = urlOrPath ?? _config.Publish; urlOrPath = urlOrPath ?? _config.Publish;
var appName = applicationName ?? Utility.GetApplicationName(); var appName = applicationName ?? Utility.GetApplicationName();
var channel = string.IsNullOrWhiteSpace(_config.Channel) ? string.Empty : $"_{_config.Channel}"; var rootAppDirectory = Path.Combine(rootDirectory ?? Utility.GetLocalAppDataDirectory(), appName);
var rootAppDirectory = Path.Combine(rootDirectory ?? Utility.GetLocalAppDataDirectory(), appName + channel);
return new UpdateManager(urlOrPath, appName, rootAppDirectory); return new UpdateManager(urlOrPath, appName, rootAppDirectory);
} }