Merge branch 'master' of https://git.boerchers.org/holger/Katteker
This commit is contained in:
		| @@ -1,7 +1,7 @@ | |||||||
| <?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||||||
| <configuration> | <configuration> | ||||||
|     <startup>  |     <startup>  | ||||||
|         <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7"/> |         <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/> | ||||||
|     </startup> |     </startup> | ||||||
|   <runtime> |   <runtime> | ||||||
|     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||||||
|   | |||||||
| @@ -10,6 +10,7 @@ namespace KattekerCreator | |||||||
|         private string _outputDir; |         private string _outputDir; | ||||||
|         private string _programFile; |         private string _programFile; | ||||||
|         private string _publishDir; |         private string _publishDir; | ||||||
|  |         private string _version; | ||||||
|  |  | ||||||
|         [DisplayName("Program")] |         [DisplayName("Program")] | ||||||
|         [Description("Path to the program file")] |         [Description("Path to the program file")] | ||||||
| @@ -20,11 +21,11 @@ namespace KattekerCreator | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         [DisplayName("Changelog")] |         [DisplayName("Changelog")] | ||||||
|         [Description("Filename of the changelog file")] |         [Description("Path of the changelog file")] | ||||||
|         public string ChangeLog |         public string ChangeLog | ||||||
|         { |         { | ||||||
|             get => _changeLog; |             get => _changeLog; | ||||||
|             set => SetPropertyIfNotDefault(ref _changeLog, value); |             set => SetPropertyIfNotDefault(ref _changeLog, Path.GetFullPath(value)); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         [DisplayName("Channel")] |         [DisplayName("Channel")] | ||||||
| @@ -51,6 +52,14 @@ namespace KattekerCreator | |||||||
|             set => SetPropertyIfNotDefault(ref _publishDir, value); |             set => SetPropertyIfNotDefault(ref _publishDir, value); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         [DisplayName("Version")] | ||||||
|  |         [Description("Override version number of the application.")] | ||||||
|  |         public string Version | ||||||
|  |         { | ||||||
|  |             get => _version; | ||||||
|  |             set => SetPropertyIfNotDefault(ref _version, value); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         private static bool SetPropertyIfNotDefault<T>(ref T field, T value) |         private static bool SetPropertyIfNotDefault<T>(ref T field, T value) | ||||||
|         { |         { | ||||||
|             if (Equals(value, field)) return false; |             if (Equals(value, field)) return false; | ||||||
|   | |||||||
| @@ -2,7 +2,6 @@ | |||||||
| using System.Drawing; | using System.Drawing; | ||||||
| using System.IO; | using System.IO; | ||||||
| using System.Linq; | using System.Linq; | ||||||
| using Katteker; |  | ||||||
| using Semver; | using Semver; | ||||||
| using TsudaKageyu; | using TsudaKageyu; | ||||||
| using Vestris.ResourceLib; | using Vestris.ResourceLib; | ||||||
| @@ -16,17 +15,17 @@ namespace KattekerCreator | |||||||
|         private readonly string _description; |         private readonly string _description; | ||||||
|         private readonly string _productName; |         private readonly string _productName; | ||||||
|  |  | ||||||
|         public AssemblyFileInfo(string fileName, string tempDir) |         public AssemblyFileInfo(ApplicationArguments appArguments, string tempDir) | ||||||
|         { |         { | ||||||
|             FileInfo = new FileInfo(fileName); |             FileInfo = new FileInfo(appArguments.ProgramFile); | ||||||
|             using (var resourceInfo = new ResourceInfo()) |             using (var resourceInfo = new ResourceInfo()) | ||||||
|             { |             { | ||||||
|                 resourceInfo.Load(fileName); |                 resourceInfo.Load(appArguments.ProgramFile); | ||||||
|                 if (resourceInfo.ResourceTypes.All(x => x.ResourceType != Kernel32.ResourceTypes.RT_VERSION)) return; |                 if (resourceInfo.ResourceTypes.All(x => x.ResourceType != Kernel32.ResourceTypes.RT_VERSION)) return; | ||||||
|                 var versionResource = (VersionResource) resourceInfo[Kernel32.ResourceTypes.RT_VERSION].First(); |                 var versionResource = (VersionResource) resourceInfo[Kernel32.ResourceTypes.RT_VERSION].First(); | ||||||
|                 var stringFileInfo = ((StringFileInfo) versionResource[nameof(StringFileInfo)]).Strings |                 var stringFileInfo = ((StringFileInfo) versionResource[nameof(StringFileInfo)]).Strings | ||||||
|                     .FirstOrDefault().Value; |                     .FirstOrDefault().Value; | ||||||
|                 AssemblyIconPath = GetAssemblyIcon(fileName, tempDir); |                 AssemblyIconPath = GetAssemblyIcon(appArguments.ProgramFile, tempDir); | ||||||
|                 if (stringFileInfo.Strings.ContainsKey("CompanyName")) |                 if (stringFileInfo.Strings.ContainsKey("CompanyName")) | ||||||
|                     _company = stringFileInfo.Strings["CompanyName"].StringValue.TrimEnd('\0'); |                     _company = stringFileInfo.Strings["CompanyName"].StringValue.TrimEnd('\0'); | ||||||
|                 if (stringFileInfo.Strings.ContainsKey("FileDescription")) |                 if (stringFileInfo.Strings.ContainsKey("FileDescription")) | ||||||
| @@ -36,14 +35,13 @@ namespace KattekerCreator | |||||||
|                 if (stringFileInfo.Strings.ContainsKey("ProductName")) |                 if (stringFileInfo.Strings.ContainsKey("ProductName")) | ||||||
|                     _productName = stringFileInfo.Strings["ProductName"].StringValue.TrimEnd('\0'); |                     _productName = stringFileInfo.Strings["ProductName"].StringValue.TrimEnd('\0'); | ||||||
|                 if (!stringFileInfo.Strings.ContainsKey("ProductVersion")) return; |                 if (!stringFileInfo.Strings.ContainsKey("ProductVersion")) return; | ||||||
|                 AssemblyVersion = |                 AssemblyVersion = appArguments.Version != null ? GetSemanticVersion(appArguments.Version) : GetSemanticVersion(stringFileInfo.Strings["ProductVersion"].StringValue.TrimEnd('\0')); | ||||||
|                     GetSemanticVersion(stringFileInfo.Strings["ProductVersion"].StringValue.TrimEnd('\0')); |  | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public string AssemblyIconPath { get; } |         public string AssemblyIconPath { get; } | ||||||
|  |  | ||||||
|         public SemVersion AssemblyVersion { get; private set; } |         public SemVersion AssemblyVersion { get; } | ||||||
|  |  | ||||||
|         public string Company => _company ?? string.Empty; |         public string Company => _company ?? string.Empty; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,4 +1,5 @@ | |||||||
| using System; | using System; | ||||||
|  | using System.Threading; | ||||||
|  |  | ||||||
| namespace KattekerCreator.Helper | namespace KattekerCreator.Helper | ||||||
| { | { | ||||||
| @@ -9,17 +10,17 @@ namespace KattekerCreator.Helper | |||||||
|  |  | ||||||
|         public static void WriteInfoLine(string text) |         public static void WriteInfoLine(string text) | ||||||
|         { |         { | ||||||
|             using (var c = new ConsoleWithOtherColor()) |             using (new ConsoleWithOtherColor()) | ||||||
|             { |             { | ||||||
|                 c.WriteLine($"{Info} [{DateTime.Now:G}] {text}"); |                 ConsoleWithOtherColor.WriteLine($"{Info} [{DateTime.Now:G}] {text}"); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public static void WriteErrorLine(string text) |         public static void WriteErrorLine(string text) | ||||||
|         { |         { | ||||||
|             using (var c = new ConsoleWithOtherColor(ConsoleColor.DarkRed)) |             using (new ConsoleWithOtherColor(ConsoleColor.DarkRed)) | ||||||
|             { |             { | ||||||
|                 c.WriteLine($"{Error} [{DateTime.Now:G}] {text}"); |                 ConsoleWithOtherColor.WriteLine($"{Error} [{DateTime.Now:G}] {text}"); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -38,13 +39,20 @@ namespace KattekerCreator.Helper | |||||||
|             Console.ForegroundColor = color; |             Console.ForegroundColor = color; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public void WriteLine(string text) |         public static void WriteLine(string text) | ||||||
|         { |         { | ||||||
|             Console.WriteLine(text); |             Console.WriteLine(text); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public void Dispose() |         public void Dispose() | ||||||
|         { |         { | ||||||
|  |             Dispose(true); | ||||||
|  |             GC.SuppressFinalize(this); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private void Dispose(bool disposing) | ||||||
|  |         { | ||||||
|  |             if (!disposing) return; | ||||||
|             if (_defaultColor != null) Console.ForegroundColor = _defaultColor.Value; |             if (_defaultColor != null) Console.ForegroundColor = _defaultColor.Value; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ | |||||||
|     <AppDesignerFolder>Properties</AppDesignerFolder> |     <AppDesignerFolder>Properties</AppDesignerFolder> | ||||||
|     <RootNamespace>KattekerCreator</RootNamespace> |     <RootNamespace>KattekerCreator</RootNamespace> | ||||||
|     <AssemblyName>KattekerCreator</AssemblyName> |     <AssemblyName>KattekerCreator</AssemblyName> | ||||||
|     <TargetFrameworkVersion>v4.7</TargetFrameworkVersion> |     <TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion> | ||||||
|     <FileAlignment>512</FileAlignment> |     <FileAlignment>512</FileAlignment> | ||||||
|     <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir> |     <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir> | ||||||
|     <RestorePackages>true</RestorePackages> |     <RestorePackages>true</RestorePackages> | ||||||
|   | |||||||
| @@ -56,7 +56,7 @@ namespace KattekerCreator | |||||||
|             //Modify AppStub |             //Modify AppStub | ||||||
|             var appStubFile = ModifyAppStub(); |             var appStubFile = ModifyAppStub(); | ||||||
|             //Acquire infos from Executable. |             //Acquire infos from Executable. | ||||||
|             _assemblyFileInfo = new AssemblyFileInfo(_appArguments.ProgramFile, _tempDir); |             _assemblyFileInfo = new AssemblyFileInfo(_appArguments, _tempDir); | ||||||
|             var configFile = CreateConfigFile(); |             var configFile = CreateConfigFile(); | ||||||
|  |  | ||||||
|             //Generate NSIS-Script |             //Generate NSIS-Script | ||||||
| @@ -109,9 +109,10 @@ namespace KattekerCreator | |||||||
|             if (!Directory.Exists(_appArguments.OutputDir)) Directory.CreateDirectory(_appArguments.OutputDir); |             if (!Directory.Exists(_appArguments.OutputDir)) Directory.CreateDirectory(_appArguments.OutputDir); | ||||||
|             if (!string.IsNullOrEmpty(_appArguments.ChangeLog)) |             if (!string.IsNullOrEmpty(_appArguments.ChangeLog)) | ||||||
|             { |             { | ||||||
|                 var changeLogPath = Path.Combine(Path.GetDirectoryName(_appArguments.ProgramFile), _appArguments.ChangeLog); |                 var changeLogFilename = Path.GetFileName(_appArguments.ChangeLog); | ||||||
|                 if (!File.Exists(changeLogPath)) throw new FileNotFoundException(changeLogPath); |  | ||||||
|                 File.Copy(changeLogPath, Path.Combine(_appArguments.OutputDir, _appArguments.ChangeLog), true); |                 if (!File.Exists(_appArguments.ChangeLog)) throw new FileNotFoundException(_appArguments.ChangeLog); | ||||||
|  |                 File.Copy(_appArguments.ChangeLog, Path.Combine(_appArguments.OutputDir, changeLogFilename), true); | ||||||
|             } |             } | ||||||
|             File.Copy(setupFilePath, Path.Combine(_appArguments.OutputDir, setupFile), true); |             File.Copy(setupFilePath, Path.Combine(_appArguments.OutputDir, setupFile), true); | ||||||
|         } |         } | ||||||
| @@ -145,7 +146,7 @@ namespace KattekerCreator | |||||||
|             var kattekerConfig = new KattekerConfig |             var kattekerConfig = new KattekerConfig | ||||||
|             { |             { | ||||||
|                 Publish = _appArguments.PublishDir ?? _appArguments.OutputDir, |                 Publish = _appArguments.PublishDir ?? _appArguments.OutputDir, | ||||||
|                 Changelog = _appArguments.ChangeLog |                 Changelog = Path.GetFileName(_appArguments.ChangeLog) | ||||||
|             }; |             }; | ||||||
|             kattekerConfig.WriteToFile(pathToFile); |             kattekerConfig.WriteToFile(pathToFile); | ||||||
|             return pathToFile; |             return pathToFile; | ||||||
|   | |||||||
| @@ -42,6 +42,7 @@ | |||||||
|     <Reference Include="System.Xml" /> |     <Reference Include="System.Xml" /> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|  |     <Compile Include="NativeMethods.cs" /> | ||||||
|     <Compile Include="Wrapper.cs" /> |     <Compile Include="Wrapper.cs" /> | ||||||
|     <Compile Include="Properties\AssemblyInfo.cs" /> |     <Compile Include="Properties\AssemblyInfo.cs" /> | ||||||
|     <Compile Include="Properties\Resources.Designer.cs"> |     <Compile Include="Properties\Resources.Designer.cs"> | ||||||
|   | |||||||
							
								
								
									
										41
									
								
								Katteker.Gui/NativeMethods.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								Katteker.Gui/NativeMethods.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,41 @@ | |||||||
|  | using System; | ||||||
|  | using System.Runtime.InteropServices; | ||||||
|  |  | ||||||
|  | // ReSharper disable InconsistentNaming | ||||||
|  |  | ||||||
|  | namespace Katteker.Gui | ||||||
|  | { | ||||||
|  |     /// <summary> | ||||||
|  |     ///     Native methods. | ||||||
|  |     /// </summary> | ||||||
|  |     public static class NativeMethods | ||||||
|  |     { | ||||||
|  |         /// <summary> | ||||||
|  |         ///     Hit Test Caption | ||||||
|  |         /// </summary> | ||||||
|  |         public const int HTCAPTION = 0x2; | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         ///     Posted when the user presses the left mouse button while the cursor is within the nonclient area of a window. | ||||||
|  |         /// </summary> | ||||||
|  |         public const int WM_NCLBUTTONDOWN = 0xA1; | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         ///     Release the capture | ||||||
|  |         /// </summary> | ||||||
|  |         [DllImport("User32.dll")] | ||||||
|  |         public static extern bool ReleaseCapture(); | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         ///     Send message | ||||||
|  |         /// </summary> | ||||||
|  |         [DllImport("User32.dll")] | ||||||
|  |         public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         ///     Set Process API aware | ||||||
|  |         /// </summary> | ||||||
|  |         [DllImport("user32.dll")] | ||||||
|  |         public static extern bool SetProcessDPIAware(); | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -1,7 +1,6 @@ | |||||||
| using System; | using System; | ||||||
| using System.Drawing; | using System.Drawing; | ||||||
| using System.IO; | using System.IO; | ||||||
| using System.Runtime.InteropServices; |  | ||||||
| using System.Windows.Forms; | using System.Windows.Forms; | ||||||
| using Katteker.Gui.Properties; | using Katteker.Gui.Properties; | ||||||
|  |  | ||||||
| @@ -9,10 +8,8 @@ namespace Katteker.Gui | |||||||
| { | { | ||||||
|     public sealed partial class UpdateWindow : Form |     public sealed partial class UpdateWindow : Form | ||||||
|     { |     { | ||||||
|         private readonly UpdateManager _updateManager; |  | ||||||
|         private readonly ReleaseEntry _entry; |         private readonly ReleaseEntry _entry; | ||||||
|         private const int HTCAPTION = 0x2; |         private readonly UpdateManager _updateManager; | ||||||
|         private const int WM_NCLBUTTONDOWN = 0xA1; |  | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         ///     The Update Window |         ///     The Update Window | ||||||
| @@ -24,7 +21,7 @@ namespace Katteker.Gui | |||||||
|             Font = SystemFonts.MessageBoxFont; |             Font = SystemFonts.MessageBoxFont; | ||||||
|             Application.EnableVisualStyles(); |             Application.EnableVisualStyles(); | ||||||
|             if (Environment.OSVersion.Version.Major >= 6) |             if (Environment.OSVersion.Version.Major >= 6) | ||||||
|                 SetProcessDPIAware(); |                 NativeMethods.SetProcessDPIAware(); | ||||||
|             InitializeComponent(); |             InitializeComponent(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -39,21 +36,10 @@ namespace Katteker.Gui | |||||||
|         /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> |         /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> | ||||||
|         protected override void Dispose(bool disposing) |         protected override void Dispose(bool disposing) | ||||||
|         { |         { | ||||||
|             if (disposing) |             if (disposing) components?.Dispose(); | ||||||
|             { |  | ||||||
|                 components?.Dispose(); |  | ||||||
|             } |  | ||||||
|             base.Dispose(disposing); |             base.Dispose(disposing); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         [DllImport("User32.dll")] |  | ||||||
|         private static extern bool ReleaseCapture(); |  | ||||||
|  |  | ||||||
|         [DllImport("User32.dll")] |  | ||||||
|         private static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); |  | ||||||
|  |  | ||||||
|         [DllImport("user32.dll")] |  | ||||||
|         private static extern bool SetProcessDPIAware(); |  | ||||||
|         private void CloseBtn_Click(object sender, EventArgs e) |         private void CloseBtn_Click(object sender, EventArgs e) | ||||||
|         { |         { | ||||||
|             Close(); |             Close(); | ||||||
| @@ -76,9 +62,10 @@ namespace Katteker.Gui | |||||||
|                 MaximizeBtn_Click(sender, e); |                 MaximizeBtn_Click(sender, e); | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             if (e.Button != MouseButtons.Left) return; |             if (e.Button != MouseButtons.Left) return; | ||||||
|             ReleaseCapture(); |             NativeMethods.ReleaseCapture(); | ||||||
|             SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0); |             NativeMethods.SendMessage(Handle, NativeMethods.WM_NCLBUTTONDOWN, NativeMethods.HTCAPTION, 0); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -137,9 +124,9 @@ namespace Katteker.Gui | |||||||
|             } |             } | ||||||
|             catch (Exception ex) |             catch (Exception ex) | ||||||
|             { |             { | ||||||
|                 MessageBox.Show(Resources.CouldNotUpdateYourApplication + Environment.NewLine + ex.Message, Gui.Properties.Resources.Updater, MessageBoxButtons.OK, MessageBoxIcon.Error); |                 MessageBox.Show(Resources.CouldNotUpdateYourApplication + Environment.NewLine + ex.Message, | ||||||
|  |                     Resources.Updater, MessageBoxButtons.OK, MessageBoxIcon.Error); | ||||||
|                 WriteTitle(Resources.Updater); |                 WriteTitle(Resources.Updater); | ||||||
|  |  | ||||||
|             } |             } | ||||||
|             finally |             finally | ||||||
|             { |             { | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| <?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||||||
| <Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | <Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||||||
|   <Import Project="..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props')" /> |   <Import Project="..\packages\MSTest.TestAdapter.1.3.0\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.1.3.0\build\net45\MSTest.TestAdapter.props')" /> | ||||||
|   <PropertyGroup> |   <PropertyGroup> | ||||||
|     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||||||
|     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||||||
| @@ -39,10 +39,10 @@ | |||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> |     <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | ||||||
|       <HintPath>..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath> |       <HintPath>..\packages\MSTest.TestFramework.1.3.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath> | ||||||
|     </Reference> |     </Reference> | ||||||
|     <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> |     <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | ||||||
|       <HintPath>..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath> |       <HintPath>..\packages\MSTest.TestFramework.1.3.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath> | ||||||
|     </Reference> |     </Reference> | ||||||
|     <Reference Include="System" /> |     <Reference Include="System" /> | ||||||
|     <Reference Include="System.Core" /> |     <Reference Include="System.Core" /> | ||||||
| @@ -51,9 +51,6 @@ | |||||||
|     <Compile Include="KattekerLibTest.cs" /> |     <Compile Include="KattekerLibTest.cs" /> | ||||||
|     <Compile Include="Properties\AssemblyInfo.cs" /> |     <Compile Include="Properties\AssemblyInfo.cs" /> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|   <ItemGroup> |  | ||||||
|     <None Include="packages.config" /> |  | ||||||
|   </ItemGroup> |  | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <Content Include="testdata\Example.exe"> |     <Content Include="testdata\Example.exe"> | ||||||
|       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||||||
| @@ -65,14 +62,17 @@ | |||||||
|       <Name>Katteker</Name> |       <Name>Katteker</Name> | ||||||
|     </ProjectReference> |     </ProjectReference> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|  |   <ItemGroup> | ||||||
|  |     <None Include="packages.config" /> | ||||||
|  |   </ItemGroup> | ||||||
|   <Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" /> |   <Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" /> | ||||||
|   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||||||
|   <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> |   <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> | ||||||
|     <PropertyGroup> |     <PropertyGroup> | ||||||
|       <ErrorText>Dieses Projekt verweist auf mindestens ein NuGet-Paket, das auf diesem Computer fehlt. Verwenden Sie die Wiederherstellung von NuGet-Paketen, um die fehlenden Dateien herunterzuladen. Weitere Informationen finden Sie unter "http://go.microsoft.com/fwlink/?LinkID=322105". Die fehlende Datei ist "{0}".</ErrorText> |       <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> | ||||||
|     </PropertyGroup> |     </PropertyGroup> | ||||||
|     <Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props'))" /> |     <Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.3.0\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.3.0\build\net45\MSTest.TestAdapter.props'))" /> | ||||||
|     <Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.targets'))" /> |     <Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.3.0\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.3.0\build\net45\MSTest.TestAdapter.targets'))" /> | ||||||
|   </Target> |   </Target> | ||||||
|   <Import Project="..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.targets')" /> |   <Import Project="..\packages\MSTest.TestAdapter.1.3.0\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.1.3.0\build\net45\MSTest.TestAdapter.targets')" /> | ||||||
| </Project> | </Project> | ||||||
| @@ -15,7 +15,7 @@ namespace Katteker.Test | |||||||
|         public void Sha1ChecksumOfFile() |         public void Sha1ChecksumOfFile() | ||||||
|         { |         { | ||||||
|             var actual = Utility.ComputeFileHash(ExampleFile); |             var actual = Utility.ComputeFileHash(ExampleFile); | ||||||
|             const string expected = "0zgDmFuotnldZIyADoWrpiSDUx4="; |             const string expected = "maFpV7FK3EtnU2G5+q2nZ1E3YKY="; | ||||||
|             Assert.AreEqual(expected, actual); |             Assert.AreEqual(expected, actual); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| <?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||||||
| <packages> | <packages> | ||||||
|   <package id="MSTest.TestAdapter" version="1.2.0" targetFramework="net461" /> |   <package id="MSTest.TestAdapter" version="1.3.0" targetFramework="net461" /> | ||||||
|   <package id="MSTest.TestFramework" version="1.2.0" targetFramework="net461" /> |   <package id="MSTest.TestFramework" version="1.3.0" targetFramework="net461" /> | ||||||
| </packages> | </packages> | ||||||
| @@ -22,7 +22,6 @@ namespace Katteker | |||||||
|         [DataMember] |         [DataMember] | ||||||
|         public string Changelog { get; set; } |         public string Changelog { get; set; } | ||||||
|  |  | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Read file and deserialize content. |         /// Read file and deserialize content. | ||||||
|         /// </summary> |         /// </summary> | ||||||
|   | |||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1,7 +1,7 @@ | |||||||
| using System; | using Semver; | ||||||
|  | using System; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| using System.Text.RegularExpressions; | using System.Text.RegularExpressions; | ||||||
| using Semver; |  | ||||||
|  |  | ||||||
| namespace Katteker | namespace Katteker | ||||||
| { | { | ||||||
| @@ -59,26 +59,32 @@ namespace Katteker | |||||||
|         /// Version |         /// Version | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         public SemVersion Version { get; } |         public SemVersion Version { get; } | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Hashsum of the file. |         /// Hashsum of the file. | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         public string SHA1 { get; } |         public string SHA1 { get; } | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// filename |         /// filename | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         public string Filename { get; } |         public string Filename { get; } | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Size of the file. |         /// Size of the file. | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         public long Filesize { get; } |         public long Filesize { get; } | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Is true if the update is delta file. False otherwise. |         /// Is true if the update is delta file. False otherwise. | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         public bool IsDelta { get; } |         public bool IsDelta { get; } | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Name of the application. |         /// Name of the application. | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         public string ApplicationName { get; } |         public string ApplicationName { get; } | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Format the release entry as line for release file. |         /// Format the release entry as line for release file. | ||||||
|         /// </summary> |         /// </summary> | ||||||
|   | |||||||
| @@ -81,6 +81,10 @@ namespace Katteker | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Check for updates | ||||||
|  |         /// </summary> | ||||||
|  |         /// <returns></returns> | ||||||
|         public async Task<IEnumerable<ReleaseEntry>> CheckForUpdateAsync() |         public async Task<IEnumerable<ReleaseEntry>> CheckForUpdateAsync() | ||||||
|         { |         { | ||||||
|             _releases = Utility.IsWebUrl(_urlOrPath) ? await DownloadIndexAsync(_urlOrPath).ConfigureAwait(false) : GetFromFilesystem(_urlOrPath); |             _releases = Utility.IsWebUrl(_urlOrPath) ? await DownloadIndexAsync(_urlOrPath).ConfigureAwait(false) : GetFromFilesystem(_urlOrPath); | ||||||
|   | |||||||
| @@ -30,21 +30,18 @@ namespace Katteker | |||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Compute file hash with SHA1.  |         /// Compute file hash with SHA1.  | ||||||
|         /// If the file is greater than 5 MB, the hash will only computed with the first 5 MB. |  | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         /// <param name="filename"></param> |         /// <param name="filename"></param> | ||||||
|         /// <returns></returns> |         /// <returns>Returns the hash as base64 string</returns> | ||||||
|         internal static string ComputeFileHash(string filename) |         internal static string ComputeFileHash(string filename) | ||||||
|         { |         { | ||||||
|             string sha1; |             string sha1; | ||||||
|             var fileInfo = new FileInfo(filename); |             var fileInfo = new FileInfo(filename); | ||||||
|  |  | ||||||
|  |             using (var sha1Managed = new SHA1Managed()) | ||||||
|             using (var fileStream = fileInfo.OpenRead()) |             using (var fileStream = fileInfo.OpenRead()) | ||||||
|             { |             { | ||||||
|                 var buffer = new byte[5242880]; |                 sha1 = Convert.ToBase64String(sha1Managed.ComputeHash(fileStream)); | ||||||
|                 fileStream.Read(buffer, 0, buffer.Length); |  | ||||||
|                 var sha1Managed = new SHA1Managed(); |  | ||||||
|                 sha1 = Convert.ToBase64String(sha1Managed.ComputeHash(buffer)); |  | ||||||
|             } |             } | ||||||
|             return sha1; |             return sha1; | ||||||
|         } |         } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Holger Boerchers
					Holger Boerchers