Fix file path issues (hopefully)
This commit is contained in:
@@ -11,8 +11,9 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="Resources/**"
|
<Content Include="Resources/**">
|
||||||
CopyToPublishDirectory="PreserveNewest" />
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -20,24 +20,21 @@ public sealed class Stockfish : IAsyncDisposable
|
|||||||
public Stockfish(int skill = 20, int hash = 256)
|
public Stockfish(int skill = 20, int hash = 256)
|
||||||
{
|
{
|
||||||
_skill = skill;
|
_skill = skill;
|
||||||
string exePath = string.Empty;
|
string baseDir = AppContext.BaseDirectory; // always points to the folder that holds your DLL / EXE
|
||||||
|
string fileName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
|
||||||
|
? "stockfish-windows-x86-64-avx2.exe"
|
||||||
|
: RuntimeInformation.IsOSPlatform(OSPlatform.OSX)
|
||||||
|
? "stockfish-mac-x86-64-avx2"
|
||||||
|
: "stockfish-ubuntu-x86-64-sse41-popcnt"; // default: Linux
|
||||||
|
|
||||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
string exePath = Path.Combine(baseDir, "Resources", fileName);
|
||||||
|
|
||||||
|
if (!File.Exists(exePath))
|
||||||
{
|
{
|
||||||
string relativeFilePath = @"\Resources\stockfish-windows-x86-64-avx2.exe";
|
throw new FileNotFoundException($"Stockfish executable not found at {exePath}. " +
|
||||||
exePath = Assembly.GetExecutingAssembly().Location.Split(@"\bin\")[0] + relativeFilePath;
|
"Ensure the file is present in the Resources folder of your project.");
|
||||||
}
|
}
|
||||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
|
||||||
{
|
|
||||||
string relativeFilePath = @"/Resources/stockfish-ubuntu-x86-64-sse41-popcnt";
|
|
||||||
exePath = Assembly.GetExecutingAssembly().Location.Split(@"/bin/")[0] + relativeFilePath;
|
|
||||||
}
|
|
||||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
|
||||||
{
|
|
||||||
string relativeFilePath = @"/Resources/stockfish-mac-x86-64-avx2";
|
|
||||||
exePath = Assembly.GetExecutingAssembly().Location.Split(@"/bin/")[0] + relativeFilePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
Console.Write(exePath);
|
Console.Write(exePath);
|
||||||
|
|
||||||
_p = new Process
|
_p = new Process
|
||||||
|
|||||||
Reference in New Issue
Block a user