Issue with Razor Class Library in MAUI while publishing the iOS app.

Ganesh 1 Reputation point
2022-07-12T13:21:51.74+00:00

While trying publish the MAUI app with Razor Class library for ios, we get below issue. Kindly help to resolve.

*C:\Program Files\dotnet\sdk\6.0.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(267,5)
: error NETSDK1005: Assets file 'C:\Users\Usr\Documents\MauiProj\MobilePoc\RazorClassLibrary\obj\pr
oject.assets.json' doesn't have a target for 'net6.0-ios'. Ensure that restore has run and that you have included 'net6
.0-ios' in the TargetFrameworks for your project. [C:\Users\Usr\Documents\MauiProj\MobilePoc\RazorC
lassLibrary\RazorClassLibrary.csproj]

C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\15.4.311\tools\msbuild\iOS\Xamarin.Shared.targets(1707,3): error : Coul
d not find Microsoft.iOS in /Users/newuser/Library/Caches/Xamarin/XMA/SDKs/dotnet/packs/Microsoft.iOS.Sdk/15.4.311/. [C
:\Users\Usr\Documents\MauiProj\MobilePoc\MobilePoc\PCLawHorizonPOC.csproj]
C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\15.4.311\tools\msbuild\iOS\Xamarin.Shared.targets(1707,3): error :
[C:\Users\Usr\Documents\MauiProj\MobilePoc\MobilePoc\PCLawHorizonPOC.csproj]*

We tried,

  • Restore the nuget packages
  • Clearing /Caches/Xamarin/XMA/ folder in both windows and mac machines
  • Updating Visual Studio
  • Adding dotnet workload

We have below content in .csproj files
In MyMobileProj.csproj

<PropertyGroup>  
    <TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>  
    <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>  
    <!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->  
    <!-- <TargetFrameworks>$(TargetFrameworks);net6.0-tizen</TargetFrameworks> -->  
    <OutputType>Exe</OutputType>  
    <RootNamespace>PCLawHorizonPOC</RootNamespace>  
    <UseMaui>true</UseMaui>  
    <SingleProject>true</SingleProject>  
    <ImplicitUsings>enable</ImplicitUsings>  
    <EnableDefaultCssItems>false</EnableDefaultCssItems>  
    <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>  
    <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>  
    <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">23.0</SupportedOSPlatformVersion>  
    <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>  
    <TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>  
    <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>  
    <AndroidSigningKeyStore>horizonkey.keystore</AndroidSigningKeyStore>  
    <CodesignKey>iPhone Distribution</CodesignKey>  
</PropertyGroup>  

<PropertyGroup Condition="$(TargetFramework.Contains('-ios'))">  
    <RuntimeIdentifier>ios-arm64</RuntimeIdentifier>  
</PropertyGroup>  

In RazorClassLibrary.csproj
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

In Global.json we have

{
"sdk": {
"version": "6.x"
}
}

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,404 questions
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,927 questions
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
36,258 questions
{count} votes