maui icon indicating copy to clipboard operation
maui copied to clipboard

Cannot reference MAUI-Blazor project from another MAUI-Blazor project on iOS

Open Dreamescaper opened this issue 3 years ago β€’ 12 comments
trafficstars

Description

I'd like to use shared library with MAUI-Blazor project. Unfortunately, currently it fails with the following error:

error NETSDK1005: Assets file '...\obj\project.assets.json' doesn't have a target for 'net6.0-ios'.

Note that it works perfectly fine with Android or Windows targets.

Repro: https://github.com/Dreamescaper/maui-3536-repro

Steps to Reproduce

  1. Open attached project.
  2. Try to build / run MauiApp1 on Remote Simulator.

Version with bug

Preview 10 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS 15

Did you find any workaround?

No.

Relevant log output

2>C:\Program Files\dotnet\sdk\6.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(267,5): error NETSDK1005: Assets file 'C:\Users\master\source\repos\MauiAppLib\Lib\obj\project.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.
2>Done building project "Lib.csproj" -- FAILED.
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Dreamescaper avatar Nov 23 '21 23:11 Dreamescaper

Hi @Dreamescaper , when you say shared lib, do you mean actual shared source (unlikely?), or do you mean this:

  1. Class lib that has Razor + MAUI stuff in it (SDK = Razor, UseMaui=true)
  2. MAUI app project that references that class lib

If so, we're tracking that in https://github.com/dotnet/maui/issues/3288.

Does it seem the same, or does this seem different?

Eilon avatar Nov 24 '21 00:11 Eilon

The description of the item seems to be correct, but actual results are different.

  • That bug mentions that component does not display anymore. In my case I cannot even build it, it fails.

  • It reproduces only on iOS.

Dreamescaper avatar Nov 24 '21 00:11 Dreamescaper

OK thanks let's keep this open.

BTW can you upload the repro project as a GitHub repo instead of a ZIP? We're not allowed to open ZIP attachments unfortunately.

Eilon avatar Nov 24 '21 00:11 Eilon

Actually, in my case (MobileBlazorBindings project) I don't even care about .razor files, there are none. But I need to get access to BlazorWebView type, therefore I need to set SDK to Razor to get it.

Anyway, if that's the same issue - feel free to close it.

Dreamescaper avatar Nov 24 '21 00:11 Dreamescaper

Well, we'll try to fix one and we'll see if it fixes the other πŸ˜„

Eilon avatar Nov 24 '21 00:11 Eilon

BTW can you upload the repro project as a GitHub repo instead of a ZIP? We're not allowed to open ZIP attachments unfortunately.

https://github.com/Dreamescaper/maui-3536-repro

Dreamescaper avatar Nov 24 '21 10:11 Dreamescaper

I don't think this is a scenario we plan to support.

Blazor wise, only RCLs are the way to share components and static web assets. If you have a Maui app we don't expect the content to be referenceable from another project in the same way that we don't support scenarios where a web project references another web project.

Only web/maui/wasm references to RCLs are expected to work.

@Eilon feel free to close this issue at your discretion.

javiercn avatar Jan 13 '22 19:01 javiercn

In my particular case I only need to access BlazorWebView type in my lib. If there's any way to get it without setting the SDK to Razor, that would solve my issue. ( Currently it fails due to missing targets if I attempt to add Microsoft.AspNetCore.Components.WebView.Maui package manually to non-Razor project)

Dreamescaper avatar Jan 13 '22 20:01 Dreamescaper

@javiercn I think this is a scenario we must support, but it might not be clear to everyone what it is.

Imagine a MAUI class lib with some MAUI control that internally uses a BlazorWebView and thus needs some Razor files and static assets. It would use the Razor SDK, plus have UseMaui=true.

This scenario is not about referencing a MAUI app as if it is a "regular" class lib.

Eilon avatar Jan 14 '22 06:01 Eilon

Verified repro with iPhone 13 pro max IOS 15.2 Simulator and the above project.

kristinx0211 avatar Feb 24 '22 07:02 kristinx0211

We've moved this issue to the Future milestone. This means that it is not going to be worked on for the coming release. We will reassess the issue following the current release and consider this item at that time.

ghost avatar Mar 21 '22 16:03 ghost

Verified this issue with Visual Studio Enterprise 17.6.0 Preview 2.0. Repro on iOS simulator(16.2) with sample project. https://github.com/Dreamescaper/maui-3536-repro image

Zhanglirong-Winnie avatar Apr 13 '23 09:04 Zhanglirong-Winnie