From 38c6302c8acc7f4b1e590ae97bfae48c175e846f Mon Sep 17 00:00:00 2001 From: temacdonald Date: Mon, 13 Apr 2020 15:47:38 +1200 Subject: [PATCH] Converted to .Net4.8 and System.CommandLine.DragonFruit Migrated to the latest .Net Framework (v4.8) and changed to System.CommandLine.DragonFruit for the parameter processing as CommandLineParser completely altered their required programme structure which meant something had to change. Figured using Microsoft's own poduct would be best. --- .gitignore | 4 + HeliosDisplayManagement.Reporting/App.config | 2 +- .../FodyWeavers.xml | 3 +- .../FodyWeavers.xsd | 111 ++++++++++++++++++ .../HeliosDisplayManagement.Reporting.csproj | 46 ++++---- .../packages.config | 7 -- .../HeliosDisplayManagement.Shared.csproj | 38 +++--- .../packages.config | 8 -- ...iosDisplayManagement.ShellExtension.csproj | 17 +-- .../packages.config | 5 - HeliosDisplayManagement/App.config | 2 +- HeliosDisplayManagement/CommandLineOptions.cs | 85 ++------------ .../HeliosDisplayManagement.csproj | 82 +++++++------ HeliosDisplayManagement/Program.cs | 78 ++++++++---- HeliosDisplayManagement/packages.config | 10 -- 15 files changed, 277 insertions(+), 221 deletions(-) create mode 100644 HeliosDisplayManagement.Reporting/FodyWeavers.xsd delete mode 100644 HeliosDisplayManagement.Reporting/packages.config delete mode 100644 HeliosDisplayManagement.Shared/packages.config delete mode 100644 HeliosDisplayManagement.ShellExtension/packages.config delete mode 100644 HeliosDisplayManagement/packages.config diff --git a/.gitignore b/.gitignore index 1ac2acf..b11f9e5 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ bld/ # Visual Studio 2015 cache/options directory .vs/ +.vscode/ # Uncomment if you have tasks that create the project's static files in wwwroot #wwwroot/ @@ -245,3 +246,6 @@ ModelManifest.xml .fake/ HeliosDisplayManagement.Setup/HeliosDisplayManagement.Setup Data/* HeliosDisplayManagement.Setup/HeliosDisplayManagement.Setup/* +/nuget.exe +/vs_community__1091181154.1584848614.exe +/MigrationBackup diff --git a/HeliosDisplayManagement.Reporting/App.config b/HeliosDisplayManagement.Reporting/App.config index 8609e96..be93275 100644 --- a/HeliosDisplayManagement.Reporting/App.config +++ b/HeliosDisplayManagement.Reporting/App.config @@ -2,6 +2,6 @@ - + \ No newline at end of file diff --git a/HeliosDisplayManagement.Reporting/FodyWeavers.xml b/HeliosDisplayManagement.Reporting/FodyWeavers.xml index 100917a..a5dcf04 100644 --- a/HeliosDisplayManagement.Reporting/FodyWeavers.xml +++ b/HeliosDisplayManagement.Reporting/FodyWeavers.xml @@ -1,5 +1,4 @@  - - + \ No newline at end of file diff --git a/HeliosDisplayManagement.Reporting/FodyWeavers.xsd b/HeliosDisplayManagement.Reporting/FodyWeavers.xsd new file mode 100644 index 0000000..44a5374 --- /dev/null +++ b/HeliosDisplayManagement.Reporting/FodyWeavers.xsd @@ -0,0 +1,111 @@ + + + + + + + + + + + + A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks + + + + + A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks. + + + + + A list of unmanaged 32 bit assembly names to include, delimited with line breaks. + + + + + A list of unmanaged 64 bit assembly names to include, delimited with line breaks. + + + + + The order of preloaded assemblies, delimited with line breaks. + + + + + + This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file. + + + + + Controls if .pdbs for reference assemblies are also embedded. + + + + + Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option. + + + + + As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off. + + + + + Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code. + + + + + Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior. + + + + + A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with | + + + + + A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |. + + + + + A list of unmanaged 32 bit assembly names to include, delimited with |. + + + + + A list of unmanaged 64 bit assembly names to include, delimited with |. + + + + + The order of preloaded assemblies, delimited with |. + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/HeliosDisplayManagement.Reporting/HeliosDisplayManagement.Reporting.csproj b/HeliosDisplayManagement.Reporting/HeliosDisplayManagement.Reporting.csproj index 6fc6e01..03268c1 100644 --- a/HeliosDisplayManagement.Reporting/HeliosDisplayManagement.Reporting.csproj +++ b/HeliosDisplayManagement.Reporting/HeliosDisplayManagement.Reporting.csproj @@ -1,7 +1,8 @@ - - - + + Debug AnyCPU @@ -9,7 +10,7 @@ Exe HeliosDisplayManagement.Reporting HeliosDisplayManagement.Reporting - v4.6.2 + v4.8 512 true true @@ -37,17 +38,8 @@ false - - ..\packages\Costura.Fody.3.1.5\lib\net46\Costura.dll - - - ..\packages\NvAPIWrapper.Net.0.6.1.15\lib\net45\NvAPIWrapper.dll - - - ..\packages\WindowsDisplayAPI.1.1.0.2\lib\net45\WindowsDisplayAPI.dll - @@ -55,7 +47,6 @@ - @@ -66,15 +57,22 @@ + + + 4.1.0 + + + 6.1.1 + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + 0.7.2.63 + + + 1.3.0.13 + + - - - 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}. - - - - - - - + \ No newline at end of file diff --git a/HeliosDisplayManagement.Reporting/packages.config b/HeliosDisplayManagement.Reporting/packages.config deleted file mode 100644 index 75a38f2..0000000 --- a/HeliosDisplayManagement.Reporting/packages.config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/HeliosDisplayManagement.Shared/HeliosDisplayManagement.Shared.csproj b/HeliosDisplayManagement.Shared/HeliosDisplayManagement.Shared.csproj index af07788..845cee4 100644 --- a/HeliosDisplayManagement.Shared/HeliosDisplayManagement.Shared.csproj +++ b/HeliosDisplayManagement.Shared/HeliosDisplayManagement.Shared.csproj @@ -9,7 +9,7 @@ Properties HeliosDisplayManagement.Shared HeliosDisplayManagement.Shared - v4.5 + v4.8 512 @@ -32,28 +32,12 @@ 4 - - ..\packages\EDIDParser.1.2.0.1\lib\net45\EDIDParser.dll - - - ..\packages\IconLib.Unofficial.0.73.0\lib\net20\IconLib.dll - True - - - ..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll - - - ..\packages\NvAPIWrapper.Net.0.6.1.15\lib\net45\NvAPIWrapper.dll - - - ..\packages\WindowsDisplayAPI.1.2.0.2\lib\net45\WindowsDisplayAPI.dll - @@ -87,9 +71,6 @@ DisplayView.cs - - - ResXFileCodeGenerator @@ -99,6 +80,23 @@ DisplayView.cs + + + 1.2.0.1 + + + 0.73.0 + + + 12.0.3 + + + 0.7.2.63 + + + 1.3.0.13 + + Debug AnyCPU @@ -9,9 +9,11 @@ Properties HeliosDisplayManagement HeliosDisplayManagement - v4.5 + v4.8 512 true + false + publish\ true Disk @@ -24,10 +26,8 @@ true 0 1.0.0.%2a - false false true - AnyCPU @@ -53,24 +53,11 @@ Icon.ico + + HeliosDisplayManagement.Program + - - ..\packages\CircularProgressBar.2.6.6823.24527\lib\net35-client\CircularProgressBar.dll - - - ..\packages\CommandLineParser.1.9.71\lib\net45\CommandLine.dll - - - ..\packages\HtmlAgilityPack.1.8.9\lib\Net45\HtmlAgilityPack.dll - - - ..\packages\IconLib.Unofficial.0.73.0\lib\net20\IconLib.dll - True - - - ..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll - @@ -79,13 +66,6 @@ - - ..\packages\WindowsDisplayAPI.1.2.0.2\lib\net45\WindowsDisplayAPI.dll - - - ..\packages\WinFormAnimation.1.5.6298.3372\lib\net35-client\WinFormAnimation.dll - True - @@ -133,6 +113,11 @@ + + True + Resources.resx + True + ResXFileCodeGenerator Language.Designer.cs @@ -155,23 +140,17 @@ Resources.Designer.cs Designer - - True - Resources.resx - True - SplashForm.cs - - + False - Microsoft .NET Framework 4.5.2 %28x86 and x64%29 + Microsoft .NET Framework 4.8 %28x86 and x64%29 true @@ -185,6 +164,9 @@ + + + {1cacda43-01c7-4cd4-bf6e-9421a29510fc} @@ -192,7 +174,30 @@ - + + 2.7.0.7 + + + 1.11.23 + + + 0.73.0 + + + 12.0.3 + + + 2.0.0-beta1.20158.1 + + + 0.3.0-alpha.20158.1 + + + 1.3.0.13 + + + 1.6.0.4 + + --> \ No newline at end of file diff --git a/HeliosDisplayManagement/Program.cs b/HeliosDisplayManagement/Program.cs index 37e4556..467e817 100644 --- a/HeliosDisplayManagement/Program.cs +++ b/HeliosDisplayManagement/Program.cs @@ -1,5 +1,8 @@ using System; using System.Collections.Generic; +//using System.CommandLine; +//using System.CommandLine.Invocation; +using System.CommandLine.DragonFruit; using System.Diagnostics; using System.IO; using System.Linq; @@ -17,6 +20,7 @@ namespace HeliosDisplayManagement { internal static class Program { + internal static bool GoProfile(Profile profile) { if (profile.IsActive) @@ -69,11 +73,11 @@ namespace HeliosDisplayManagement IPCService.GetInstance().Status = InstanceStatus.User; new ShortcutForm(profiles[profileIndex]) { - FileName = CommandLineOptions.Default.ExecuteFilename, - SteamAppId = CommandLineOptions.Default.ExecuteSteamApp, - Arguments = CommandLineOptions.Default.ExecuteArguments, - ProcessName = CommandLineOptions.Default.ExecuteProcessName, - Timeout = CommandLineOptions.Default.ExecuteProcessTimeout + FileName = CommandLineOptions.ExecuteFilename, + SteamAppId = CommandLineOptions.ExecuteSteamApp, + Arguments = CommandLineOptions.ExecuteArguments, + ProcessName = CommandLineOptions.ExecuteProcessName, + Timeout = CommandLineOptions.ExecuteProcessTimeout }.ShowDialog(); } @@ -98,12 +102,36 @@ namespace HeliosDisplayManagement } } + [STAThread] /// /// The main entry point for the application. /// - [STAThread] - private static void Main() + /// (required) The startup action to perform: None (Do nothing), SwitchProfile (Change to another profile and optionally run an application/game), CreateShortcut (Create a Desktop Shortcut), EditProfile (Edit a profile) + /// (required) UUID string that selects the profile to use. + /// (optional) Extra arguments to pass to the application/game when we're switching profile and running the application/game. Also can be used when creating a shortcut. + /// (optional) The application/game to start when we're switching profile and running the application/game. Also can be used when creating a shortcut. + /// (optional) The process name to wait for when we're temporarily switching profile and running the application/game. Also can be used when creating a shortcut. + /// (optional) The time in seconds we should delay starting the application/game when we're temporarily switching profile and running the application/game. Also can be used when creating a shortcut. + /// (optional) The Steam AppID wait for when we're temporarily switching profile and running the application/game. Also can be used when creating a shortcut. + private static void Main( + HeliosStartupAction action, + string profileId = null, + string arguments = null, + string execute = null, + string processName = null, + uint processTimeout = 30u, + uint steamId = 0u) { + + // Save these in CommandLineOptions for easy access from other parts of the application + CommandLineOptions.Action = action; + CommandLineOptions.ProfileId = profileId; + CommandLineOptions.ExecuteArguments = arguments; + CommandLineOptions.ExecuteFilename = execute; + CommandLineOptions.ExecuteProcessName = processName; + CommandLineOptions.ExecuteProcessTimeout = processTimeout; + CommandLineOptions.ExecuteSteamApp = steamId; + Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; @@ -116,15 +144,15 @@ namespace HeliosDisplayManagement } var profiles = Profile.GetAllProfiles().ToArray(); - var profileIndex = !string.IsNullOrWhiteSpace(CommandLineOptions.Default.ProfileId) && + var profileIndex = !string.IsNullOrWhiteSpace(CommandLineOptions.ProfileId) && profiles.Length > 0 ? Array.FindIndex(profiles, p => - p.Id.Equals(CommandLineOptions.Default.ProfileId, + p.Id.Equals(null, StringComparison.InvariantCultureIgnoreCase)) : -1; - switch (CommandLineOptions.Default.Action) + switch (CommandLineOptions.Action) { case HeliosStartupAction.SwitchProfile: SwitchProfile(profiles, profileIndex); @@ -144,6 +172,8 @@ namespace HeliosDisplayManagement break; } + + } catch (Exception e) { @@ -182,9 +212,9 @@ namespace HeliosDisplayManagement .Another_instance_of_this_program_is_in_working_state_Please_close_other_instances_before_trying_to_switch_profile); } - if (!string.IsNullOrWhiteSpace(CommandLineOptions.Default.ExecuteFilename)) + if (!string.IsNullOrWhiteSpace(CommandLineOptions.ExecuteFilename)) { - if (!File.Exists(CommandLineOptions.Default.ExecuteFilename)) + if (!File.Exists(CommandLineOptions.ExecuteFilename)) { throw new Exception(Language.Executable_file_not_found); } @@ -194,17 +224,17 @@ namespace HeliosDisplayManagement throw new Exception(Language.Can_not_change_active_profile); } - var process = Process.Start(CommandLineOptions.Default.ExecuteFilename, - CommandLineOptions.Default.ExecuteArguments); - var processes = new Process[0]; + var process = System.Diagnostics.Process.Start(CommandLineOptions.ExecuteFilename, + CommandLineOptions.ExecuteArguments); + var processes = new System.Diagnostics.Process[0]; - if (!string.IsNullOrWhiteSpace(CommandLineOptions.Default.ExecuteProcessName)) + if (!string.IsNullOrWhiteSpace(CommandLineOptions.ExecuteProcessName)) { var ticks = 0; - while (ticks < CommandLineOptions.Default.ExecuteProcessTimeout * 1000) + while (ticks < CommandLineOptions.ExecuteProcessTimeout * 1000) { - processes = Process.GetProcessesByName(CommandLineOptions.Default.ExecuteProcessName); + processes = System.Diagnostics.Process.GetProcessesByName(CommandLineOptions.ExecuteProcessName); if (processes.Length > 0) { @@ -271,9 +301,9 @@ namespace HeliosDisplayManagement } } } - else if (CommandLineOptions.Default.ExecuteSteamApp > 0) + else if (CommandLineOptions.ExecuteSteamApp > 0) { - var steamGame = new SteamGame(CommandLineOptions.Default.ExecuteSteamApp); + var steamGame = new SteamGame(CommandLineOptions.ExecuteSteamApp); if (!SteamGame.SteamInstalled) { @@ -302,16 +332,16 @@ namespace HeliosDisplayManagement var address = $"steam://rungameid/{steamGame.AppId}"; - if (!string.IsNullOrWhiteSpace(CommandLineOptions.Default.ExecuteArguments)) + if (!string.IsNullOrWhiteSpace(CommandLineOptions.ExecuteArguments)) { - address += "/" + CommandLineOptions.Default.ExecuteArguments; + address += "/" + CommandLineOptions.ExecuteArguments; } - var steamProcess = Process.Start(address); + var steamProcess = System.Diagnostics.Process.Start(address); // Wait for steam game to update and then run var ticks = 0; - while (ticks < CommandLineOptions.Default.ExecuteProcessTimeout * 1000) + while (ticks < CommandLineOptions.ExecuteProcessTimeout * 1000) { if (steamGame.IsRunning) { diff --git a/HeliosDisplayManagement/packages.config b/HeliosDisplayManagement/packages.config deleted file mode 100644 index 5df4d83..0000000 --- a/HeliosDisplayManagement/packages.config +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file