Telerik MAUI is not compatible with net6.0

2 Answers 79 Views
General Discussions
Allen
Top achievements
Rank 1
Iron
Iron
Allen asked on 06 Jul 2022, 06:39 AM

Hey Team,

I got a error when we added Telerik.UI.for.MAUI.Trial 1.0.1 reference into my MAUI class libraries, It said Project XXX is not compatible with net6.0 (.NETCoreApp,Version=v6.0). Project XXX supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)

For right now we created Unit Test for ClassLibrary and it is related Net 6.0. ClassLibrary needs other projects reference which include telerik, you can see my below screenshot.

Repro steps:

1. Create a MAUI class Library A and add Telerik.UI.for.MAUI.Trial 1.0.1 reference into library A.

2. Create a MAUI ClassLibrary B and add ClassLibraryA reference into B.

Is there a way to fix this issue?

 

Thanks

Allen

 

 

2 Answers, 1 is accepted

Sort by
0
Antoan
Telerik team
answered on 06 Jul 2022, 12:15 PM

Hello Allen,

Thank you for the provided screenshots.

I understand the confusion over the error. This happens because class libraries, unlike a normal .MAUI Project, target .NET 6.0. Telerik UI for .NET MAUI supports net.6.0-Android, net.6.0-iOS, net.6.0-MacCatalyst and net.6.0-Windows. 

If you do not plan to use the .net6.0 dependency you can open the cs.proj of the class library and in the TargetFrameworks tag remove net.6.0.

I hope this gives some clarity. Let me know if you need any further assistance.

Regards,
Antoan
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Allen
Top achievements
Rank 1
Iron
Iron
commented on 06 Jul 2022, 12:30 PM | edited

Hey Antoan,

Thank you for quick feedback. I see what you mentioned, Actually we have another situation, We need a xUnitTest project for ClassLibrary(ProjectB), That is why we keep Net6.0 there. And based on that ProjectB's pages can't add Telerik component.  

I'm still struggling on how to figure out a solution to resolve it? 

 

Thanks

Allen

 
Lance | Manager Technical Support
Telerik team
commented on 06 Jul 2022, 01:43 PM

Hi Allen,

The net6.0-platform TFM comes with .NET 6 support implicitly, you shouldn't need to add net6.0 on top of it.

If you have another dependency that requires net6.0 be declared, then you have two options to move forward:

  1. Contact the dependency's authors and request they add MAUI targets
  2. Restructuring the library design so that you have one class library for only net6.0 code and a second one for MAUI targets

I personally would recommend option #2 because you shouldn't mix UI platform code with platform-agnostic code.

Balaji
Top achievements
Rank 1
commented on 06 Jul 2022, 02:51 PM

Hi Antoan, 

2.Restructuring the library design so that you have one class library for only net6.0 code and a second one for MAUI targets

We understand #2 is an alternate way , but if we have View(with telerik component) and ViewModel(VM) in the Projects and we want to unit test the VM then we have to separate VM to its own .net6 project ,  we don't want to separate VM from View in to 2  different projects.

Is there anyway we keep the View and VM in one project and still able to unit test VM?

1.Contact the dependency's authors and request they add MAUI targets

Sorry I did not get this, Are you saying we have to contact dependency's author for  Telerik.UI.for.MAUI.Trial 1.0.1 ?

 

Thanks,

Balaji

Lance | Manager Technical Support
Telerik team
commented on 06 Jul 2022, 03:38 PM

It sounds like the testing framework you're using is balking at the fact that the class library project doesn't have a separate net6.0 TFM.  This is what I meant about contacting that dependency author and asking them to add net6.0-android, net6.0-windows, net6.0-maccatalyst and/or net6.0-ios.

The bottom line is you cannot use UI code (Telerik UI for MAUI) in a non-UI, net6.0 only, class library. Telerik U for MAUI is dependent on the target platform, so any project it is referenced in must define MAUI TFM when that is compiled. It is not a platform-agnostic component library that can be compiled in a platform-agnostic net6.0 only library.

Balaji
Top achievements
Rank 1
commented on 07 Jul 2022, 01:50 AM

We agree Telerik UI is not a platform-agnostic component library that can be compiled in a platform-agnostic net6.0.

