Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug MAUI Blazor] "Microsoft.AspNetCore.App" not found for "maccatalyst-x64" #1619

Closed
dicong-Apption opened this issue Jul 9, 2021 · 7 comments
Labels
area-blazor Blazor Hybrid / Desktop, BlazorWebView

Comments

@dicong-Apption
Copy link

Description

We are managing to transfer our existing Blazor server application into MAUI Blazor project. So far, we got the WinUI project building and working, which is really excited! But, for the main MAUI project, we had a runtime pack error for both mac and ios.

>C:\Program Files\dotnet\sdk\6.0.100-preview.5.21302.13\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(391,5): error NETSDK1082: There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'iossimulator-x64'.
6>C:\Program Files\dotnet\sdk\6.0.100-preview.5.21302.13\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(391,5): error NETSDK1082: There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'maccatalyst-x64'.

After some diggings, we think that the error appears after we add a nuget package like
Askmethat.Aspnet.JsonLocalizer (3.1.1) or Microsoft.AspNetCore.Mvc.NewtonsoftJson (6.0.0-preview.5.21301.17)
I am wondering what could be the reason here? and what can we do to avoid having this issue?

Steps to Reproduce

  1. Start from a clean .Net MAUI Blazor project
  2. Add a packageReference to <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.0-preview.5.21301.17" />
    or <PackageReference Include="Askmethat.Aspnet.JsonLocalizer" Version="3.1.1" />
  3. Rebuild the main Maui project

Actual Behavior

image

Basic Information

Microsoft Visual Studio Professional 2019 Preview
Version 16.11.0 Preview 2.0
dotnet --version
6.0.100-preview.5.21302.13
maui-check is clean

the main csproj file if you are curisou,

<Project Sdk="Microsoft.NET.Sdk.Razor">

	<PropertyGroup>
		<!-- iOS, Android, MacCatalyst -->
		<TargetFrameworks>net6.0-ios;net6.0-android;net6.0-maccatalyst</TargetFrameworks>
		<OutputType>Exe</OutputType>
		<SingleProject>true</SingleProject>
		<RootNamespace>MauiApp2</RootNamespace>

		<!-- Display name -->
		<ApplicationTitle>MauiApp2</ApplicationTitle>

		<!-- App Identifier -->
		<ApplicationId>com.companyname.MauiApp2</ApplicationId>

		<!-- Versions -->
		<ApplicationVersion>1.0</ApplicationVersion>
		<AndroidVersionCode>1</AndroidVersionCode>
	</PropertyGroup>

	<ItemGroup>
		<!-- App Icon -->
		<MauiImage Include="Resources\appicon.svg" ForegroundFile="Resources\appiconfg.svg" IsAppIcon="true" Color="#512BD4" />

		<!-- Splash Screen -->
		<MauiSplashScreen Include="Resources\appiconfg.svg" Color="#512BD4" />

		<!-- Images -->
		<MauiImage Include="Resources\Images\*" />

		<!-- Custom Fonts -->
		<MauiFont Include="Resources\Fonts\*" />
	</ItemGroup>

	<ItemGroup>
		<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="6.0.100-preview.5.794" />
		<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="6.0.0-preview.5.*" />
		<PackageReference Include="Microsoft.Maui" Version="6.0.100-preview.5.794" />
	
	  <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.0-preview.5.21301.17" />
	</ItemGroup>

	<PropertyGroup>
		<InvariantGlobalization Condition="$(TargetFramework.Contains('-maccatalyst'))">true</InvariantGlobalization>
		<RuntimeIdentifier Condition="$(TargetFramework.Contains('-ios'))">iossimulator-x64</RuntimeIdentifier>
		<RuntimeIdentifier Condition="$(TargetFramework.Contains('-maccatalyst'))">maccatalyst-x64</RuntimeIdentifier>
		<UseInterpreter Condition="$(TargetFramework.Contains('-android'))">True</UseInterpreter>
	</PropertyGroup>
	<ItemGroup Condition="$(TargetFramework.Contains('-android'))">
		<AndroidEnvironment Include="Android\AndroidEnvironment.txt" />
	</ItemGroup>
	<ItemGroup>
	</ItemGroup>

</Project>
@dicong-Apption dicong-Apption changed the title [Bug] Does .NET MAUI Blazor support all the .NetStandard and .NetCore nuget packages? [Bug MAUI Blazor] "Microsoft.AspNetCore.App" not found for "maccatalyst-x64" Jul 15, 2021
@Eilon
Copy link
Member

Eilon commented Jul 15, 2021

Hi @dicong-Apption , it looks like the Askmethat.Aspnet.JsonLocalizer package requires Blazor WebAssembly, which I don't think is supported on these platforms. I looked at the code for that project and I'm not sure it really needs Blazor WebAssembly to begin with, because at least in the default case it doesn't seem to use anything from Blazor WebAssembly. There are a few #if BLAZORASM cases in the code but I don't see that ever used. So I think that the project could reference Microsoft.AspNetCore.Components instead of Microsoft.AspNetCore.Components.WebAssembly and it would be fine.

Given that this seems to be an external issue, I am closing this issue.

@Eilon Eilon closed this as completed Jul 15, 2021
@Eilon Eilon added the area-blazor Blazor Hybrid / Desktop, BlazorWebView label Jul 15, 2021
@dicong-Apption
Copy link
Author

does this package Microsoft.AspNetCore.Mvc.NewtonsoftJson mean the same as well? I mean, is it supported in .NET MAUI?
For future debug, is there a way to check whether or not a package is supported in .NET MAUI?

@dicong-Apption
Copy link
Author

Just tested it with preview 6,
looks like Microsoft.AspNetCore.Mvc.NewtonsoftJson can be compiled now in a clean MAUI project

@Eilon
Copy link
Member

Eilon commented Jul 15, 2021

The package Microsoft.AspNetCore.Mvc.NewtonsoftJson I think should run everywhere.

I don't know of a good way to just look at a package and know where it will run. BTW it's not so much about .NET MAUI or not. It's more about the OS/architecture. So in your case the package should work fine if you use .NET MAUI but only on Windows.

@dicong-Apption
Copy link
Author

ahh, makes sense
really appreciate your time here! Thanks a lot!
I didn't notice that the JsonLocalizer used #if BLAZORASM, thanks for digging it for me!

@Eilon
Copy link
Member

Eilon commented Jul 16, 2021

@dicong-Apption no problem, this was an interesting issue to investigate. I recommend contacting the author of that package to see if they can change the reference to remove WebAssembly (and move the namespace using statements into #if BLAZORASM) so that it will compile without the dependency.

@Ghevi
Copy link

Ghevi commented Jan 19, 2022

Don't know if this can be helpfull to someone because it's probably a dumb mistake from my part, but the NuGet package Microsoft.AspNetCore.Authentication.OpenIdConnect will also cause these errors.

@ghost ghost locked as resolved and limited conversation to collaborators Feb 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Blazor Hybrid / Desktop, BlazorWebView
Projects
None yet
Development

No branches or pull requests

4 participants
@Eilon @Ghevi @dicong-Apption and others