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.
This commit is contained in:
temacdonald
2020-04-13 15:47:38 +12:00
parent 22b24746df
commit 38c6302c8a
15 changed files with 277 additions and 221 deletions

4
.gitignore vendored
View File

@ -24,6 +24,7 @@ bld/
# Visual Studio 2015 cache/options directory # Visual Studio 2015 cache/options directory
.vs/ .vs/
.vscode/
# Uncomment if you have tasks that create the project's static files in wwwroot # Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/ #wwwroot/
@ -245,3 +246,6 @@ ModelManifest.xml
.fake/ .fake/
HeliosDisplayManagement.Setup/HeliosDisplayManagement.Setup Data/* HeliosDisplayManagement.Setup/HeliosDisplayManagement.Setup Data/*
HeliosDisplayManagement.Setup/HeliosDisplayManagement.Setup/* HeliosDisplayManagement.Setup/HeliosDisplayManagement.Setup/*
/nuget.exe
/vs_community__1091181154.1584848614.exe
/MigrationBackup

View File

@ -2,6 +2,6 @@
<configuration> <configuration>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup> </startup>
</configuration> </configuration>

View File

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<Weavers>
<Costura /> <Costura />
</Weavers> </Weavers>

View File

@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="Costura" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:all>
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="IncludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged32Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="PreloadOrder" type="xs:string">
<xs:annotation>
<xs:documentation>The order of preloaded assemblies, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:all>
<xs:attribute name="CreateTemporaryAssemblies" type="xs:boolean">
<xs:annotation>
<xs:documentation>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.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeDebugSymbols" type="xs:boolean">
<xs:annotation>
<xs:documentation>Controls if .pdbs for reference assemblies are also embedded.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="DisableCompression" type="xs:boolean">
<xs:annotation>
<xs:documentation>Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="DisableCleanup" type="xs:boolean">
<xs:annotation>
<xs:documentation>As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="LoadAtModuleInit" type="xs:boolean">
<xs:annotation>
<xs:documentation>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.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IgnoreSatelliteAssemblies" type="xs:boolean">
<xs:annotation>
<xs:documentation>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.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="ExcludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Unmanaged32Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Unmanaged64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="PreloadOrder" type="xs:string">
<xs:annotation>
<xs:documentation>The order of preloaded assemblies, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Costura.Fody.3.1.5\build\Costura.Fody.props" Condition="Exists('..\packages\Costura.Fody.3.1.5\build\Costura.Fody.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<!--<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
<Import Project="..\packages\Costura.Fody.4.1.0\build\Costura.Fody.targets" Condition="Exists('..\packages\Costura.Fody.4.1.0\build\Costura.Fody.targets')"/>
<Import Project="..\packages\Fody.6.1.1\build\Fody.targets" Condition="Exists('..\packages\Fody.6.1.1\build\Fody.targets')"/>-->
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@ -9,7 +10,7 @@
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<RootNamespace>HeliosDisplayManagement.Reporting</RootNamespace> <RootNamespace>HeliosDisplayManagement.Reporting</RootNamespace>
<AssemblyName>HeliosDisplayManagement.Reporting</AssemblyName> <AssemblyName>HeliosDisplayManagement.Reporting</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion> <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
@ -37,17 +38,8 @@
<Prefer32Bit>false</Prefer32Bit> <Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Costura, Version=3.1.5.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
<HintPath>..\packages\Costura.Fody.3.1.5\lib\net46\Costura.dll</HintPath>
</Reference>
<Reference Include="NvAPIWrapper, Version=0.6.1.15, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\NvAPIWrapper.Net.0.6.1.15\lib\net45\NvAPIWrapper.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="WindowsDisplayAPI, Version=1.1.0.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\WindowsDisplayAPI.1.1.0.2\lib\net45\WindowsDisplayAPI.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
@ -55,7 +47,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="App.config" /> <None Include="App.config" />
<None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\HeliosDisplayManagement.Shared\HeliosDisplayManagement.Shared.csproj"> <ProjectReference Include="..\HeliosDisplayManagement.Shared\HeliosDisplayManagement.Shared.csproj">
@ -66,15 +57,22 @@
<ItemGroup> <ItemGroup>
<Content Include="FodyWeavers.xml" /> <Content Include="FodyWeavers.xml" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<PackageReference Include="Costura.Fody">
<Version>4.1.0</Version>
</PackageReference>
<PackageReference Include="Fody">
<Version>6.1.1</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="NvAPIWrapper.Net">
<Version>0.7.2.63</Version>
</PackageReference>
<PackageReference Include="WindowsDisplayAPI">
<Version>1.3.0.13</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Import Project="..\packages\Costura.Fody.4.1.0\build\Costura.Fody.targets" Condition="Exists('..\packages\Costura.Fody.4.1.0\build\Costura.Fody.targets')" />
<PropertyGroup>
<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>
<Error Condition="!Exists('..\packages\Costura.Fody.3.1.5\build\Costura.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.3.1.5\build\Costura.Fody.props'))" />
<Error Condition="!Exists('..\packages\Costura.Fody.3.1.5\build\Costura.Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.3.1.5\build\Costura.Fody.targets'))" />
<Error Condition="!Exists('..\packages\Fody.3.2.11\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.3.2.11\build\Fody.targets'))" />
</Target>
<Import Project="..\packages\Costura.Fody.3.1.5\build\Costura.Fody.targets" Condition="Exists('..\packages\Costura.Fody.3.1.5\build\Costura.Fody.targets')" />
<Import Project="..\packages\Fody.3.2.11\build\Fody.targets" Condition="Exists('..\packages\Fody.3.2.11\build\Fody.targets')" />
</Project> </Project>

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Costura.Fody" version="3.1.5" targetFramework="net462" />
<package id="Fody" version="3.2.11" targetFramework="net462" developmentDependency="true" />
<package id="NvAPIWrapper.Net" version="0.6.1.15" targetFramework="net462" />
<package id="WindowsDisplayAPI" version="1.1.0.2" targetFramework="net462" />
</packages>

View File

@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>HeliosDisplayManagement.Shared</RootNamespace> <RootNamespace>HeliosDisplayManagement.Shared</RootNamespace>
<AssemblyName>HeliosDisplayManagement.Shared</AssemblyName> <AssemblyName>HeliosDisplayManagement.Shared</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<TargetFrameworkProfile /> <TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
@ -32,28 +32,12 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="EDIDParser, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\EDIDParser.1.2.0.1\lib\net45\EDIDParser.dll</HintPath>
</Reference>
<Reference Include="IconLib, Version=0.73.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\IconLib.Unofficial.0.73.0\lib\net20\IconLib.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NvAPIWrapper, Version=0.6.1.15, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\NvAPIWrapper.Net.0.6.1.15\lib\net45\NvAPIWrapper.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="WindowsDisplayAPI, Version=1.2.0.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\WindowsDisplayAPI.1.2.0.2\lib\net45\WindowsDisplayAPI.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="RestartManagerSession.cs" /> <Compile Include="RestartManagerSession.cs" />
@ -87,9 +71,6 @@
<DependentUpon>DisplayView.cs</DependentUpon> <DependentUpon>DisplayView.cs</DependentUpon>
</Compile> </Compile>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Resources\Language.resx"> <EmbeddedResource Include="Resources\Language.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
@ -99,6 +80,23 @@
<DependentUpon>DisplayView.cs</DependentUpon> <DependentUpon>DisplayView.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup>
<PackageReference Include="EDIDParser">
<Version>1.2.0.1</Version>
</PackageReference>
<PackageReference Include="IconLib.Unofficial">
<Version>0.73.0</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>12.0.3</Version>
</PackageReference>
<PackageReference Include="NvAPIWrapper.Net">
<Version>0.7.2.63</Version>
</PackageReference>
<PackageReference Include="WindowsDisplayAPI">
<Version>1.3.0.13</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EDIDParser" version="1.2.0.1" targetFramework="net45" />
<package id="IconLib.Unofficial" version="0.73.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net45" />
<package id="NvAPIWrapper.Net" version="0.6.1.15" targetFramework="net45" />
<package id="WindowsDisplayAPI" version="1.2.0.2" targetFramework="net45" />
</packages>

View File

@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>HeliosDisplayManagement.ShellExtension</RootNamespace> <RootNamespace>HeliosDisplayManagement.ShellExtension</RootNamespace>
<AssemblyName>HeliosDisplayManagement.ShellExtension</AssemblyName> <AssemblyName>HeliosDisplayManagement.ShellExtension</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<TargetFrameworkProfile /> <TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
@ -31,12 +31,6 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="ServerRegistrationManager, Version=2.6.0.0, Culture=neutral, PublicKeyToken=68bd4561cc3495fc, processorArchitecture=MSIL">
<HintPath>..\packages\ServerRegistrationManager.2.6.0\lib\net45\ServerRegistrationManager.exe</HintPath>
</Reference>
<Reference Include="SharpShell, Version=2.6.0.0, Culture=neutral, PublicKeyToken=f14dc899472fe6fb, processorArchitecture=MSIL">
<HintPath>..\packages\SharpShell.2.6.0\lib\net40-client\SharpShell.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
@ -76,12 +70,19 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="packages.config" />
<None Include="Resources\Icon_x16.png" /> <None Include="Resources\Icon_x16.png" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Shield.cs" /> <Compile Include="Shield.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<PackageReference Include="ServerRegistrationManager">
<Version>2.7.2</Version>
</PackageReference>
<PackageReference Include="SharpShell">
<Version>2.7.2</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ServerRegistrationManager" version="2.6.0" targetFramework="net45" />
<package id="SharpShell" version="2.6.0" targetFramework="net45" />
</packages>

View File

@ -2,6 +2,6 @@
<configuration> <configuration>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup> </startup>
</configuration> </configuration>

View File

@ -1,88 +1,29 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
using CommandLine; //using CommandLine;
using CommandLine.Text; //using CommandLine.Text;
using HeliosDisplayManagement.Resources; using HeliosDisplayManagement.Resources;
using HeliosDisplayManagement.Shared; using HeliosDisplayManagement.Shared;
using System.Runtime.CompilerServices;
namespace HeliosDisplayManagement namespace HeliosDisplayManagement
{ {
internal class CommandLineOptions internal class CommandLineOptions
{ {
private static CommandLineOptions _defaultObject;
private CommandLineOptions() private CommandLineOptions()
{ {
} }
[Option('a', @"action", HelpText = @"The action to perform", public static HeliosStartupAction Action { get; set; }
DefaultValue = HeliosStartupAction.None)] public static string ExecuteArguments { get; set; }
public HeliosStartupAction Action { get; set; } public static string ExecuteFilename { get; set; }
public static string ExecuteProcessName { get; set; }
public static CommandLineOptions Default public static uint ExecuteProcessTimeout { get; set; }
{ public static uint ExecuteSteamApp { get; set; }
get public static string ProfileId { get; set; }
{
if (_defaultObject == null)
{
_defaultObject = new CommandLineOptions();
Parser.Default.ParseArguments(Environment.GetCommandLineArgs().Skip(1).ToArray(), _defaultObject);
Console.WriteLine(string.Join(" ", Environment.GetCommandLineArgs().Skip(1)));
if (_defaultObject.LastParserState != null && _defaultObject.LastParserState.Errors.Count > 0)
{
throw new Exception(_defaultObject.LastParserState.Errors[0].ToString());
}
}
return _defaultObject;
}
}
[Option(@"arguments",
HelpText = @"Program's argument to execute, for temporarily switch or to create shortcut.",
DefaultValue = null)]
public string ExecuteArguments { get; set; }
[Option('e', @"execute",
HelpText = @"Program's address to execute, for temporarily switch or to create shortcut.",
DefaultValue = null)]
public string ExecuteFilename { get; set; }
[Option('w', @"waitfor",
HelpText =
@"Program's process name to wait for end of execution before rolling back the settings, for temporarily switch or to create shortcut; Useful when there is a launcher involved.",
DefaultValue = null)]
public string ExecuteProcessName { get; set; }
[Option('t', @"timeout",
HelpText =
@"The maximum time in seconds to wait for the process since the execution of the program, for temporarily switch or to create shortcut.",
DefaultValue = 30u)]
public uint ExecuteProcessTimeout { get; set; }
[Option('s', @"steam",
HelpText = @"AppId of the Steam game, for temporarily switch or to create shortcut.",
DefaultValue = 0u)]
public uint ExecuteSteamApp { get; set; }
[ParserState]
public IParserState LastParserState { get; set; }
[Option('p', @"p", HelpText = @"Profile identification string to switch to.", DefaultValue = null)]
public string ProfileId { get; set; }
[HelpOption]
// ReSharper disable once UnusedMember.Global
public string GetUsage()
{
var help = HelpText.AutoBuild(this, current => HelpText.DefaultParsingErrorsHandler(this, current));
MessageBox.Show(help, Language.Help, MessageBoxButtons.OK,
MessageBoxIcon.Information);
Environment.Exit(0);
return help;
}
} }
} }

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<!--<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>-->
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@ -9,9 +9,11 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>HeliosDisplayManagement</RootNamespace> <RootNamespace>HeliosDisplayManagement</RootNamespace>
<AssemblyName>HeliosDisplayManagement</AssemblyName> <AssemblyName>HeliosDisplayManagement</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<IsWebBootstrapper>false</IsWebBootstrapper>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl> <PublishUrl>publish\</PublishUrl>
<Install>true</Install> <Install>true</Install>
<InstallFrom>Disk</InstallFrom> <InstallFrom>Disk</InstallFrom>
@ -24,10 +26,8 @@
<MapFileExtensions>true</MapFileExtensions> <MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision> <ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion> <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled> <BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@ -53,24 +53,11 @@
<PropertyGroup> <PropertyGroup>
<ApplicationIcon>Icon.ico</ApplicationIcon> <ApplicationIcon>Icon.ico</ApplicationIcon>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<StartupObject>HeliosDisplayManagement.Program</StartupObject>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="CircularProgressBar, Version=2.6.6823.24527, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CircularProgressBar.2.6.6823.24527\lib\net35-client\CircularProgressBar.dll</HintPath>
</Reference>
<Reference Include="CommandLine, Version=1.9.71.2, Culture=neutral, PublicKeyToken=de6f01bd326f8c32, processorArchitecture=MSIL">
<HintPath>..\packages\CommandLineParser.1.9.71\lib\net45\CommandLine.dll</HintPath>
</Reference>
<Reference Include="HtmlAgilityPack, Version=1.8.9.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
<HintPath>..\packages\HtmlAgilityPack.1.8.9\lib\Net45\HtmlAgilityPack.dll</HintPath>
</Reference>
<Reference Include="IconLib, Version=0.73.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\IconLib.Unofficial.0.73.0\lib\net20\IconLib.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
@ -79,13 +66,6 @@
<Reference Include="System.XML" /> <Reference Include="System.XML" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml.Serialization" /> <Reference Include="System.Xml.Serialization" />
<Reference Include="WindowsDisplayAPI, Version=1.2.0.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\WindowsDisplayAPI.1.2.0.2\lib\net45\WindowsDisplayAPI.dll</HintPath>
</Reference>
<Reference Include="WinFormAnimation, Version=1.5.6298.3372, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\WinFormAnimation.1.5.6298.3372\lib\net35-client\WinFormAnimation.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="CommandLineOptions.cs" /> <Compile Include="CommandLineOptions.cs" />
@ -133,6 +113,11 @@
</Compile> </Compile>
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<EmbeddedResource Include="Resources\Language.resx"> <EmbeddedResource Include="Resources\Language.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Language.Designer.cs</LastGenOutput> <LastGenOutput>Language.Designer.cs</LastGenOutput>
@ -155,23 +140,17 @@
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</EmbeddedResource> </EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<EmbeddedResource Include="UIForms\SplashForm.resx"> <EmbeddedResource Include="UIForms\SplashForm.resx">
<DependentUpon>SplashForm.cs</DependentUpon> <DependentUpon>SplashForm.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="App.config" /> <None Include="App.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2"> <BootstrapperPackage Include=".NETFramework,Version=v4.8">
<Visible>False</Visible> <Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5.2 %28x86 and x64%29</ProductName> <ProductName>Microsoft .NET Framework 4.8 %28x86 and x64%29</ProductName>
<Install>true</Install> <Install>true</Install>
</BootstrapperPackage> </BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1"> <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
@ -185,6 +164,9 @@
<None Include="Icon.png" /> <None Include="Icon.png" />
<None Include="Icon.psd" /> <None Include="Icon.psd" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="Resources\SteamIcon.png" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\HeliosDisplayManagement.Shared\HeliosDisplayManagement.Shared.csproj"> <ProjectReference Include="..\HeliosDisplayManagement.Shared\HeliosDisplayManagement.Shared.csproj">
<Project>{1cacda43-01c7-4cd4-bf6e-9421a29510fc}</Project> <Project>{1cacda43-01c7-4cd4-bf6e-9421a29510fc}</Project>
@ -192,7 +174,30 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="Resources\SteamIcon.png" /> <PackageReference Include="CircularProgressBar">
<Version>2.7.0.7</Version>
</PackageReference>
<PackageReference Include="HtmlAgilityPack">
<Version>1.11.23</Version>
</PackageReference>
<PackageReference Include="IconLib.Unofficial">
<Version>0.73.0</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>12.0.3</Version>
</PackageReference>
<PackageReference Include="System.CommandLine">
<Version>2.0.0-beta1.20158.1</Version>
</PackageReference>
<PackageReference Include="System.CommandLine.DragonFruit">
<Version>0.3.0-alpha.20158.1</Version>
</PackageReference>
<PackageReference Include="WindowsDisplayAPI">
<Version>1.3.0.13</Version>
</PackageReference>
<PackageReference Include="WinFormAnimation">
<Version>1.6.0.4</Version>
</PackageReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
@ -200,6 +205,5 @@
<Target Name="BeforeBuild"> <Target Name="BeforeBuild">
</Target> </Target>
<Target Name="AfterBuild"> <Target Name="AfterBuild">
</Target> </Target>-->
-->
</Project> </Project>

View File

@ -1,5 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
//using System.CommandLine;
//using System.CommandLine.Invocation;
using System.CommandLine.DragonFruit;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -17,6 +20,7 @@ namespace HeliosDisplayManagement
{ {
internal static class Program internal static class Program
{ {
internal static bool GoProfile(Profile profile) internal static bool GoProfile(Profile profile)
{ {
if (profile.IsActive) if (profile.IsActive)
@ -69,11 +73,11 @@ namespace HeliosDisplayManagement
IPCService.GetInstance().Status = InstanceStatus.User; IPCService.GetInstance().Status = InstanceStatus.User;
new ShortcutForm(profiles[profileIndex]) new ShortcutForm(profiles[profileIndex])
{ {
FileName = CommandLineOptions.Default.ExecuteFilename, FileName = CommandLineOptions.ExecuteFilename,
SteamAppId = CommandLineOptions.Default.ExecuteSteamApp, SteamAppId = CommandLineOptions.ExecuteSteamApp,
Arguments = CommandLineOptions.Default.ExecuteArguments, Arguments = CommandLineOptions.ExecuteArguments,
ProcessName = CommandLineOptions.Default.ExecuteProcessName, ProcessName = CommandLineOptions.ExecuteProcessName,
Timeout = CommandLineOptions.Default.ExecuteProcessTimeout Timeout = CommandLineOptions.ExecuteProcessTimeout
}.ShowDialog(); }.ShowDialog();
} }
@ -98,12 +102,36 @@ namespace HeliosDisplayManagement
} }
} }
[STAThread]
/// <summary> /// <summary>
/// The main entry point for the application. /// The main entry point for the application.
/// </summary> /// </summary>
[STAThread] /// <param name="action">(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)</param>
private static void Main() /// <param name="profileId">(required) UUID string that selects the profile to use.</param>
/// <param name="arguments">(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.</param>
/// <param name="execute">(optional) The application/game to start when we're switching profile and running the application/game. Also can be used when creating a shortcut.</param>
/// <param name="processName">(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.</param>
/// <param name="processTimeout">(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.</param>
/// <param name="steamId">(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.</param>
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.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
@ -116,15 +144,15 @@ namespace HeliosDisplayManagement
} }
var profiles = Profile.GetAllProfiles().ToArray(); var profiles = Profile.GetAllProfiles().ToArray();
var profileIndex = !string.IsNullOrWhiteSpace(CommandLineOptions.Default.ProfileId) && var profileIndex = !string.IsNullOrWhiteSpace(CommandLineOptions.ProfileId) &&
profiles.Length > 0 profiles.Length > 0
? Array.FindIndex(profiles, ? Array.FindIndex(profiles,
p => p =>
p.Id.Equals(CommandLineOptions.Default.ProfileId, p.Id.Equals(null,
StringComparison.InvariantCultureIgnoreCase)) StringComparison.InvariantCultureIgnoreCase))
: -1; : -1;
switch (CommandLineOptions.Default.Action) switch (CommandLineOptions.Action)
{ {
case HeliosStartupAction.SwitchProfile: case HeliosStartupAction.SwitchProfile:
SwitchProfile(profiles, profileIndex); SwitchProfile(profiles, profileIndex);
@ -144,6 +172,8 @@ namespace HeliosDisplayManagement
break; break;
} }
} }
catch (Exception e) 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); .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); throw new Exception(Language.Executable_file_not_found);
} }
@ -194,17 +224,17 @@ namespace HeliosDisplayManagement
throw new Exception(Language.Can_not_change_active_profile); throw new Exception(Language.Can_not_change_active_profile);
} }
var process = Process.Start(CommandLineOptions.Default.ExecuteFilename, var process = System.Diagnostics.Process.Start(CommandLineOptions.ExecuteFilename,
CommandLineOptions.Default.ExecuteArguments); CommandLineOptions.ExecuteArguments);
var processes = new Process[0]; var processes = new System.Diagnostics.Process[0];
if (!string.IsNullOrWhiteSpace(CommandLineOptions.Default.ExecuteProcessName)) if (!string.IsNullOrWhiteSpace(CommandLineOptions.ExecuteProcessName))
{ {
var ticks = 0; 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) 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) if (!SteamGame.SteamInstalled)
{ {
@ -302,16 +332,16 @@ namespace HeliosDisplayManagement
var address = $"steam://rungameid/{steamGame.AppId}"; 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 // Wait for steam game to update and then run
var ticks = 0; var ticks = 0;
while (ticks < CommandLineOptions.Default.ExecuteProcessTimeout * 1000) while (ticks < CommandLineOptions.ExecuteProcessTimeout * 1000)
{ {
if (steamGame.IsRunning) if (steamGame.IsRunning)
{ {

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CircularProgressBar" version="2.6.6823.24527" targetFramework="net45" />
<package id="CommandLineParser" version="1.9.71" targetFramework="net45" />
<package id="HtmlAgilityPack" version="1.8.9" targetFramework="net45" />
<package id="IconLib.Unofficial" version="0.73.0" targetFramework="net452" />
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net45" />
<package id="WindowsDisplayAPI" version="1.2.0.2" targetFramework="net45" />
<package id="WinFormAnimation" version="1.5.6298.3372" targetFramework="net452" />
</packages>