Fix Archive for publishing when .NET MAUI references to own .NET Core project

Bohdan Bats 20 Reputation points
2024-03-05T07:59:19.4533333+00:00

According to this article, I completed all steps except "Publish the app", because when I right click on .NET MAUI project and select "Archive for publishing" and get the error with text "Assets file '.../ClassLibraryDotnetCoreProject/obj/project.assets.json' doesn't have a target for 'net8.0-ios'. Ensure that restore has run and that you have included 'net8.0-ios' in the TargetFrameworks for your project". The problem is that Class Library, which is .NET Core 8.0 project, cannot have target for "net8.0-ios". How to fix this, but save this separated .NET Core project? I also can change its type to .NET Standard but I don't think that it can correct this problem

I use VS for Mac with the latest updates

Developer technologies | .NET | .NET MAUI
{count} votes

Accepted answer
  1. Anonymous
    2024-03-06T07:12:57.4066667+00:00

    Hello,

    Please create a .NET MAUI Class Library, you can open the class library 's csproj file. And you can find the <TargetFrameworks> like following code.

    <Project Sdk="Microsoft.NET.Sdk">
    
    
       <PropertyGroup>
            <TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
            <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
    

    You can try to create a .NET MAUI Class Library . Next, MAUI project add reference to the .NET MAUI Class Library. Release this MAUI project.

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.