diff --git a/VECTO.sln b/VECTO.sln index 4a667b740b39a26e781a8a951d8a457351c6dcfc..c26e2ed2b435224f53b1119cebeb2c90540c2dd0 100644 --- a/VECTO.sln +++ b/VECTO.sln @@ -68,6 +68,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VectoAPI", "..\VECTO-API\Ve EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VectoAPI Test", "..\VECTO-API\VectoAPI Test\VectoAPI Test.csproj", "{D959CB7C-F514-4F5E-9C33-684D0012474B}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VECTOStart", "VECTOStart\VECTOStart.csproj", "{A151C75E-471A-42EB-8FE2-296C8D9FB8F9}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -220,6 +222,12 @@ Global {D959CB7C-F514-4F5E-9C33-684D0012474B}.Deploy|Any CPU.Build.0 = Debug|Any CPU {D959CB7C-F514-4F5E-9C33-684D0012474B}.Release|Any CPU.ActiveCfg = Release|Any CPU {D959CB7C-F514-4F5E-9C33-684D0012474B}.Release|Any CPU.Build.0 = Release|Any CPU + {A151C75E-471A-42EB-8FE2-296C8D9FB8F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A151C75E-471A-42EB-8FE2-296C8D9FB8F9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A151C75E-471A-42EB-8FE2-296C8D9FB8F9}.Deploy|Any CPU.ActiveCfg = Debug|Any CPU + {A151C75E-471A-42EB-8FE2-296C8D9FB8F9}.Deploy|Any CPU.Build.0 = Debug|Any CPU + {A151C75E-471A-42EB-8FE2-296C8D9FB8F9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A151C75E-471A-42EB-8FE2-296C8D9FB8F9}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/VECTOStart/Icon2.ico b/VECTOStart/Icon2.ico new file mode 100644 index 0000000000000000000000000000000000000000..6de7e5cd7ef1e97f70d64cb3eeaa2b7fcc8d604f Binary files /dev/null and b/VECTOStart/Icon2.ico differ diff --git a/VECTOStart/Program.cs b/VECTOStart/Program.cs new file mode 100644 index 0000000000000000000000000000000000000000..98ffa01c5717c3e5c277e3e13360e94991c6bbad --- /dev/null +++ b/VECTOStart/Program.cs @@ -0,0 +1,61 @@ +using System; +using Microsoft.Win32; +using System.Diagnostics; + +namespace TUGraz.VECTO +{ + class Program + { + static void Main() + { + var version = GetHighestNETVersion(); + try { + Process.Start(new ProcessStartInfo($"{version}\\VECTO.exe") { CreateNoWindow = true }); + } catch (Exception e) { + Console.WriteLine($"Could not start VECTO with {version}: {e.Message}"); + Console.ReadKey(); + } + } + + private static string GetHighestNETVersion() + { + if (SupportsNet50()) { + return "net5.0"; + } + + if (SupportsNET48()) { + return "net48"; + } + + return "net45"; + } + + private static bool SupportsNet50() + { + var p = Process.Start(new ProcessStartInfo("dotnet", "--list-runtimes") { + CreateNoWindow = true, + UseShellExecute = false, + RedirectStandardError = true, + RedirectStandardOutput = true + } + ); + + p.WaitForExit(); + var output = p.StandardOutput.ReadToEnd(); + return output.Contains("Microsoft.WindowsDesktop.App 5.0"); + } + + private static bool SupportsNET48() + { + const string subkey = @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\"; + using (var ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey(subkey)) { + if (ndpKey != null && ndpKey.GetValue("Release") != null) { + var releaseKey = (int)ndpKey.GetValue("Release"); + return releaseKey >= 528040; + } + + return false; + } + } + } +} diff --git a/VECTOStart/VECTOStart.csproj b/VECTOStart/VECTOStart.csproj new file mode 100644 index 0000000000000000000000000000000000000000..0205246a2da48714ff0141322dbc9622ce7d94c6 --- /dev/null +++ b/VECTOStart/VECTOStart.csproj @@ -0,0 +1,26 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <OutputType>Exe</OutputType> + <TargetFrameworks /> + <TargetFramework>net45</TargetFramework> + <AssemblyName>VECTO</AssemblyName> + <ApplicationIcon>Icon2.ico</ApplicationIcon> + <PackageIconUrl /> + <RootNamespace>TUGraz.VECTO</RootNamespace> + <AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects> + </PropertyGroup> + + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> + <DefineConstants /> + <AllowUnsafeBlocks>false</AllowUnsafeBlocks> + </PropertyGroup> + + <ItemGroup> + <None Include="..\VECTO\Resources\Icon.png"> + <Pack>True</Pack> + <PackagePath></PackagePath> + </None> + </ItemGroup> + +</Project>