Files
Electron.NET/ElectronNET.CLI/Commands/Actions/GetTargetPlatformInformation.cs

71 lines
2.5 KiB
C#
Raw Normal View History

using System;
using System.Runtime.InteropServices;
namespace ElectronNET.CLI.Commands.Actions
{
public static class GetTargetPlatformInformation
{
public struct GetTargetPlatformInformationResult
{
public string NetCorePublishRid { get; set; }
public string ElectronPackerPlatform { get; set; }
}
2018-02-11 22:24:12 +01:00
public static GetTargetPlatformInformationResult Do(string desiredPlatform, string specifiedPlatfromFromCustom)
{
string netCorePublishRid = string.Empty;
string electronPackerPlatform = string.Empty;
switch (desiredPlatform)
{
case "win":
netCorePublishRid = "win-x64";
electronPackerPlatform = "win";
break;
case "osx":
netCorePublishRid = "osx-x64";
electronPackerPlatform = "mac";
break;
case "linux":
netCorePublishRid = "linux-x64";
electronPackerPlatform = "linux";
break;
2018-04-19 21:14:00 +02:00
case "linux-arm":
netCorePublishRid = "linux-arm";
electronPackerPlatform = "linux";
break;
2018-02-11 22:24:12 +01:00
case "custom":
var splittedSpecified = specifiedPlatfromFromCustom.Split(';');
netCorePublishRid = splittedSpecified[0];
electronPackerPlatform = splittedSpecified[1];
break;
default:
2018-02-11 22:24:12 +01:00
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
netCorePublishRid = $"win-x{(Environment.Is64BitOperatingSystem ? "64" : "86")}";
electronPackerPlatform = "win";
}
2018-02-11 22:24:12 +01:00
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
2018-02-11 22:24:12 +01:00
netCorePublishRid = "osx-x64";
electronPackerPlatform = "mac";
2018-02-11 22:24:12 +01:00
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
netCorePublishRid = "linux-x64";
electronPackerPlatform = "linux";
}
2018-01-24 22:39:46 +01:00
break;
}
return new GetTargetPlatformInformationResult()
{
ElectronPackerPlatform = electronPackerPlatform,
NetCorePublishRid = netCorePublishRid
};
}
}
}