Quellcode durchsuchen

Added Update Channels

flabbet vor 3 Jahren
Ursprung
Commit
72a3535552

+ 14 - 14
Installer/installer-setup-x64-light.iss

@@ -4,8 +4,8 @@
 // requires netcorecheck.exe and netcorecheck_x64.exe (see download link below)
 #define UseNetCoreCheck
 #ifdef UseNetCoreCheck
-  ;#define UseDotNet50
-  #define UseDotNet50Desktop
+  ;#define UseDotNet60
+  #define UseDotNet60Desktop
 #endif
 
 // custom setup info
@@ -396,24 +396,24 @@ var
   Version: String;
 begin
 
-#ifdef UseDotNet50
-  // https://dotnet.microsoft.com/download/dotnet/5.0
-  if not IsNetCoreInstalled('Microsoft.NETCore.App 5.0.0') then begin
-    AddDependency('dotnet50' + GetArchitectureSuffix + '.exe',
+#ifdef UseDotNet60
+  // https://dotnet.microsoft.com/download/dotnet/6.0
+  if not IsNetCoreInstalled('Microsoft.NETCore.App 6.0.0') then begin
+    AddDependency('dotnet60' + GetArchitectureSuffix + '.exe',
       '/lcid ' + IntToStr(GetUILanguage) + ' /passive /norestart',
-      '.NET Runtime 5.0' + GetArchitectureTitle,
-      GetString('https://download.visualstudio.microsoft.com/download/pr/a7e15da3-7a15-43c2-a481-cf50bf305214/c69b951e8b47101e90b1289c387bb01a/dotnet-runtime-5.0.0-win-x86.exe', 'https://download.visualstudio.microsoft.com/download/pr/36a9dc4e-1745-4f17-8a9c-f547a12e3764/ae25e38f20a4854d5e015a88659a22f9/dotnet-runtime-5.0.0-win-x64.exe'),
+      '.NET Runtime 6.0' + GetArchitectureTitle,
+      GetString('https://download.visualstudio.microsoft.com/download/pr/34df41d5-c813-4e30-8aa3-3603ce6600c0/976e801af82c7108abbcb736a8bc5c14/dotnet-runtime-6.0.0-win-x86.exe', 'https://download.visualstudio.microsoft.com/download/pr/b9cfdb9e-d5cd-4024-b318-00390b729d2f/65690f2440f40654898020cdfffa1050/dotnet-runtime-6.0.0-win-x64.exe'),
       '', False, False, False);
   end;
 #endif
 
-#ifdef UseDotNet50Desktop
-  // https://dotnet.microsoft.com/download/dotnet/5.0
-  if not IsNetCoreInstalled('Microsoft.WindowsDesktop.App 5.0.0') then begin
-    AddDependency('dotnet50desktop' + GetArchitectureSuffix + '.exe',
+#ifdef UseDotNet60Desktop
+  // https://dotnet.microsoft.com/download/dotnet/6.0
+  if not IsNetCoreInstalled('Microsoft.WindowsDesktop.App 6.0.0') then begin
+    AddDependency('dotnet60desktop' + GetArchitectureSuffix + '.exe',
       '/lcid ' + IntToStr(GetUILanguage) + ' /passive /norestart',
-      '.NET Desktop Runtime 5.0' + GetArchitectureTitle,
-      GetString('https://download.visualstudio.microsoft.com/download/pr/b2780d75-e54a-448a-95fc-da9721b2b4c2/62310a9e9f0ba7b18741944cbae9f592/windowsdesktop-runtime-5.0.0-win-x86.exe', 'https://download.visualstudio.microsoft.com/download/pr/1b3a8899-127a-4465-a3c2-7ce5e4feb07b/1e153ad470768baa40ed3f57e6e7a9d8/windowsdesktop-runtime-5.0.0-win-x64.exe'),
+      '.NET Desktop Runtime 6.0' + GetArchitectureTitle,
+      GetString('https://download.visualstudio.microsoft.com/download/pr/a1ca7d0d-ce01-4878-b952-3fa1e6d9a7c6/e386db367490b631b8c013a9fb0f3794/windowsdesktop-runtime-6.0.0-win-x86.exe', 'https://download.visualstudio.microsoft.com/download/pr/a865ccae-2219-4184-bcd6-0178dc580589/ba452d37e8396b7a49a9adc0e1a07e87/windowsdesktop-runtime-6.0.0-win-x64.exe'),
       '', False, False, False);
   end;
 #endif

+ 14 - 14
Installer/installer-setup-x86-light.iss

@@ -4,8 +4,8 @@
 // requires netcorecheck.exe and netcorecheck_x64.exe (see download link below)
 #define UseNetCoreCheck
 #ifdef UseNetCoreCheck
-  ;#define UseDotNet50
-  #define UseDotNet50Desktop
+  ;#define UseDotNet60
+  #define UseDotNet60Desktop
 #endif
 
 // custom setup info
@@ -395,24 +395,24 @@ var
   Version: String;
 begin
 
-#ifdef UseDotNet50
-  // https://dotnet.microsoft.com/download/dotnet/5.0
-  if not IsNetCoreInstalled('Microsoft.NETCore.App 5.0.0') then begin
-    AddDependency('dotnet50' + GetArchitectureSuffix + '.exe',
+#ifdef UseDotNet60
+  // https://dotnet.microsoft.com/download/dotnet/6.0
+  if not IsNetCoreInstalled('Microsoft.NETCore.App 6.0.0') then begin
+    AddDependency('dotnet60' + GetArchitectureSuffix + '.exe',
       '/lcid ' + IntToStr(GetUILanguage) + ' /passive /norestart',
-      '.NET Runtime 5.0' + GetArchitectureTitle,
-      GetString('https://download.visualstudio.microsoft.com/download/pr/a7e15da3-7a15-43c2-a481-cf50bf305214/c69b951e8b47101e90b1289c387bb01a/dotnet-runtime-5.0.0-win-x86.exe', 'https://download.visualstudio.microsoft.com/download/pr/36a9dc4e-1745-4f17-8a9c-f547a12e3764/ae25e38f20a4854d5e015a88659a22f9/dotnet-runtime-5.0.0-win-x64.exe'),
+      '.NET Runtime 6.0' + GetArchitectureTitle,
+      GetString('https://download.visualstudio.microsoft.com/download/pr/34df41d5-c813-4e30-8aa3-3603ce6600c0/976e801af82c7108abbcb736a8bc5c14/dotnet-runtime-6.0.0-win-x86.exe', 'https://download.visualstudio.microsoft.com/download/pr/b9cfdb9e-d5cd-4024-b318-00390b729d2f/65690f2440f40654898020cdfffa1050/dotnet-runtime-6.0.0-win-x64.exe'),
       '', False, False, False);
   end;
 #endif
 
-#ifdef UseDotNet50Desktop
-  // https://dotnet.microsoft.com/download/dotnet/5.0
-  if not IsNetCoreInstalled('Microsoft.WindowsDesktop.App 5.0.0') then begin
-    AddDependency('dotnet50desktop' + GetArchitectureSuffix + '.exe',
+#ifdef UseDotNet60Desktop
+  // https://dotnet.microsoft.com/download/dotnet/6.0
+  if not IsNetCoreInstalled('Microsoft.WindowsDesktop.App 6.0.0') then begin
+    AddDependency('dotnet60desktop' + GetArchitectureSuffix + '.exe',
       '/lcid ' + IntToStr(GetUILanguage) + ' /passive /norestart',
-      '.NET Desktop Runtime 5.0' + GetArchitectureTitle,
-      GetString('https://download.visualstudio.microsoft.com/download/pr/b2780d75-e54a-448a-95fc-da9721b2b4c2/62310a9e9f0ba7b18741944cbae9f592/windowsdesktop-runtime-5.0.0-win-x86.exe', 'https://download.visualstudio.microsoft.com/download/pr/1b3a8899-127a-4465-a3c2-7ce5e4feb07b/1e153ad470768baa40ed3f57e6e7a9d8/windowsdesktop-runtime-5.0.0-win-x64.exe'),
+      '.NET Desktop Runtime 6.0' + GetArchitectureTitle,
+      GetString('https://download.visualstudio.microsoft.com/download/pr/a1ca7d0d-ce01-4878-b952-3fa1e6d9a7c6/e386db367490b631b8c013a9fb0f3794/windowsdesktop-runtime-6.0.0-win-x86.exe', 'https://download.visualstudio.microsoft.com/download/pr/a865ccae-2219-4184-bcd6-0178dc580589/ba452d37e8396b7a49a9adc0e1a07e87/windowsdesktop-runtime-6.0.0-win-x64.exe'),
       '', False, False, False);
   end;
 #endif

+ 26 - 0
PixiEditor.UpdateModule/UpdateChannel.cs

@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PixiEditor.UpdateModule
+{
+    public class UpdateChannel
+    {
+        public string Name { get; }
+        public string RepositoryOwner { get; }
+        public string RepositoryName { get; }
+        public string ApiUrl { get; } 
+        public string IncompatibleFileApiUrl { get; }
+
+        public UpdateChannel(string name, string repositoryOwner, string repositoryName)
+        {
+            Name = name;
+            RepositoryOwner = repositoryOwner;
+            RepositoryName = repositoryName;
+            ApiUrl = $"https://api.github.com/repos/{repositoryOwner}/{repositoryName}/releases/latest";
+            IncompatibleFileApiUrl = "https://raw.githubusercontent.com/" + $"{repositoryOwner}/{repositoryName}/" + "{0}/incompatible.json";
+        }
+    }
+}

+ 8 - 8
PixiEditor.UpdateModule/UpdateChecker.cs

@@ -10,16 +10,16 @@ namespace PixiEditor.UpdateModule
 {
     public class UpdateChecker
     {
-        private const string ReleaseApiUrl = "https://api.github.com/repos/PixiEditor/PixiEditor/releases/latest";
-        private const string IncompatibleFileApiUrl = "https://raw.githubusercontent.com/PixiEditor/PixiEditor/{0}/incompatible.json";
-
-        public UpdateChecker(string currentVersionTag)
+        public UpdateChecker(string currentVersionTag, UpdateChannel channel)
         {
             CurrentVersionTag = currentVersionTag;
+            Channel = channel;
         }
 
         public ReleaseInfo LatestReleaseInfo { get; private set; }
 
+        public UpdateChannel Channel { get; set; }
+
         public string CurrentVersionTag { get; }
 
         /// <summary>
@@ -45,7 +45,7 @@ namespace PixiEditor.UpdateModule
 
         public async Task<bool> CheckUpdateAvailable()
         {
-            LatestReleaseInfo = await GetLatestReleaseInfoAsync();
+            LatestReleaseInfo = await GetLatestReleaseInfoAsync(Channel.ApiUrl);
             return CheckUpdateAvailable(LatestReleaseInfo);
         }
 
@@ -70,7 +70,7 @@ namespace PixiEditor.UpdateModule
             using (HttpClient client = new HttpClient())
             {
                 client.DefaultRequestHeaders.Add("User-Agent", "PixiEditor");
-                HttpResponseMessage response = await client.GetAsync(string.Format(IncompatibleFileApiUrl, tag));
+                HttpResponseMessage response = await client.GetAsync(string.Format(Channel.IncompatibleFileApiUrl, tag));
                 if (response.StatusCode == HttpStatusCode.OK)
                 {
                     string content = await response.Content.ReadAsStringAsync();
@@ -81,12 +81,12 @@ namespace PixiEditor.UpdateModule
             return Array.Empty<string>();
         }
 
-        private static async Task<ReleaseInfo> GetLatestReleaseInfoAsync()
+        private static async Task<ReleaseInfo> GetLatestReleaseInfoAsync(string apiUrl)
         {
             using (HttpClient client = new HttpClient())
             {
                 client.DefaultRequestHeaders.Add("User-Agent", "PixiEditor");
-                HttpResponseMessage response = await client.GetAsync(ReleaseApiUrl);
+                HttpResponseMessage response = await client.GetAsync(apiUrl);
                 if (response.StatusCode == HttpStatusCode.OK)
                 {
                     string content = await response.Content.ReadAsStringAsync();

+ 1 - 1
PixiEditor/ViewModels/SettingsWindowViewModel.cs

@@ -28,7 +28,7 @@ namespace PixiEditor.ViewModels
         {
             get
             {
-#if UPDATE
+#if UPDATE || DEBUG
                 return true;
 #else
                 return false;

+ 16 - 2
PixiEditor/ViewModels/SubViewModels/Main/UpdateViewModel.cs

@@ -2,7 +2,7 @@
 using System.ComponentModel;
 using System.Diagnostics;
 using System.IO;
-using System.Reflection;
+using System.Linq;
 using System.Threading.Tasks;
 using System.Windows;
 using PixiEditor.Helpers;
@@ -19,6 +19,8 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
 
         public UpdateChecker UpdateChecker { get; set; }
 
+        public UpdateChannel[] UpdateChannels { get; } = new UpdateChannel[2];
+
         public RelayCommand RestartApplicationCommand { get; set; }
 
         private string versionText;
@@ -52,6 +54,7 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
         {
             Owner.OnStartupEvent += Owner_OnStartupEvent;
             RestartApplicationCommand = new RelayCommand(RestartApplication);
+            IPreferences.Current.AddCallback<string>("UpdateChannel", (val) => UpdateChecker.Channel = GetUpdateChannel(val));
             InitUpdateChecker();
         }
 
@@ -191,9 +194,20 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
 
         private void InitUpdateChecker()
         {
+            UpdateChannels[0] = new UpdateChannel("Release", "PixiEditor", "PixiEditor");
+            UpdateChannels[1] = new UpdateChannel("Development", "PixiEditor", "PixiEditor-development-channel");
+
+            string updateChannel = IPreferences.Current.GetPreference<string>("UpdateChannel");
+
             string version = VersionHelpers.GetCurrentAssemblyVersionString();
-            UpdateChecker = new UpdateChecker(version);
+            UpdateChecker = new UpdateChecker(version, GetUpdateChannel(updateChannel));
             VersionText = $"Version {version}";
         }
+
+        private UpdateChannel GetUpdateChannel(string channelName)
+        {
+            UpdateChannel selectedChannel = UpdateChannels.FirstOrDefault(x => x.Name == channelName, UpdateChannels[0]);
+            return selectedChannel;
+        }
     }
 }

+ 22 - 1
PixiEditor/ViewModels/SubViewModels/UserPreferences/Settings/UpdateSettings.cs

@@ -1,4 +1,8 @@
-namespace PixiEditor.ViewModels.SubViewModels.UserPreferences.Settings
+using PixiEditor.ViewModels.SubViewModels.Main;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace PixiEditor.ViewModels.SubViewModels.UserPreferences.Settings
 {
     public class UpdateSettings : SettingsGroup
     {
@@ -14,5 +18,22 @@
                 RaiseAndUpdatePreference(name, value);
             }
         }
+
+        private string updateChannelName = GetPreference("UpdateChannel", "Release");
+
+        public string UpdateChannelName
+        {
+            get => updateChannelName;
+            set
+            {
+                updateChannelName = value;
+                RaiseAndUpdatePreference("UpdateChannel", value);
+            }
+        }
+
+        public IEnumerable<string> UpdateChannels
+        {
+            get => ViewModelMain.Current.UpdateSubViewModel.UpdateChannels.Select(x => x.Name);
+        }
     }
 }

+ 1 - 4
PixiEditor/ViewModels/SubViewModels/UserPreferences/SettingsViewModel.cs

@@ -1,7 +1,4 @@
-using System;
-using System.Configuration;
-using PixiEditor.Models.UserPreferences;
-using PixiEditor.ViewModels.SubViewModels.UserPreferences.Settings;
+using PixiEditor.ViewModels.SubViewModels.UserPreferences.Settings;
 
 namespace PixiEditor.ViewModels.SubViewModels.UserPreferences
 {

+ 6 - 0
PixiEditor/Views/Dialogs/SettingsWindow.xaml

@@ -82,6 +82,12 @@
                     <Label Style="{StaticResource Header1}" Content="Auto-updates"/>
                     <StackPanel Orientation="Vertical" Margin="50 0 50 0">
                         <CheckBox IsChecked="{Binding SettingsSubViewModel.Update.CheckUpdatesOnStartup}" Content="Check updates on startup"/>
+                        <StackPanel Orientation="Horizontal">
+                        <Label VerticalAlignment="Center" Content="Update source" Style="{StaticResource BaseLabel}"/>
+                            <ComboBox Width="110" Margin="0 10 0 10" HorizontalAlignment="Left" 
+                                      ItemsSource="{Binding SettingsSubViewModel.Update.UpdateChannels}"
+                                      SelectedValue="{Binding SettingsSubViewModel.Update.UpdateChannelName}"/>
+                        </StackPanel>
                     </StackPanel>
                 </StackPanel>
             </Grid>

+ 2 - 2
azure-pipelines.yml

@@ -1,5 +1,5 @@
 trigger:
-- dev
+- development
 - master
 
 pool:
@@ -40,7 +40,7 @@ steps:
 - task: PowerShell@2
   inputs:
     targetType: 'inline'
-    script: '& "$env:userprofile\.nuget\packages\opencover\4.7.922\tools\OpenCover.Console.exe" -register -target:"$env:programfiles/dotnet/dotnet.exe" -targetargs:test -filter:"+[*]*" -output:".\PixiEditor_coverage.xml" -oldstyle'
+    script: '& "$env:userprofile\.nuget\packages\opencover\4.7.1221\tools\OpenCover.Console.exe" -register -target:"$env:programfiles/dotnet/dotnet.exe" -targetargs:test -filter:"+[*]*" -output:".\PixiEditor_coverage.xml" -oldstyle'
     workingDirectory: 'PixiEditorTests\'
   displayName: Collect code coverage
 

+ 2 - 1
windows-x64-release.yml

@@ -5,6 +5,7 @@
 
 trigger:
 - release
+- development
 
 pr: none
 
@@ -79,7 +80,7 @@ steps:
   displayName: "Compile installer"
   inputs:
     targetType: 'inline'
-    script: '& "$env:userprofile\.nuget\packages\tools.innosetup\6.1.2\tools\ISCC.exe" Installer\installer-setup-x64-light.iss'
+    script: '& "$env:userprofile\.nuget\packages\tools.innosetup\6.2.0\tools\ISCC.exe" Installer\installer-setup-x64-light.iss'
 
 - task: PublishPipelineArtifact@1
   displayName: "Publish artifact"

+ 2 - 1
windows-x86-release.yml

@@ -5,6 +5,7 @@
 
 trigger:
 - release
+- development
 pr: none
 
 pool:
@@ -79,7 +80,7 @@ steps:
   displayName: "Compile installer"
   inputs:
     targetType: 'inline'
-    script: '& "$env:userprofile\.nuget\packages\tools.innosetup\6.1.2\tools\ISCC.exe" Installer\installer-setup-x86-light.iss'
+    script: '& "$env:userprofile\.nuget\packages\tools.innosetup\6.2.0\tools\ISCC.exe" Installer\installer-setup-x86-light.iss'
 
 - task: PublishPipelineArtifact@1
   displayName: "Publish artifact"