Skip to content

A Swiss Army knife for developers.

Fixed MAUI Blazor app publish on MacOS

Etienne Baudoux1d352c03df36
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index d406f2b06..22336aeb6 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -74,6 +74,14 @@ You can contribute to DevToys app by:
2. Install the `C#` extension.
1. In `Run and Debug`, select `Debug (macOS dektop app)` and press Start.
+#### Special note for `DevToys.MauiBlazor`
+In order to access the Safari developer tools with macOS to debug the HTML/CSS/JS of the Maui Blazor app, follow the following instructions:
+1. Open desktop Safari.
+2. Select the Safari > Preferences > Advanced > Show Develop menu in the menu bar checkbox.
+3. Run the `DevToys.MauiBlazor` app in macOS.
+4. Return to Safari. Select Develop > {REMOTE INSPECTION TARGET} > 0.0.0.0, where the {REMOTE INSPECTION TARGET} placeholder is either the devices's plain name (for example, MacBook Pro) or the device's serial number (for example XMVM7VFF10). If multiple entries for 0.0.0.0 are present, select the entry that highlights the BlazorWebView. The BlazorWebView is highlighted in blue in macOS when the correct 0.0.0.0 entry is selected.
+5. The Web Inspector window appears for the BlazorWebView.
+
# Internationalization and localization
There are two possibilities offered:
diff --git a/init.ps1 b/init.ps1
index 5969e0126..105398719 100644
--- a/init.ps1
+++ b/init.ps1
@@ -42,17 +42,17 @@ Write-Host "Restoring all dependencies"
Get-ChildItem $PSScriptRoot\src\ -rec |? { $_.FullName.EndsWith('DevToys-Windows.sln') } |% {
$SolutionPath = $_.FullName;
Write-Host "Restoring packages for $($SolutionPath)..."
- ExecSafe { & $env:DOTNET_EXE restore -v:quiet $SolutionPath }
+ ExecSafe { & $env:DOTNET_EXE restore -p:PublishReadyToRun=true -v:quiet $SolutionPath }
# If we run on Windows
if ([System.Boolean](Get-CimInstance -ClassName Win32_OperatingSystem -ErrorAction SilentlyContinue)) {
$MSBuildPath = Get-MsBuildPath true
- ExecSafe { & "$MSBuildPath" $SolutionPath /t:restore /p:Configuration=Release /p:platform=x86 /v:Quiet }
- ExecSafe { & "$MSBuildPath" $SolutionPath /t:restore /p:Configuration=Release /p:platform=x64 /v:Quiet }
- ExecSafe { & "$MSBuildPath" $SolutionPath /t:restore /p:Configuration=Release /p:platform=arm64 /v:Quiet }
- ExecSafe { & "$MSBuildPath" $SolutionPath /t:restore /p:Configuration=Debug /p:platform=x86 /v:Quiet }
- ExecSafe { & "$MSBuildPath" $SolutionPath /t:restore /p:Configuration=Debug /p:platform=x64 /v:Quiet }
- ExecSafe { & "$MSBuildPath" $SolutionPath /t:restore /p:Configuration=Debug /p:platform=arm64 /v:Quiet }
+ ExecSafe { & "$MSBuildPath" $SolutionPath /t:restore /p:PublishReadyToRun=true /p:Configuration=Release /p:platform=x86 /v:Quiet }
+ ExecSafe { & "$MSBuildPath" $SolutionPath /t:restore /p:PublishReadyToRun=true /p:Configuration=Release /p:platform=x64 /v:Quiet }
+ ExecSafe { & "$MSBuildPath" $SolutionPath /t:restore /p:PublishReadyToRun=true /p:Configuration=Release /p:platform=arm64 /v:Quiet }
+ ExecSafe { & "$MSBuildPath" $SolutionPath /t:restore /p:PublishReadyToRun=true /p:Configuration=Debug /p:platform=x86 /v:Quiet }
+ ExecSafe { & "$MSBuildPath" $SolutionPath /t:restore /p:PublishReadyToRun=true /p:Configuration=Debug /p:platform=x64 /v:Quiet }
+ ExecSafe { & "$MSBuildPath" $SolutionPath /t:restore /p:PublishReadyToRun=true /p:Configuration=Debug /p:platform=arm64 /v:Quiet }
}
}
diff --git a/init.sh b/init.sh
index a86b2688a..a1eef43ab 100644
--- a/init.sh
+++ b/init.sh
@@ -22,7 +22,7 @@ SOLUTIONS=$(find ./src/ -iname "*DevToys-MacOS.sln" -print)
for SOLUTION_FILE in $SOLUTIONS
do
echo "Restoring packages for $SOLUTION_FILE..."
- "$DOTNET_EXE" restore -v:quiet $SOLUTION_FILE
+ "$DOTNET_EXE" restore -p:PublishReadyToRun=true -v:quiet $SOLUTION_FILE
done
echo "Done."
diff --git a/src/DevToys-MacOS.sln b/src/DevToys-MacOS.sln
index 9f4efbb83..684451808 100644
--- a/src/DevToys-MacOS.sln
+++ b/src/DevToys-MacOS.sln
@@ -35,10 +35,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "desktops", "desktops", "{22EE9386-CEFA-47D8-97B2-09A63EDF7F2E}"
- ProjectSection(SolutionItems) = preProject
- app\dev\platforms\desktop\Directory.Build.props = app\dev\platforms\desktop\Directory.Build.props
- app\dev\platforms\desktop\Directory.Build.targets = app\dev\platforms\desktop\Directory.Build.targets
- EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "macos", "macos", "{8B003389-15D4-4466-A40E-50FC0D603BF6}"
EndProject
diff --git a/src/app/dev/platforms/desktop/DevToys.MauiBlazor/DevToys.MauiBlazor.csproj b/src/app/dev/platforms/desktop/DevToys.MauiBlazor/DevToys.MauiBlazor.csproj
index 3e3e5abdd..ddf51c63b 100644
--- a/src/app/dev/platforms/desktop/DevToys.MauiBlazor/DevToys.MauiBlazor.csproj
+++ b/src/app/dev/platforms/desktop/DevToys.MauiBlazor/DevToys.MauiBlazor.csproj
@@ -30,6 +30,9 @@
<PropertyGroup>
<DefineConstants>$(DefineConstants);__MACCATALYST__</DefineConstants>
<RuntimeIdentifiers>maccatalyst-arm64</RuntimeIdentifiers>
+ <UseInterpreter>true</UseInterpreter>
+ <!-- TODO: Only do this in DEBUG build. -->
+ <CodeSignEntitlements>Platforms/MacCatalyst/Entitlements.Debug.plist</CodeSignEntitlements>
</PropertyGroup>
<PropertyGroup Condition="'$(RuntimeIdentifier)'=='' AND '$(Configuration)'=='Release'">
<!-- Default values for command line builds -->
diff --git a/src/app/dev/platforms/desktop/DevToys.MauiBlazor/Platforms/MacCatalyst/Entitlements.Debug.plist b/src/app/dev/platforms/desktop/DevToys.MauiBlazor/Platforms/MacCatalyst/Entitlements.Debug.plist
new file mode 100644
index 000000000..d16b3f587
--- /dev/null
+++ b/src/app/dev/platforms/desktop/DevToys.MauiBlazor/Platforms/MacCatalyst/Entitlements.Debug.plist
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>com.apple.security.app-sandbox</key>
+ <false/>
+ <key>com.apple.security.get-task-allow</key>
+ <true/>
+</dict>
+</plist>
\ No newline at end of file
diff --git a/src/build/Build.cs b/src/build/Build.cs
index 28b453588..c82017e94 100644
--- a/src/build/Build.cs
+++ b/src/build/Build.cs
@@ -76,7 +76,7 @@ class Build : NukeBuild
{
if (!Debugger.IsAttached)
{
- RootDirectory.GlobDirectories("bin", "obj", "publish").ForEach(EnsureCleanDirectory);
+ RootDirectory.GlobDirectories("bin", "obj", "packages", "publish").ForEach(EnsureCleanDirectory);
}
});
@@ -222,7 +222,7 @@ class Build : NukeBuild
.SetProjectFile(dotnetParameters.ProjectOrSolutionPath)
.SetConfiguration(Configuration)
.SetPublishSingleFile(false) // Not supported by MacCatalyst as it would require UseAppHost to be true, which isn't supported on Mac
- .SetPublishReadyToRun(true)
+ .SetPublishReadyToRun(false)
.SetPublishTrimmed(true) /* Required True for MacCatalyst ? */
.SetVerbosity(DotNetVerbosity.Quiet)
.SetNoRestore(true) /* workaround for https://github.com/xamarin/xamarin-macios/issues/15664#issuecomment-1233123515 */