Fixed a lot of "in the wild" problems.

This commit is contained in:
Holger Börchers 2018-08-02 12:55:50 +02:00
parent d85858b0c1
commit ec576558c8
10 changed files with 59 additions and 41 deletions

View File

@ -149,7 +149,8 @@ namespace KattekerCreator
var kattekerConfig = new KattekerConfig
{
Publish = _appArguments.PublishDir ?? _appArguments.OutputDir,
Changelog = Path.GetFileName(_appArguments.ChangeLog)
Changelog = Path.GetFileName(_appArguments.ChangeLog),
Channel = _appArguments.Channel
};
kattekerConfig.WriteToFile(pathToFile);
return pathToFile;

View File

@ -31,6 +31,6 @@ 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: AssemblyVersion("1.0.1.0")]
[assembly: AssemblyFileVersion("1.0.1.0")]

View File

@ -34,6 +34,9 @@
<DocumentationFile>bin\Release\Katteker.UserInterface.xml</DocumentationFile>
</PropertyGroup>
<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="System" />
<Reference Include="System.Core" />
@ -59,6 +62,7 @@
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
@ -70,12 +74,6 @@
<DependentUpon>UpdateWindow.cs</DependentUpon>
</EmbeddedResource>
</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" />
<PropertyGroup>
<PostBuildEvent>

View File

@ -31,5 +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")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyVersion("1.1.4")]
[assembly: AssemblyFileVersion("1.1.4")]

View File

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

View File

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

View File

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

View File

@ -7,7 +7,7 @@ namespace Katteker
/// <summary>
/// Configuration of a Katteker-Deployment
/// </summary>
[Serializable]
[Serializable]
public class KattekerConfig
{
/// <summary>
@ -20,6 +20,11 @@ namespace Katteker
/// </summary>
public string Changelog { get; set; }
/// <summary>
/// Channel of the application. (Alpha, Beta and so on...)
/// </summary>
public string Channel { get; set; }
/// <summary>
/// Read file and deserialize content.
/// </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,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.0")]
[assembly: AssemblyFileVersion("1.1.0")]
[assembly: AssemblyVersion("1.1.1")]
[assembly: AssemblyFileVersion("1.1.1")]
[assembly: InternalsVisibleTo("Katteker.Test")]

View File

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