2017-11-04 23:17:04 +01:00
|
|
|
|
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)
|
2017-11-04 23:17:04 +01:00
|
|
|
|
{
|
|
|
|
|
|
string netCorePublishRid = string.Empty;
|
|
|
|
|
|
string electronPackerPlatform = string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
switch (desiredPlatform)
|
|
|
|
|
|
{
|
|
|
|
|
|
case "win":
|
|
|
|
|
|
netCorePublishRid = "win-x64";
|
2019-07-26 16:31:44 +02:00
|
|
|
|
electronPackerPlatform = "win";
|
2017-11-04 23:17:04 +01:00
|
|
|
|
break;
|
|
|
|
|
|
case "osx":
|
|
|
|
|
|
netCorePublishRid = "osx-x64";
|
2019-07-26 16:31:44 +02:00
|
|
|
|
electronPackerPlatform = "mac";
|
2017-11-04 23:17:04 +01:00
|
|
|
|
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;
|
2017-11-04 23:17:04 +01:00
|
|
|
|
default:
|
2018-02-11 22:24:12 +01:00
|
|
|
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
2017-11-04 23:17:04 +01:00
|
|
|
|
{
|
2019-01-10 20:47:27 +02:00
|
|
|
|
netCorePublishRid = $"win-x{(Environment.Is64BitOperatingSystem ? "64" : "86")}";
|
2019-07-26 16:31:44 +02:00
|
|
|
|
electronPackerPlatform = "win";
|
2017-11-04 23:17:04 +01:00
|
|
|
|
}
|
2018-02-11 22:24:12 +01:00
|
|
|
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
2017-11-04 23:17:04 +01:00
|
|
|
|
{
|
2018-02-11 22:24:12 +01:00
|
|
|
|
netCorePublishRid = "osx-x64";
|
2019-07-26 16:31:44 +02:00
|
|
|
|
electronPackerPlatform = "mac";
|
2018-02-11 22:24:12 +01:00
|
|
|
|
}
|
|
|
|
|
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
|
|
|
|
|
{
|
|
|
|
|
|
netCorePublishRid = "linux-x64";
|
|
|
|
|
|
electronPackerPlatform = "linux";
|
2017-11-04 23:17:04 +01:00
|
|
|
|
}
|
2018-01-24 22:39:46 +01:00
|
|
|
|
|
2017-11-04 23:17:04 +01:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return new GetTargetPlatformInformationResult()
|
|
|
|
|
|
{
|
|
|
|
|
|
ElectronPackerPlatform = electronPackerPlatform,
|
|
|
|
|
|
NetCorePublishRid = netCorePublishRid
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|