But we have created UI libraries with MAUI UI controls which allows us to compile in net6.0 and it is consumed by application exe assembly which targets to specific platforms like net6.0-windows and net6.0-maccatalyst. We are not consuming this class libraries in .net6.0 application which can be issue.

Also if you create sample class library through MS MAUI project wizard they do add .net6.0 as target framework. 

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

If this not possible in telerik libraries then we will have to change our test project to have different targets.

Lance | Manager Technical Support
Telerik team
commented on 07 Jul 2022, 01:13 PM

Hi Allen,

The problem is that class library project is trying to compile a dependency that only supports .NET MAUI into an assembly that only targets the lowest common denominator net6.0. This is not possible because net6.0 does not have any support for .NET MAUI  (remember, .NET MAUI is net6.0-ios/net6.0-android/etc)

I do understand what you're trying to do, the bottom line is we do not surface any assemblies that are compatible for only the net6.0 target because our code is only for .NET MAUI platforms. To simply say it; Telerik UI for MAUI is for .NET MAUI, not .NET 6.0

You could add some custom #if preprocessor statements inside your class library that will exclude the Telerik code when the target is only net6.0

For example:

#if WINDOWS10_0_17763_0_OR_GREATER
#elif MACCATALYST
#elif IOS
#elif ANDROID

// .NET MAUI compatible code can go in here (e.g., Telerik UI for MAUI)

#elif

// Your net6.0 only compatible code goes here

#endif

Note: If your class library doesn't have .NET MAUI preprocessor statements, you will need to manually add them. I do not have any tutorials that show you how to do it, but you could ask Microsoft: here: dotnet-maui - Microsoft Q&A (or here dotnet-csharp - Microsoft Q&A).

Allen
Top achievements
Rank 1
Iron
Iron
commented on 19 Jul 2022, 07:34 AM

Hey Lance, 

I did follow your suggestion to manually add TFS into *Test. csproj,

it can build successfully, but can't run test case, and it also show me below error when I did a run. 

 

 

 

Thanks

Allen

Lance | Manager Technical Support
Telerik team
commented on 19 Jul 2022, 12:59 PM

Hello Allen,

Can you share a small demo with me that I can use to experiment with? Something like what you have in your first screenshot. I will use that to experiment with, I'll also use it to talk to our QA engineers and see what they might offer for suggestions.

Allen
Top achievements
Rank 1
Iron
Iron
commented on 20 Jul 2022, 06:05 AM

Sure, I attached previously projects , you can check on it.  
Lance | Manager Technical Support
Telerik team
commented on 20 Jul 2022, 01:24 PM

Hi Allen, thank you for the effort in preparing the project.

I also wanted to share news that I've spoken with product owners and they are currently working on adding net6.0 TFM to our compiled assemblies so that it can be used in this scenario. I can't promise anything right now, but barring any serious blockers, you should be able to use your original combined setup in a future release.

For now, I'll see what I can do with the attached setup.

Lance | Manager Technical Support
Telerik team
commented on 21 Jul 2022, 06:42 PM

Hello Allen, unfortunately I was not able to figure out a way to get this to work. Therefore, I have created a Feature Request on your behalf => Add net6.0 TFM to support tests (telerik.com)

This will allow you to track the progress of the item and be notified when it is available. Please go there and click the ":Follow" button, I have already added an upvote for you.

Allen
Top achievements
Rank 1
Iron
Iron
commented on 22 Jul 2022, 12:22 AM

I see, Thank you for update. 
0
Lance | Manager Technical Support
Telerik team
answered on 05 Aug 2022, 09:17 PM

Hi Allen,

I know you've already seen this in the official Feature Request item, but I also wanted to reply here so that the information is more easily available to anyone searching the forums.

This is now supported as of Telerik UI for MAUI .2.3.0. See the release notes here => Telerik UI for MAUI - Telerik UI for .NET MAUI (version 2.3.0).

Thank you for your patience and understanding!

Regards,
Lance | Manager Technical Support
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
General Discussions
Asked by
Allen
Top achievements
Rank 1
Iron
Iron
Answers by
Antoan
Telerik team
Lance | Manager Technical Support
Telerik team
Share this question
or