Make ZuneHost report errors on old systems

This commit is contained in:
Yoshi Askharoun
2023-04-28 18:53:00 -05:00
parent 1b5eecd837
commit 6e6a965a04
4 changed files with 58 additions and 28 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFrameworks>net6.0-windows10.0.22000;net40</TargetFrameworks>
<LangVersion>11.0</LangVersion>
<LangVersion>11.0</LangVersion>
<UseWPF>true</UseWPF>
<ApplicationIcon>Assets\ZuneFluentGem.ico</ApplicationIcon>
</PropertyGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
</configuration>
+42 -18
View File
@@ -1,5 +1,7 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
namespace ZuneHost
@@ -13,27 +15,34 @@ namespace ZuneHost
{
string strArgs = string.Join(" ", args);
// Make sure that ZuneDBApi can find all the Zune native libraries
Console.WriteLine("Copying Zune files...");
_zuneProgramDir = new(Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),
"Zune"));
if (_zuneProgramDir.Exists)
#if NETFRAMEWORK
Console.WriteLine("Running legacy build on .NET Framework. If your OS supports .NET Core, please use OpenZune.");
#endif
if (args.Contains("--copyFiles", StringComparer.InvariantCultureIgnoreCase))
{
foreach (var info in _zuneProgramDir.GetFileSystemInfos())
// Make sure that ZuneDBApi can find all the Zune native libraries
Console.WriteLine("Copying Zune files...");
_zuneProgramDir = new(Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),
"Zune"));
if (_zuneProgramDir.Exists)
{
if (info is DirectoryInfo dirInfo)
foreach (var info in _zuneProgramDir.GetFileSystemInfos())
{
CopyAll(dirInfo, new DirectoryInfo(Path.Combine(Environment.CurrentDirectory, dirInfo.Name)));
}
else if (info is FileInfo fileInfo)
{
string fileName = fileInfo.Name;
if (fileInfo.Extension == ".dll")
if (info is DirectoryInfo dirInfo)
{
string targetPath = Path.Combine(Environment.CurrentDirectory, fileName);
if (!File.Exists(targetPath) || fileName == "ZuneDbApi.dll")
fileInfo.CopyTo(targetPath);
CopyAll(dirInfo, new DirectoryInfo(Path.Combine(Environment.CurrentDirectory, dirInfo.Name)));
}
else if (info is FileInfo fileInfo)
{
string fileName = fileInfo.Name;
if (fileInfo.Extension == ".dll")
{
string targetPath = Path.Combine(Environment.CurrentDirectory, fileName);
if (!File.Exists(targetPath) || fileName == "ZuneDbApi.dll")
fileInfo.CopyTo(targetPath);
}
}
}
}
@@ -41,7 +50,22 @@ namespace ZuneHost
Console.WriteLine("Starting Zune...");
return Microsoft.Zune.Shell.ZuneApplication.Launch(strArgs, IntPtr.Zero);
try
{
return Microsoft.Zune.Shell.ZuneApplication.Launch(strArgs, IntPtr.Zero);
}
catch (FileNotFoundException ex)
{
Console.WriteLine(ex.FileName);
throw;
}
catch
{
Debugger.Launch();
Debugger.Break();
throw;
}
}
public static void CopyAll(DirectoryInfo source, DirectoryInfo target)
+14 -8
View File
@@ -1,14 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0-windows10.0.22000;net6.0;net40</TargetFrameworks>
<Platforms>AnyCPU;x64;x86;ARM32</Platforms>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net40;net6.0-windows10.0.22000;net6.0;</TargetFrameworks>
<Platforms>AnyCPU;x64;x86;ARM32</Platforms>
<LangVersion>11.0</LangVersion>
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\ZuneShell\ZuneShell.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Remove="build\**" />
<EmbeddedResource Remove="build\**" />
<None Remove="build\**" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ZuneShell\ZuneShell.csproj" />
</ItemGroup>
</Project>