JaneySprings / DotNet.Meteor

A VSCode extension that can run and debug .NET apps (Xamarin, MAUI, Avalonia)
https://marketplace.visualstudio.com/items?itemName=nromanov.dotnet-meteor
MIT License
269 stars 10 forks source link

[net8.0-maccatalyst] HotReload - Permission denied #82

Closed newakb closed 7 months ago

newakb commented 7 months ago

[HotReload][Error]: Permission denied

That ^^ is what I see in my Debug Console in VSCode on my device. Here is what I did after installing the extension:

    <ItemGroup>
        <PackageReference Include="Microsoft.Maui.Controls" Version="8.0.7" />
        <PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.7" />
        <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
        <PackageReference Include="MySqlConnector" Version="2.3.5" />
        <!-- Added .NET Meteor HotReload -->
        <PackageReference Include="DotNetMeteor.HotReload.Plugin" Version="3.*" />
    </ItemGroup>

And my MauiProgram.cs:

using Microsoft.Extensions.Logging;
using DotNet.Meteor.HotReload.Plugin;

namespace project;

public static class MauiProgram
{
    public static MauiApp CreateMauiApp()
    {
        var builder = MauiApp.CreateBuilder();
        builder
            .UseMauiApp<App>()
            .ConfigureFonts(fonts =>
            {
                fonts.AddFont("Kanit-Regular.ttf", "KanitRegular");
                fonts.AddFont("Kanit-SemiBold.ttf", "KanitSemibold");
            });

#if DEBUG
        builder.Logging.AddDebug();
        builder.EnableHotReload();
#endif

        return builder.Build();
    }
}
JaneySprings commented 7 months ago

Hi, @AcAkb ! Thank you for your issue! What is your target platform? iPhone / Android / Macbook?

JaneySprings commented 7 months ago

Ok, I can reproduce it for Maccatalyst. Something broken on the new MAUI version. You can continue using it for iOS and Android

JaneySprings commented 7 months ago

As I understand it, something changed in the Entitlements.plist file. Just add this two lines to your Platforms/MacCatalyst/Entitlements.plist file:

<key>com.apple.security.network.server</key>
<true/>

For example, my Entitlements.plist file:

<?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">
    <!-- See https://aka.ms/maui-publish-app-store#add-entitlements for more information about adding entitlements.-->
    <dict>
        <!-- App Sandbox must be enabled to distribute a MacCatalyst app through the Mac App Store. -->
        <key>com.apple.security.app-sandbox</key>
        <true/>
        <!-- When App Sandbox is enabled, this value is required to open outgoing network connections. -->
        <key>com.apple.security.network.client</key>
        <true/>
        <key>com.apple.security.network.server</key>
        <true/>
    </dict>
</plist>

Don’t forget to clean bin / obj folders!!!

I think you should create a copy of this file and add the com.apple.security.network.server option only for debug configuration.

newakb commented 7 months ago

Thanks! Updating the Entitlements.plist fixed my issue.