private static void AcquireGuiConverter() { const string tempZip = "gui_converter.zip"; var guiConverterUrl = new Dictionary <OSPlatform, string> { { OSPlatform.OSX, "https://github.com/joshua-software-dev/SharpGuiConverter/releases/download/v1.0.0.0/gui_converter_macos10_10_64.zip" }, { OSPlatform.Linux, "https://github.com/joshua-software-dev/SharpGuiConverter/releases/download/v1.0.0.0/gui_converter_linux_64.zip" }, { OSPlatform.Windows, "https://github.com/joshua-software-dev/SharpGuiConverter/releases/download/v1.0.0.0/gui_converter_win_64.zip" }, }[Platform]; using (var client = new WebClient()) { client.DownloadFile(guiConverterUrl, tempZip); } ZipFile.ExtractToDirectory(tempZip, Environment.CurrentDirectory, true); File.Delete(tempZip); if (Platform != OSPlatform.Windows) { var unixFileInfo = new UnixFileInfo(GuiConverterExecutable); unixFileInfo.FileAccessPermissions |= FileAccessPermissions.UserExecute; unixFileInfo.Refresh(); } }
private static void CreateLinuxShellScript(string scriptPath, string targetPath, string arguments) { var file = new FileInfo(scriptPath); using var fs = file.Open(FileMode.Create, FileAccess.Write); using var writer = new StreamWriter(fs); writer.WriteLine("#!/usr/bin/env bash"); writer.WriteLine($"{targetPath} {arguments}"); var info = new UnixFileInfo(file.FullName); info.FileAccessPermissions |= FileAccessPermissions.UserExecute | FileAccessPermissions.GroupExecute; info.Refresh(); }
public static void SetLinuxFilePermission(FileAccessPermissions permissions, params string[] paths) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { return; } foreach (var path in paths) { var unixFileInfo = new UnixFileInfo(path) { FileAccessPermissions = permissions }; unixFileInfo.Refresh(); } }
private static void AcquireWarpPacker() { var warpPackerUrl = new Dictionary <OSPlatform, string> { { OSPlatform.OSX, "https://github.com/dgiagio/warp/releases/download/v0.3.0/macos-x64.warp-packer" }, { OSPlatform.Linux, "https://github.com/dgiagio/warp/releases/download/v0.3.0/linux-x64.warp-packer" }, { OSPlatform.Windows, "https://github.com/dgiagio/warp/releases/download/v0.3.0/windows-x64.warp-packer.exe" }, }[Platform]; using (var client = new WebClient()) { client.DownloadFile(warpPackerUrl, WarpPackerExecutable); } if (Platform != OSPlatform.Windows) { var unixFileInfo = new UnixFileInfo(WarpPackerExecutable); unixFileInfo.FileAccessPermissions |= FileAccessPermissions.UserExecute; unixFileInfo.Refresh(); } }