Windows 11 MAUI publish command for .net8

Harsh Agarwal

New Member
Joined
Jul 25, 2024
Messages
4
I am using the following command to publish a MAUI application.
dotnet publish -f net7.0-windows10.0.19041.0 -p:RuntimeIdentifierOverride=win10-x64 -p:WindowsPackageType=None -p:WindowsAppSDKSelfContained=true -p:Version=${appVersion} --configuration ${environmentMap[env]}

This is working fine for dotnet 7 but nor for dotnet 8. When i build with dotnet v8 then build is successfull but on the system where dotnet is not already installed. It is showing it needs dotnet that means the self contained behavipur is not working fine.

Do we have any solution for this ?
 


Solution
It seems like you're facing an issue with publishing your MAUI application using .NET 8, where the self-contained option isn't behaving as expected. Your command for .NET 7 works fine, but with .NET 8, you're getting an error about needing to install .NET on the target system, which indicates that the application is not truly self-contained.

Here are a few pointers to troubleshoot this issue:

1. Verify SDK Configuration: Ensure you have the latest version of .NET 8 installed. Sometimes, switching SDK versions can lead to unexpected behavior if there are missing components or updates.

2. Self-Contained Deployment: For .NET 8, the way configurations are set might have changed. Ensure your RuntimeIdentifier and...
It seems like you're facing an issue with publishing your MAUI application using .NET 8, where the self-contained option isn't behaving as expected. Your command for .NET 7 works fine, but with .NET 8, you're getting an error about needing to install .NET on the target system, which indicates that the application is not truly self-contained.

Here are a few pointers to troubleshoot this issue:

1. Verify SDK Configuration: Ensure you have the latest version of .NET 8 installed. Sometimes, switching SDK versions can lead to unexpected behavior if there are missing components or updates.

2. Self-Contained Deployment: For .NET 8, the way configurations are set might have changed. Ensure your RuntimeIdentifier and WindowsAppSDKSelfContained properties are correctly configured. According to the .NET documentation, you should also confirm that the targeted runtime identifier aligns with the .NET version you're using.

Your command can be modified as follows:
Code:
bash
    dotnet publish -f net8.0-windows10.0.19041.0 -p:RuntimeIdentifier=win10-x64 -p:WindowsAppSDKSelfContained=true -p:Version=${appVersion} --configuration ${environmentMap[env]}

3. Package Type: Since you have -p:WindowsPackageType=None, make sure that's still appropriate for your use case with .NET 8. This property determines how the app is packaged and could affect dependencies.

4. Check Dependencies: Sometimes, external dependencies might require the presence of the .NET runtime. Check if all libraries or components you're using are compatible with a self-contained deployment in .NET 8.

5. Inspect Output Directory: After publishing, inspect the output directory for the presence of all necessary files, especially the dotnet.exe executable, which should be included in a self-contained deployment.

6. Testing: If possible, test running the application on a fresh machine or a virtual machine where no .NET SDKs are installed. This will give you a clearer indication of whether the self-contained feature is functioning as intended.

If none of the above solutions work, you might want to look for updates or fixes in the official .NET MAUI and .NET 8 documentation or consider raising a question or issue on platforms like GitHub, where the community or developers can provide additional insights based on recent changes.
 


Solution
Back
Top