A Swiss Army knife for developers.
C# blazorcross-platformcsharpdesktopdesktop-appdesktop-applicationdeveloper-toolsextensiblefluentfluent-designlinuxmacosmicasyntax-highlightingtypescriptwindowswindows-10windows-11winui
Fix crash on Linux on startup (#1046)
Etienne BAUDOUXa9a959fb9887
diff --git a/.nuke/build.schema.json b/.nuke/build.schema.jsonindex f60885a1c..40579afa5 100644--- a/.nuke/build.schema.json+++ b/.nuke/build.schema.json@@ -43,6 +43,10 @@"VSCode"]},+ "LinuxSolution": {+ "type": "string",+ "description": "Path to a solution file that is automatically loaded"+ },"MacSolution": {"type": "string","description": "Path to a solution file that is automatically loaded"diff --git a/.nuke/parameters.json b/.nuke/parameters.jsonindex 3c9460a70..e6750498c 100644--- a/.nuke/parameters.json+++ b/.nuke/parameters.json@@ -1,5 +1,6 @@{"$schema": "./build.schema.json","WindowsSolution": "src/DevToys-Windows.sln",- "MacSolution": "src/DevToys-MacOS.sln"+ "MacSolution": "src/DevToys-MacOS.sln",+ "LinuxSolution": "src/DevToys-Linux.sln"}\ No newline at end of filediff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex d947abb12..f7efff3e3 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -86,11 +86,13 @@ Most of the `DevToys.MacOS` app runs in a web browser (Safari). In order to acce## From Linux### Prerequisites-1. Make sure your machine has GTK4 installed. Distro like Ubuntu generally have it pre-installed.+1. Make sure your machine has GTK4 and WebKitGTK installed. Distro like Ubuntu generally have it pre-installed.1. [**Visual Studio Code**](https://code.visualstudio.com/) with [**C# Dev Kit**](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit), or [**JetBrains Rider**](https://www.jetbrains.com/rider/).1. **.NET SDK**. This is required to build the app itself.* [.NET 8.0 SDK](https://dotnet.microsoft.com/download/dotnet-core/8.0) (**version 8.0 (SDK 8.0.100)** or later).- > Use `dotnet --version` from the terminal to get the version installed.+ * Unless GTK has been installed through `snap`, we recommend to avoid installing .NET from `snap`.+ * We recommend installing .NET from the [official script](https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual#scripted-install), then [the dependencies](https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#dependencies), and finally set the [environment variables](https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual#set-environment-variables-system-wide).+ * > Use `dotnet --version` from the terminal to get the version installed.1. [Node.js](https://nodejs.org/) **14.0 or later**. This is required to build Monaco Editor.### Finalize your environmentdiff --git a/src/Directory.Packages.props b/src/Directory.Packages.propsindex 3bf957483..8a6d4d6ae 100644--- a/src/Directory.Packages.props+++ b/src/Directory.Packages.props@@ -32,7 +32,7 @@<PackageVersion Include="Moq" Version="4.18.4" /><PackageVersion Include="Newtonsoft.Json" Version="13.0.3" /><PackageVersion Include="NuGet.Packaging" Version="6.8.0" />- <PackageVersion Include="Nuke.Common" Version="7.0.2" />+ <PackageVersion Include="Nuke.Common" Version="8.0.0" /><PackageVersion Include="OneOf" Version="3.0.263" /><PackageVersion Include="SixLabors.ImageSharp" Version="3.0.2" /><PackageVersion Include="System.Text.Json" Version="$(DotNetVersion)" />diff --git a/src/app/dev/DevToys.Api/DevToys.Api.csproj b/src/app/dev/DevToys.Api/DevToys.Api.csprojindex db7815490..c9c77d24f 100644--- a/src/app/dev/DevToys.Api/DevToys.Api.csproj+++ b/src/app/dev/DevToys.Api/DevToys.Api.csproj@@ -1,4 +1,4 @@-<Project Sdk="Microsoft.NET.Sdk">+<Project Sdk="Microsoft.NET.Sdk"><PropertyGroup><TargetFrameworks>$(NetCore)</TargetFrameworks><GenerateDocumentationFile>true</GenerateDocumentationFile>@@ -7,7 +7,7 @@<PropertyGroup><!-- NuGet package --><GeneratePackageOnBuild>True</GeneratePackageOnBuild>- <Version>2.0.0-pre.2</Version>+ <Version>2.0.0-pre.0</Version><Authors>veler,btiteux</Authors><Description>SDK for developing extensions for DevToys 2.0 and higher</Description><PackageProjectUrl>https://devtoys.app</PackageProjectUrl>diff --git a/src/app/dev/DevToys.Tools/DevToys.Tools.csproj b/src/app/dev/DevToys.Tools/DevToys.Tools.csprojindex b688b2b1a..b89648cf1 100644--- a/src/app/dev/DevToys.Tools/DevToys.Tools.csproj+++ b/src/app/dev/DevToys.Tools/DevToys.Tools.csproj@@ -11,7 +11,7 @@<IncludeBuildOutput>true</IncludeBuildOutput><CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>- <Version>2.0.0-pre.2</Version>+ <Version>2.0.0-pre.0</Version><Title>DevToys.Tools</Title><Description>A set of offline tools installed by default with DevToys.</Description><PackageProjectUrl>https://devtoys.app</PackageProjectUrl>diff --git a/src/app/dev/platforms/desktop/DevToys.Linux/Components/BlazorWebView/BlazorAssetFileProvider.cs b/src/app/dev/platforms/desktop/DevToys.Linux/Components/BlazorWebView/BlazorAssetFileProvider.csnew file mode 100644index 000000000..eb0c666d0--- /dev/null+++ b/src/app/dev/platforms/desktop/DevToys.Linux/Components/BlazorWebView/BlazorAssetFileProvider.cs@@ -0,0 +1,75 @@+using System.Collections;+using System.Reflection;+using Microsoft.Extensions.FileProviders;+using Microsoft.Extensions.Primitives;++namespace DevToys.Linux.Components;++/// <summary>+/// A minimal implementation of an <see cref="IFileProvider"/> to be used by the <see cref="BlazorWebView"/> and <see cref="BlazorWebViewBridge"/> types.+/// </summary>+internal sealed class BlazorAssetFileProvider : IFileProvider+{+ private readonly string _bundleRootDir;++ public BlazorAssetFileProvider(string contentRootDir)+ {+ _bundleRootDir = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly()!.Location)!, contentRootDir);+ }++ public IDirectoryContents GetDirectoryContents(string subpath)+ => new BlazorAssetDirectoryContents(Path.Combine(_bundleRootDir, subpath));++ public IFileInfo GetFileInfo(string subpath)+ => new BlazorAssetFileInfo(Path.Combine(_bundleRootDir, subpath));++ public IChangeToken Watch(string filter)+ => NullChangeToken.Singleton;++ private sealed class BlazorAssetFileInfo : IFileInfo+ {+ private readonly string _filePath;++ internal BlazorAssetFileInfo(string filePath)+ {+ _filePath = filePath;++ Name = Path.GetFileName(_filePath);++ var fileInfo = new FileInfo(_filePath);+ Exists = fileInfo.Exists;+ Length = Exists ? fileInfo.Length : -1;+ }++ public bool Exists { get; }++ public long Length { get; }++ public string PhysicalPath => null!;++ public string Name { get; }++ public DateTimeOffset LastModified { get; } = DateTimeOffset.FromUnixTimeSeconds(0);++ public bool IsDirectory => false;++ public Stream CreateReadStream()+ => File.OpenRead(_filePath);+ }++ // This is never used by BlazorWebView or WebViewManager+ private sealed class BlazorAssetDirectoryContents : IDirectoryContents+ {+ internal BlazorAssetDirectoryContents(string filePath)+ {+ }++ public bool Exists => false;++ public IEnumerator<IFileInfo> GetEnumerator()+ => throw new NotImplementedException();++ IEnumerator IEnumerable.GetEnumerator()+ => throw new NotImplementedException();+ }+}diff --git a/src/app/dev/platforms/desktop/DevToys.Linux/Components/BlazorWebView/BlazorWebView.cs b/src/app/dev/platforms/desktop/DevToys.Linux/Components/BlazorWebView/BlazorWebView.csindex 95b870765..20a76b6c6 100644--- a/src/app/dev/platforms/desktop/DevToys.Linux/Components/BlazorWebView/BlazorWebView.cs+++ b/src/app/dev/platforms/desktop/DevToys.Linux/Components/BlazorWebView/BlazorWebView.cs@@ -7,12 +7,26 @@ internal sealed class BlazorWebView : WebView{private readonly BlazorWebViewBridge _bridge;+ static BlazorWebView()+ {+ WebKit.Module.Initialize();+ }+internal BlazorWebView(IServiceProvider serviceProvider){+ BlazorWebViewOptions options = serviceProvider.GetRequiredService<BlazorWebViewOptions>();++ // We assume the host page is always in the root of the content directory, because it's+ // unclear there's any other use case. We can add more options later if so.+ string contentRootDir = Path.GetDirectoryName(options.HostPath) ?? string.Empty;+ string hostPageRelativePath = Path.GetRelativePath(contentRootDir, options.HostPath);+_bridge= new BlazorWebViewBridge(this,serviceProvider,- serviceProvider.GetRequiredService<BlazorWebViewOptions>());+ options,+ contentRootDir,+ hostPageRelativePath);}}diff --git a/src/app/dev/platforms/desktop/DevToys.Linux/Components/BlazorWebView/BlazorWebViewBridge.cs b/src/app/dev/platforms/desktop/DevToys.Linux/Components/BlazorWebView/BlazorWebViewBridge.csindex 384f2f540..73b95aced 100644--- a/src/app/dev/platforms/desktop/DevToys.Linux/Components/BlazorWebView/BlazorWebViewBridge.cs+++ b/src/app/dev/platforms/desktop/DevToys.Linux/Components/BlazorWebView/BlazorWebViewBridge.cs@@ -12,7 +12,7 @@ namespace DevToys.Linux.Components;internal sealed class BlazorWebViewBridge : WebViewManager{private const string Scheme = "app";- private static readonly Uri baseUri = new($"{Scheme}://localhost/");+ private static readonly Uri AppOriginUri = new($"{Scheme}://localhost/");private readonly BlazorWebView _webView;private readonly string _relativeHostPath;@@ -20,14 +20,16 @@ internal sealed class BlazorWebViewBridge : WebViewManagerpublic BlazorWebViewBridge(BlazorWebView webView,IServiceProvider serviceProvider,- BlazorWebViewOptions options)+ BlazorWebViewOptions options,+ string contentRootRelativeToAppRoot,+ string hostPageRelativePath): base(serviceProvider,Dispatcher.CreateDefault(),- baseUri,- new PhysicalFileProvider(options.ContentRoot),+ AppOriginUri,+ new BlazorAssetFileProvider(Path.Combine(options.ContentRoot, contentRootRelativeToAppRoot)),new JSComponentConfigurationStore(),- options.RelativeHostPath)+ hostPageRelativePath){Guard.IsNotNull(webView);_webView = webView;@@ -35,14 +37,18 @@ internal sealed class BlazorWebViewBridge : WebViewManager_relativeHostPath = options.RelativeHostPath;Type rootComponent = options.RootComponent;- // This is necessary to automatically serve the files in the `_framework` virtual folder.- // Using `file://` will cause the webview to look for the `_framework` files on the file system,- // and it won't find them.- if (_webView.WebContext is null)+ try+ {+ Guard.IsNotNull(_webView.WebContext); // this might be null or crash when trying to access the WebContext property.+ }+ catch (Exception e){- throw new Exception("WebView.WebContext is null");+ throw new DllNotFoundException("WebKitGTK could not be found. Please verify that the package 'libwebkitgtk-6.0-4' is installed on the operating system and retry.");}+ // This is necessary to automatically serve the files in the `_framework` virtual folder.+ // Using `file://` will cause the webview to look for the `_framework` files on the file system,+ // and it won't find them._webView.WebContext.RegisterUriScheme(Scheme, HandleUriScheme);Dispatcher.InvokeAsync(async () =>@@ -101,7 +107,7 @@ internal sealed class BlazorWebViewBridge : WebViewManagerprivate void HandleScriptMessageReceivedSignal(UserContentManager ucm, UserContentManager.ScriptMessageReceivedSignalArgs signalArgs){JavaScriptCore.Value result = signalArgs.Value;- MessageReceived(baseUri, result.ToString());+ MessageReceived(AppOriginUri, result.ToString());}private void HandleUriScheme(URISchemeRequest request)@@ -112,14 +118,11 @@ internal sealed class BlazorWebViewBridge : WebViewManager}string uri = request.GetUri();- if (request.GetPath() == "/")- {- uri += _relativeHostPath;- }+ bool allowFallbackOnHostPage = IsUriBaseOfPage(AppOriginUri, uri);if (TryGetResponseContent(uri,- false,+ allowFallbackOnHostPage,out int statusCode,out string? statusMessage,out Stream? content,@@ -138,6 +141,18 @@ internal sealed class BlazorWebViewBridge : WebViewManager}}+ private static bool IsUriBaseOfPage(Uri baseUri, string? uriString)+ {+ if (Path.HasExtension(uriString))+ {+ // If the path ends in a file extension, it's not referring to a page.+ return false;+ }++ var uri = new Uri(uriString!);+ return baseUri.IsBaseOf(uri);+ }+// Workaround for protection level accessprivate class InputStream : Gio.InputStream{diff --git a/src/app/dev/platforms/desktop/DevToys.Linux/Components/BlazorWebView/BlazorWebViewOptions.cs b/src/app/dev/platforms/desktop/DevToys.Linux/Components/BlazorWebView/BlazorWebViewOptions.csindex 4cabf579c..91c59c51e 100644--- a/src/app/dev/platforms/desktop/DevToys.Linux/Components/BlazorWebView/BlazorWebViewOptions.cs+++ b/src/app/dev/platforms/desktop/DevToys.Linux/Components/BlazorWebView/BlazorWebViewOptions.cs@@ -1,3 +1,5 @@+using System.Reflection;+namespace DevToys.Linux.Components;internal record BlazorWebViewOptions@@ -6,7 +8,7 @@ internal record BlazorWebViewOptionsinternal string HostPath { get; init; } = Path.Combine("wwwroot", "index.html");- internal string ContentRoot => Path.GetDirectoryName(Path.GetFullPath(HostPath))!;+ internal string ContentRoot { get; init; } = Path.GetDirectoryName(Assembly.GetEntryAssembly()!.Location)!;internal string RelativeHostPath => Path.GetRelativePath(ContentRoot, HostPath);}diff --git a/src/app/dev/platforms/desktop/DevToys.Linux/Core/FileStorage.cs b/src/app/dev/platforms/desktop/DevToys.Linux/Core/FileStorage.csindex 8240f755d..155d744c7 100644--- a/src/app/dev/platforms/desktop/DevToys.Linux/Core/FileStorage.cs+++ b/src/app/dev/platforms/desktop/DevToys.Linux/Core/FileStorage.cs@@ -6,16 +6,8 @@ using Gtk;namespace DevToys.Linux.Core;[Export(typeof(IFileStorage))]-internal sealed class FileStorage : GObject.Object, IFileStorage+internal sealed class FileStorage : IFileStorage{- [ImportingConstructor]- public FileStorage()- : base(- Gtk.Internal.FileDialog.New(),- ownedRef: true)- {- }-public string AppCacheDirectory => Constants.AppCacheDirectory;internal Gtk.Window? MainWindow { private get; set; }@@ -69,47 +61,39 @@ internal sealed class FileStorage : GObject.Object, IFileStoragepublic async ValueTask<string?> PickFolderAsync(){Guard.IsNotNull(MainWindow);- var tcs = new TaskCompletionSource<Gio.File?>();- var callbackHandler = new Gio.Internal.AsyncReadyCallbackAsyncHandler((sourceObject, res, data) =>+ // Create a new GtkFileChooserNative object and set its properties+ using var fileChooser+ = Gtk.FileChooserNative.New(+ Other.OpenFolder,+ MainWindow,+ Gtk.FileChooserAction.SelectFolder,+ Other.Open,+ Other.Cancel);+ fileChooser.Modal = true;+ fileChooser.SelectMultiple = false;++ var taskCompletionSource = new TaskCompletionSource<Gio.File?>();+ fileChooser.OnResponse += (_, e) =>{- if (sourceObject is null)+ // Handle the result of the window.+ if (e.ResponseId != (int)Gtk.ResponseType.Accept){- tcs.SetException(new Exception("Missing source object"));+ taskCompletionSource.SetResult(null);return;}- nint fileValue- = Gtk.Internal.FileDialog.SelectFolderFinish(- sourceObject.Handle,- res.Handle,- out GLib.Internal.ErrorOwnedHandle? error);+ Gio.File? folder = fileChooser.GetCurrentFolder();- if (!error.IsInvalid)- {- tcs.SetException(new GLib.GException(error));- }- else if (fileValue == IntPtr.Zero)- {- tcs.SetResult(null);- }- else- {- tcs.SetResult(new Gio.FileHelper(fileValue, true));- }- });+ taskCompletionSource.SetResult(folder);+ };- Gtk.Internal.FileDialog.SelectFolder(- self: base.Handle,- parent: MainWindow.Handle,- cancellable: IntPtr.Zero,- callback: callbackHandler.NativeCallback,- userData: IntPtr.Zero- );+ // Show the dialog.+ fileChooser.Show();try{- Gio.File? folder = await tcs.Task;+ Gio.File? folder = await taskCompletionSource.Task;if (folder is not null){string? folderPath = folder.GetPath();diff --git a/src/app/dev/platforms/desktop/DevToys.Linux/Core/ThemeListener.cs b/src/app/dev/platforms/desktop/DevToys.Linux/Core/ThemeListener.csindex 37a3f5052..6254d54c9 100644--- a/src/app/dev/platforms/desktop/DevToys.Linux/Core/ThemeListener.cs+++ b/src/app/dev/platforms/desktop/DevToys.Linux/Core/ThemeListener.cs@@ -1,4 +1,5 @@-using DevToys.Api;+using Adw;+using DevToys.Api;using DevToys.Core.Settings;using DevToys.Blazor.Components;using DevToys.Blazor.Core.Services;@@ -11,8 +12,11 @@ namespace DevToys.Linux.Core;internal sealed class ThemeListener : IThemeListener{private readonly ISettingsProvider _settingsProvider;+ private readonly Gtk.Settings _gtkSettings;+ private readonly StyleManager _adwStyleManager;private Gtk.Window? _mainWindow;+ private bool _ignoreOperatingSystemSettingChanged;[ImportingConstructor]public ThemeListener(ISettingsProvider settingsProvider)@@ -21,12 +25,11 @@ internal sealed class ThemeListener : IThemeListener_settingsProvider = settingsProvider;_settingsProvider.SettingChanged += SettingsProvider_SettingChanged;+ _adwStyleManager = StyleManager.GetDefault();+// Listen for operating system settings.- var gtkSettings = Gtk.Settings.GetDefault();- if (gtkSettings is not null)- {- gtkSettings.OnNotify += System_RequestedThemeChanged;- }+ _gtkSettings = Gtk.Settings.GetDefault()!;+ _gtkSettings.OnNotify += System_RequestedThemeChanged;UpdateSystemSettingsAndApplyTheme();@@ -57,13 +60,21 @@ internal sealed class ThemeListener : IThemeListener}// Set theme for window root.- if (theme == AvailableApplicationTheme.Dark)+ if (_gtkSettings.GtkThemeName is not null){- ActualAppTheme = ApplicationTheme.Dark;- }- else- {- ActualAppTheme = ApplicationTheme.Light;+ _ignoreOperatingSystemSettingChanged = true;+ if (theme == AvailableApplicationTheme.Dark)+ {+ ActualAppTheme = ApplicationTheme.Dark;+ _adwStyleManager.ColorScheme = ColorScheme.ForceDark;+ }+ else+ {+ ActualAppTheme = ApplicationTheme.Light;+ _adwStyleManager.ColorScheme = ColorScheme.ForceLight;+ }++ _ignoreOperatingSystemSettingChanged = false;}ThemeChanged?.Invoke(this, EventArgs.Empty);@@ -96,7 +107,10 @@ internal sealed class ThemeListener : IThemeListenerprivate void System_RequestedThemeChanged(Object? sender, NotifySignalArgs e){- UpdateSystemSettingsAndApplyTheme();+ if (!_ignoreOperatingSystemSettingChanged)+ {+ UpdateSystemSettingsAndApplyTheme();+ }}private void UpdateCompactModeBasedOnWindowSize()@@ -126,20 +140,14 @@ internal sealed class ThemeListener : IThemeListenerprivate void UpdateSystemSettingsAndApplyTheme(){- IsHighContrast = false; // TODO: Detect high contrast+ IsHighContrast = _adwStyleManager.HighContrast;CurrentSystemTheme = GetCurrentSystemTheme();ApplyDesiredColorTheme();}- private static AvailableApplicationTheme GetCurrentSystemTheme()+ private AvailableApplicationTheme GetCurrentSystemTheme(){- var gtkSettings = Gtk.Settings.GetDefault();- if (gtkSettings is not null)- {- return gtkSettings.GtkApplicationPreferDarkTheme ? AvailableApplicationTheme.Dark : AvailableApplicationTheme.Light;- }-- return AvailableApplicationTheme.Light;+ return _gtkSettings.GtkApplicationPreferDarkTheme ? AvailableApplicationTheme.Dark : AvailableApplicationTheme.Light;}}diff --git a/src/app/dev/platforms/desktop/DevToys.Linux/DevToys.Linux.csproj b/src/app/dev/platforms/desktop/DevToys.Linux/DevToys.Linux.csprojindex 5e7a85ae9..4e09aaadd 100644--- a/src/app/dev/platforms/desktop/DevToys.Linux/DevToys.Linux.csproj+++ b/src/app/dev/platforms/desktop/DevToys.Linux/DevToys.Linux.csproj@@ -25,7 +25,7 @@<ItemGroup><Content Include="$(RepoRoot)\src\app\dev\platforms\desktop\DevToys.Windows\wwwroot\index.html" Link="wwwroot\index.html">- <CopyToOutputDirectory>Always</CopyToOutputDirectory>+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory></Content></ItemGroup>diff --git a/src/app/dev/platforms/desktop/DevToys.Linux/LinuxProgram.cs b/src/app/dev/platforms/desktop/DevToys.Linux/LinuxProgram.csindex 8a16f50d3..0ae85b200 100644--- a/src/app/dev/platforms/desktop/DevToys.Linux/LinuxProgram.cs+++ b/src/app/dev/platforms/desktop/DevToys.Linux/LinuxProgram.cs@@ -11,8 +11,10 @@ using DevToys.Linux.Core;using Microsoft.Extensions.DependencyInjection;using Microsoft.Extensions.Logging;using DevToys.Core.Logging;-using DevToys.Core;using DevToys.Core.Tools;+using Gio;+using Constants = DevToys.Linux.Core.Constants;+using FileHelper = DevToys.Core.FileHelper;namespace DevToys.Linux;@@ -29,9 +31,11 @@ internal partial class LinuxPrograminternal LinuxProgram(){- WebKit.Module.Initialize();+ Application = Adw.Application.New(null, Gio.ApplicationFlags.NonUnique);- Application = Adw.Application.New("devtoys", Gio.ApplicationFlags.FlagsNone);+ GLib.Functions.SetPrgname("DevToys");+ // Set the human-readable application name for app bar and task list.+ GLib.Functions.SetApplicationName("DevToys");Application.OnActivate += OnApplicationActivate;Application.OnShutdown += OnApplicationShutdown;@@ -55,11 +59,7 @@ internal partial class LinuxProgram// Initialize extension installation folder, and uninstall extensions that are planned for being removed.string[] pluginFolders- = new[]- {- Path.Combine(AppContext.BaseDirectory!, "Plugins"),- Constants.PluginInstallationFolder- };+ = new[] { Path.Combine(AppContext.BaseDirectory!, "Plugins"), Constants.PluginInstallationFolder };ExtensionInstallationManager.PreferredExtensionInstallationFolder = Constants.PluginInstallationFolder;ExtensionInstallationManager.ExtensionInstallationFolders = pluginFolders;ExtensionInstallationManager.UninstallExtensionsScheduledForRemoval();@@ -67,10 +67,7 @@ internal partial class LinuxProgram// Initialize MEF.MefComposer= new MefComposer(- assemblies: new[] {- typeof(MainWindowViewModel).Assembly,- typeof(DevToysBlazorResourceManagerAssemblyIdentifier).Assembly- },+ assemblies: new[] { typeof(MainWindowViewModel).Assembly, typeof(DevToysBlazorResourceManagerAssemblyIdentifier).Assembly },pluginFolders);LogInitialization((DateTime.Now - _startTime).TotalMilliseconds);@@ -80,7 +77,7 @@ internal partial class LinuxProgramstring? languageIdentifier = MefComposer.Provider.Import<ISettingsProvider>().GetSetting(PredefinedSettings.Language);LanguageDefinition languageDefinition= LanguageManager.Instance.AvailableLanguages.FirstOrDefault(l => string.Equals(l.InternalName, languageIdentifier))- ?? LanguageManager.Instance.AvailableLanguages[0];+ ?? LanguageManager.Instance.AvailableLanguages[0];LanguageManager.Instance.SetCurrentCulture(languageDefinition);// Create and open main window.@@ -106,10 +103,7 @@ internal partial class LinuxProgram_serviceCollection.AddBlazorWebView();_serviceCollection.AddSingleton(- new BlazorWebViewOptions()- {- RootComponent = typeof(DevToys.Blazor.Main)- }+ new BlazorWebViewOptions() { RootComponent = typeof(DevToys.Blazor.Main) });_serviceCollection.AddLogging((ILoggingBuilder builder) =>diff --git a/src/app/dev/platforms/desktop/DevToys.Linux/MainWindow.cs b/src/app/dev/platforms/desktop/DevToys.Linux/MainWindow.csindex 561110c15..06ea9a384 100644--- a/src/app/dev/platforms/desktop/DevToys.Linux/MainWindow.cs+++ b/src/app/dev/platforms/desktop/DevToys.Linux/MainWindow.cs@@ -4,6 +4,7 @@ using DevToys.Core;using DevToys.Linux.Components;using DevToys.Linux.Core;using Microsoft.Extensions.DependencyInjection;+using WebKit;namespace DevToys.Linux;@@ -23,7 +24,7 @@ internal class MainWindowprivate TitleBarInfoProvider _titleBarInfoProvider = default!;#pragma warning restore IDE0044 // Add readonly modifier- private readonly BlazorWebView _blazorWebView;+ private readonly BlazorWebView _blazorGtkWebView;private readonly Gtk.Window _window;internal MainWindow(IServiceProvider serviceProvider, Adw.Application application)@@ -33,22 +34,26 @@ internal class MainWindowGuard.IsNotNull(_titleBarInfoProvider);_titleBarInfoProvider.PropertyChanged += TitleBarInfoProvider_PropertyChanged;- _blazorWebView = new BlazorWebView(serviceProvider);+ _blazorGtkWebView = new BlazorWebView(serviceProvider);+ _blazorGtkWebView.OnContextMenu += BlazorGtkWebViewOnOnContextMenu;++ // Make web view transparent+ _blazorGtkWebView.SetBackgroundColor(new Gdk.RGBA(Gdk.Internal.RGBAManagedHandle.Create(new Gdk.Internal.RGBAData { Red = 0, Blue = 0, Green = 0, Alpha = 0 })));// Allow opening developer tools- WebKit.Settings webViewSettings = _blazorWebView.GetSettings();+ Settings webViewSettings = _blazorGtkWebView.GetSettings();#if DEBUGwebViewSettings.EnableDeveloperExtras = true;#endifwebViewSettings.JavascriptCanAccessClipboard = true;webViewSettings.EnableBackForwardNavigationGestures = false;- _blazorWebView.SetSettings(webViewSettings);+ _blazorGtkWebView.SetSettings(webViewSettings);// Create and open main window._window = Gtk.ApplicationWindow.New(application);_window.Title = _titleBarInfoProvider.Title ?? string.Empty;_window.SetDefaultSize(1280, 800);- _window.SetChild(_blazorWebView);+ _window.SetChild(_blazorGtkWebView);var windowService = (WindowService)serviceProvider.GetService<IWindowService>()!;((ThemeListener)_themeListener).SetMainWindow(_window, windowService);@@ -59,6 +64,16 @@ internal class MainWindow_window.Show();}+ private bool BlazorGtkWebViewOnOnContextMenu(WebView sender, WebView.ContextMenuSignalArgs args)+ {+ // Returning true to prevent the context menu from opening.+#if DEBUG+ return false;+#else+ return true;+#endif+ }+private void TitleBarInfoProvider_PropertyChanged(object? sender, PropertyChangedEventArgs e){if (e.PropertyName == nameof(TitleBarInfoProvider.Title))diff --git a/src/app/dev/platforms/desktop/DevToys.Linux/Strings/Other/Other.Designer.cs b/src/app/dev/platforms/desktop/DevToys.Linux/Strings/Other/Other.Designer.csindex 78b83ac89..8ede5bcd9 100644--- a/src/app/dev/platforms/desktop/DevToys.Linux/Strings/Other/Other.Designer.cs+++ b/src/app/dev/platforms/desktop/DevToys.Linux/Strings/Other/Other.Designer.cs@@ -1,7 +1,6 @@//------------------------------------------------------------------------------// <auto-generated>// This code was generated by a tool.-// Runtime Version:4.0.30319.42000//// Changes to this file may cause incorrect behavior and will be lost if// the code is regenerated.@@ -12,46 +11,32 @@ namespace DevToys.Linux.Strings.Other {using System;- /// <summary>- /// A strongly-typed resource class, for looking up localized strings, etc.- /// </summary>- // This class was auto-generated by the StronglyTypedResourceBuilder- // class via a tool like ResGen or Visual Studio.- // To add or remove a member, edit your .ResX file then rerun ResGen- // with the /str option, or rebuild your VS project.- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]+ [System.Diagnostics.DebuggerNonUserCodeAttribute()]+ [System.Runtime.CompilerServices.CompilerGeneratedAttribute()]internal class Other {- private static global::System.Resources.ResourceManager resourceMan;+ private static System.Resources.ResourceManager resourceMan;- private static global::System.Globalization.CultureInfo resourceCulture;+ private static System.Globalization.CultureInfo resourceCulture;- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]internal Other() {}- /// <summary>- /// Returns the cached ResourceManager instance used by this class.- /// </summary>- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]- internal static global::System.Resources.ResourceManager ResourceManager {+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]+ internal static System.Resources.ResourceManager ResourceManager {get {- if (object.ReferenceEquals(resourceMan, null)) {- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DevToys.Linux.Strings.Other.Other", typeof(Other).Assembly);+ if (object.Equals(null, resourceMan)) {+ System.Resources.ResourceManager temp = new System.Resources.ResourceManager("DevToys.Linux.Strings.Other.Other", typeof(Other).Assembly);resourceMan = temp;}return resourceMan;}}- /// <summary>- /// Overrides the current thread's CurrentUICulture property for all- /// resource lookups using this strongly typed resource class.- /// </summary>- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]- internal static global::System.Globalization.CultureInfo Culture {+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]+ internal static System.Globalization.CultureInfo Culture {get {return resourceCulture;}@@ -60,75 +45,57 @@ namespace DevToys.Linux.Strings.Other {}}- /// <summary>- /// Looks up a localized string similar to All {0}.- /// </summary>internal static string AllFiles {get {return ResourceManager.GetString("AllFiles", resourceCulture);}}- /// <summary>- /// Looks up a localized string similar to All files.- /// </summary>- internal static string AllFiles2 {+ internal static string OpenFile {get {- return ResourceManager.GetString("AllFiles2", resourceCulture);+ return ResourceManager.GetString("OpenFile", resourceCulture);+ }+ }++ internal static string Open {+ get {+ return ResourceManager.GetString("Open", resourceCulture);}}- /// <summary>- /// Looks up a localized string similar to Cancel.- /// </summary>internal static string Cancel {get {return ResourceManager.GetString("Cancel", resourceCulture);}}- /// <summary>- /// Looks up a localized string similar to Open.- /// </summary>- internal static string Open {+ internal static string OpenFiles {get {- return ResourceManager.GetString("Open", resourceCulture);+ return ResourceManager.GetString("OpenFiles", resourceCulture);}}- /// <summary>- /// Looks up a localized string similar to Open file.- /// </summary>- internal static string OpenFile {+ internal static string AllFiles2 {get {- return ResourceManager.GetString("OpenFile", resourceCulture);+ return ResourceManager.GetString("AllFiles2", resourceCulture);}}- /// <summary>- /// Looks up a localized string similar to Open files.- /// </summary>- internal static string OpenFiles {+ internal static string SaveFile {get {- return ResourceManager.GetString("OpenFiles", resourceCulture);+ return ResourceManager.GetString("SaveFile", resourceCulture);}}- /// <summary>- /// Looks up a localized string similar to Save.- /// </summary>internal static string Save {get {return ResourceManager.GetString("Save", resourceCulture);}}- /// <summary>- /// Looks up a localized string similar to Save file.- /// </summary>- internal static string SaveFile {+ internal static string OpenFolder {get {- return ResourceManager.GetString("SaveFile", resourceCulture);+ return ResourceManager.GetString("OpenFolder", resourceCulture);}}}diff --git a/src/app/dev/platforms/desktop/DevToys.Linux/Strings/Other/Other.resx b/src/app/dev/platforms/desktop/DevToys.Linux/Strings/Other/Other.resxindex e8ded02c2..bdf8493ba 100644--- a/src/app/dev/platforms/desktop/DevToys.Linux/Strings/Other/Other.resx+++ b/src/app/dev/platforms/desktop/DevToys.Linux/Strings/Other/Other.resx@@ -149,4 +149,7 @@<value>Save</value><comment/></data>+ <data name="OpenFolder" xml:space="preserve">+ <value>Open folder</value>+ </data></root>\ No newline at end of filediff --git a/src/app/dev/platforms/desktop/DevToys.MacOS/Controls/BlazorWebView/BlazorWKWebView.cs b/src/app/dev/platforms/desktop/DevToys.MacOS/Controls/BlazorWebView/BlazorWKWebView.csindex f17f555df..af913bdd8 100644--- a/src/app/dev/platforms/desktop/DevToys.MacOS/Controls/BlazorWebView/BlazorWKWebView.cs+++ b/src/app/dev/platforms/desktop/DevToys.MacOS/Controls/BlazorWebView/BlazorWKWebView.cs@@ -9,49 +9,48 @@ namespace DevToys.MacOS.Controls.BlazorWebView;internal sealed partial class BlazorWkWebView : IDisposable{+ private const string DevToysInteropName = "devtoyswebinterop";+ private const string Scheme = "app";internal const string AppHostAddress = "0.0.0.0";- internal static readonly Uri AppOriginUri = new(AppOrigin);- private const string AppOrigin = $"app://{AppHostAddress}/";+ internal static readonly Uri AppOriginUri = new($"{Scheme}://{AppHostAddress}/");private const string BlazorInitScript- = """-- window.__receiveMessageCallbacks = [];- window.__dispatchMessageCallback = function(message) {- window.__receiveMessageCallbacks.forEach(function(callback) { callback(message); });- };- window.external = {- sendMessage: function(message) {- window.webkit.messageHandlers.webwindowinterop.postMessage(message);- },- receiveMessage: function(callback) {- window.__receiveMessageCallbacks.push(callback);- }- };-- Blazor.start();-- (function () {- window.onpageshow = function(event) {- if (event.persisted) {- window.location.reload();- }- };- })();-- """;+ = $$"""+ window.__receiveMessageCallbacks = [];+ window.__dispatchMessageCallback = function(message) {+ window.__receiveMessageCallbacks.forEach(function(callback) { callback(message); });+ };+ window.external = {+ sendMessage: function(message) {+ window.webkit.messageHandlers.{{DevToysInteropName}}.postMessage(message);+ },+ receiveMessage: function(callback) {+ window.__receiveMessageCallbacks.push(callback);+ }+ };++ Blazor.start();++ (function () {+ window.onpageshow = function(event) {+ if (event.persisted) {+ window.location.reload();+ }+ };+ })();+ """;private readonly ILogger _logger;- private readonly IServiceProvider? _serviceProvider;+ private readonly IServiceProvider _serviceProvider;private BlazorWebViewManager? _webViewManager;private string? _hostPage;- internal BlazorWkWebView(IServiceProvider serviceProviderProvider, bool enableDeveloperTools)+ internal BlazorWkWebView(IServiceProvider serviceProvider, bool enableDeveloperTools){_logger = this.Log();- Guard.IsNotNull(serviceProviderProvider);- _serviceProvider = serviceProviderProvider;+ Guard.IsNotNull(serviceProvider);+ _serviceProvider = serviceProvider;View = CreateWebView(enableDeveloperTools);RootComponents.CollectionChanged += RootComponentsOnCollectionChanged;@@ -148,7 +147,7 @@ internal sealed partial class BlazorWkWebView : IDisposableprivate WKWebView CreateWebView(bool enableDeveloperTools){- WKWebViewConfiguration configuration = CreatConfiguration(enableDeveloperTools, MessageReceived);+ WKWebViewConfiguration configuration = CreateConfiguration(enableDeveloperTools, MessageReceived);var webView = new WKWebView(CGRect.Empty, configuration){@@ -171,7 +170,7 @@ internal sealed partial class BlazorWkWebView : IDisposablereturn webView;}- private WKWebViewConfiguration CreatConfiguration(bool enableDeveloperTools, Action<Uri, string> messageReceivedDelegate)+ private WKWebViewConfiguration CreateConfiguration(bool enableDeveloperTools, Action<Uri, string> messageReceivedDelegate){var config = new WKWebViewConfiguration();@@ -191,17 +190,17 @@ internal sealed partial class BlazorWkWebView : IDisposable// Handle messages.config.UserContentController.AddScriptMessageHandler(new WebViewScriptMessageHandler(messageReceivedDelegate),- "webwindowinterop");+ DevToysInteropName);// Add Blazor initialization script.config.UserContentController.AddUserScript(new WKUserScript(new NSString(BlazorInitScript),WKUserScriptInjectionTime.AtDocumentEnd,- true));+ isForMainFrameOnly: true));- // iOS WKWebView doesn't allow handling 'http'/'https' schemes, so we use the fake 'app' scheme- config.SetUrlSchemeHandler(new SchemeHandler(this), urlScheme: "app");+ // Register a "app" url scheme to handle Blazor resources+ config.SetUrlSchemeHandler(new AppSchemeHandler(this), urlScheme: Scheme);// Legacy Developer Extras setting.config.Preferences.SetValueForKey(@@ -228,8 +227,9 @@ internal sealed partial class BlazorWkWebView : IDisposableIFileProvider fileProvider = CreateFileProvider(contentRootDir);_webViewManager = new BlazorWebViewManager(+ AppOriginUri,this,- _serviceProvider!,+ _serviceProvider,fileProvider,RootComponents.JSComponents,contentRootDir,@@ -284,11 +284,11 @@ internal sealed partial class BlazorWkWebView : IDisposable}}- private sealed class SchemeHandler : NSObject, IWKUrlSchemeHandler+ private sealed class AppSchemeHandler : NSObject, IWKUrlSchemeHandler{private readonly BlazorWkWebView _blazorWebView;- internal SchemeHandler(BlazorWkWebView blazorWebView)+ internal AppSchemeHandler(BlazorWkWebView blazorWebView){_blazorWebView = blazorWebView;}diff --git a/src/app/dev/platforms/desktop/DevToys.MacOS/Controls/BlazorWebView/BlazorWebViewManager.cs b/src/app/dev/platforms/desktop/DevToys.MacOS/Controls/BlazorWebView/BlazorWebViewManager.csindex 08901bdc3..28e5a87af 100644--- a/src/app/dev/platforms/desktop/DevToys.MacOS/Controls/BlazorWebView/BlazorWebViewManager.cs+++ b/src/app/dev/platforms/desktop/DevToys.MacOS/Controls/BlazorWebView/BlazorWebViewManager.cs@@ -29,6 +29,7 @@ public partial class BlazorWebViewManager : WebViewManager/// <param name="contentRootRelativeToAppRoot">Path to the directory containing application content files.</param>/// <param name="hostPageRelativePath">Path to the host page within the fileProvider.</param>internal BlazorWebViewManager(+ Uri baseUri,BlazorWkWebView blazorMauiWebViewHandler,IServiceProvider provider,IFileProvider fileProvider,@@ -38,7 +39,7 @@ public partial class BlazorWebViewManager : WebViewManager: base(provider,new AppKitDispatcher(),- BlazorWkWebView.AppOriginUri,+ baseUri,fileProvider,jsComponents,hostPageRelativePath)diff --git a/src/app/dev/shared/SharedAssemblyVersion.cs b/src/app/dev/shared/SharedAssemblyVersion.csindex d77ea9319..46a876838 100644--- a/src/app/dev/shared/SharedAssemblyVersion.cs+++ b/src/app/dev/shared/SharedAssemblyVersion.cs@@ -1,4 +1,4 @@-//------------------------------------------------------------------------------+//------------------------------------------------------------------------------// <auto-generated>// This code was generated by a tool.//diff --git a/src/build/Build.cs b/src/build/Build.csindex 3dbf967e4..e1bf80cac 100644--- a/src/build/Build.cs+++ b/src/build/Build.cs@@ -45,6 +45,9 @@ class Build : NukeBuild[Solution]readonly Solution? MacSolution;+ [Solution]+ readonly Solution? LinuxSolution;+Target PreliminaryCheck => _ => _.Before(Clean).Executes(() =>@@ -67,6 +70,12 @@ class Build : NukeBuildreturn;}+ if (PlatformTargets.Contains(PlatformTarget.Linux) && !OperatingSystem.IsLinux())+ {+ Assert.Fail("To build Linux app, you need to run on Linux.");+ return;+ }+Log.Information("Preliminary checks are successful.");});@@ -114,7 +123,7 @@ class Build : NukeBuild.SetConfiguration(Configuration).SetSelfContained(true).SetPublishTrimmed(false)- .SetVerbosity(DotNetVerbosity.Quiet)));+ .SetVerbosity(DotNetVerbosity.quiet)));});Target BuildPlugins => _ => _@@ -131,7 +140,7 @@ class Build : NukeBuild.SetConfiguration(Configuration).SetSelfContained(false).SetPublishTrimmed(false)- .SetVerbosity(DotNetVerbosity.Quiet));+ .SetVerbosity(DotNetVerbosity.quiet));});#pragma warning disable IDE0051 // Remove unused private members@@ -150,7 +159,7 @@ class Build : NukeBuildDotNetTest(s => s.SetProjectFile(f).SetConfiguration(Configuration)- .SetVerbosity(DotNetVerbosity.Quiet)));+ .SetVerbosity(DotNetVerbosity.quiet)));});#pragma warning restore IDE0051 // Remove unused private members@@ -167,7 +176,7 @@ class Build : NukeBuild.SetProject(project).SetConfiguration(Configuration).SetPublishTrimmed(false)- .SetVerbosity(DotNetVerbosity.Quiet)+ .SetVerbosity(DotNetVerbosity.quiet).SetProcessArgumentConfigurator(_ => _.Add($"/bl:\"{RootDirectory / "publish" / "Sdk"}.binlog\"")).SetOutputDirectory(RootDirectory / "publish" / "Sdk"));@@ -187,6 +196,11 @@ class Build : NukeBuildPublishMacApp();}+ if (PlatformTargets!.Contains(PlatformTarget.Linux))+ {+ PublishLinuxApp();+ }+if (PlatformTargets!.Contains(PlatformTarget.CLI)){PublishCliApp();@@ -209,7 +223,7 @@ class Build : NukeBuild.SetPublishSingleFile(false).SetPublishReadyToRun(false).SetPublishTrimmed(false)- .SetVerbosity(DotNetVerbosity.Quiet)+ .SetVerbosity(DotNetVerbosity.quiet).SetProcessArgumentConfigurator(_ => _.Add("/p:RuntimeIdentifierOverride=" + dotnetParameters.RuntimeIdentifier).Add("/p:Unpackaged=" + dotnetParameters.Portable)@@ -231,7 +245,7 @@ class Build : NukeBuild.SetPublishSingleFile(false) // Not supported by MacCatalyst as it would require UseAppHost to be true, which isn't supported on Mac.SetPublishReadyToRun(false).SetPublishTrimmed(true) // Should be true, even though the CSPROJ disable AOT and Trimming.- .SetVerbosity(DotNetVerbosity.Quiet)+ .SetVerbosity(DotNetVerbosity.quiet).SetNoRestore(true) /* workaround for https://github.com/xamarin/xamarin-macios/issues/15664#issuecomment-1233123515 */.SetProcessArgumentConfigurator(_ => _.Add("/p:RuntimeIdentifierOverride=" + dotnetParameters.RuntimeIdentifier)@@ -241,6 +255,31 @@ class Build : NukeBuild}}+ void PublishLinuxApp()+ {+ // DevToys Linux+ foreach (DotnetParameters dotnetParameters in GetDotnetParametersForLinuxApp())+ {+ Log.Information($"Publishing {dotnetParameters.ProjectOrSolutionPath + " - " + dotnetParameters.TargetFramework + " - " + dotnetParameters.RuntimeIdentifier + (dotnetParameters.Portable ? "-Portable" : string.Empty)} ...");+ DotNetPublish(s => s+ .SetProject(dotnetParameters.ProjectOrSolutionPath)+ .SetConfiguration(Configuration)+ .SetFramework(dotnetParameters.TargetFramework)+ .SetRuntime(dotnetParameters.RuntimeIdentifier)+ .SetPlatform(dotnetParameters.Platform)+ .SetSelfContained(dotnetParameters.Portable)+ .SetPublishSingleFile(false)+ .SetPublishReadyToRun(false)+ .SetPublishTrimmed(false)+ .SetVerbosity(DotNetVerbosity.quiet)+ .SetProcessArgumentConfigurator(_ => _+ .Add("/p:RuntimeIdentifierOverride=" + dotnetParameters.RuntimeIdentifier)+ .Add("/p:Unpackaged=" + dotnetParameters.Portable)+ .Add($"/bl:\"{RootDirectory / "publish" / dotnetParameters.OutputPath}.binlog\""))+ .SetOutput(RootDirectory / "publish" / dotnetParameters.OutputPath));+ }+ }+void PublishCliApp(){// DevToys CLI@@ -256,7 +295,7 @@ class Build : NukeBuild.SetPublishSingleFile(dotnetParameters.Portable).SetPublishReadyToRun(false).SetPublishTrimmed(false)- .SetVerbosity(DotNetVerbosity.Quiet)+ .SetVerbosity(DotNetVerbosity.quiet).SetProcessArgumentConfigurator(_ => _.Add($"/bl:\"{RootDirectory / "publish" / dotnetParameters.OutputPath}.binlog\"")).SetOutput(RootDirectory / "publish" / dotnetParameters.OutputPath));@@ -327,6 +366,29 @@ class Build : NukeBuild}}+ IEnumerable<DotnetParameters> GetDotnetParametersForLinuxApp()+ {+ string publishProject = "DevToys.Linux";+ Project project;++ if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))+ {+ project = LinuxSolution!.GetAllProjects(publishProject).Single();+ foreach (string targetFramework in project.GetTargetFrameworks())+ {+ yield return new DotnetParameters(project.Path, "linux-arm", targetFramework, portable: false, platform: "arm");+ yield return new DotnetParameters(project.Path, "linux-x64", targetFramework, portable: false, platform: "x64");++ yield return new DotnetParameters(project.Path, "linux-arm", targetFramework, portable: true, platform: "arm");+ yield return new DotnetParameters(project.Path, "linux-x64", targetFramework, portable: true, platform: "x64");+ }+ }+ else+ {+ throw new NotSupportedException();+ }+ }+IEnumerable<DotnetParameters> GetDotnetParametersForMacOSApp(){string publishProject = "DevToys.MacOS";diff --git a/src/build/Restore/RestoreTask.cs b/src/build/Restore/RestoreTask.csindex 6720637a7..f4a104838 100644--- a/src/build/Restore/RestoreTask.cs+++ b/src/build/Restore/RestoreTask.cs@@ -41,6 +41,16 @@ internal static class RestoreTaskprivate static async Task<int> Bash(string cmd){+ string bashProgram;+ if (OperatingSystem.IsMacOS())+ {+ bashProgram = "sh";+ }+ else+ {+ bashProgram = "bash";+ }+var source = new TaskCompletionSource<int>();string escapedArgs = cmd.Replace("\"", "\\\"");var process = new Process@@ -48,7 +58,7 @@ internal static class RestoreTaskStartInfo = new ProcessStartInfo{FileName = "/bin/bash",- Arguments = $"-c \"sh {escapedArgs}\"",+ Arguments = $"-c \"{bashProgram} {escapedArgs}\"",UseShellExecute = false,CreateNoWindow = true},