question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Publish MAUI Project with project reference To Class library produces errors.

See original GitHub issue

Description

Publish MAUI Project with project reference To Class library produces errors.

Steps to Reproduce

  1. Create Maui Project.
  2. Add Class library A.
  3. Add Class library B.
  4. Add project reference from MAUI projects for two class librariles.
  5. Publish according to this documents: https://docs.microsoft.com/en-us/dotnet/maui/windows/deployment/overview
  6. I used this commands:
 New-SelfSignedCertificate -Type Custom -Subject "CN=Dani" -KeyUsage DigitalSignature -FriendlyName "My temp dev cert" -CertStoreLocation "Cert:\CurrentUser\My" -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.3", "2.5.29.19={text}")
 Get-ChildItem "Cert:\CurrentUser\My" | Format-Table Subject, FriendlyName, Thumbprint
 msbuild  /restore /t:Publish /p:TargetFramework=net6.0-windows10.0.19041 /p:configuration=release /p:GenerateAppxPackageOnBuild=true /p:AppxPackageSigningEnabled=true /p:PackageCertificateThumbprint="44CF7D6F1FD0B7CF538085CBEA22A1B0ACDBB541" 
  1. Get error in build phase, please see Relevant log output

Version with bug

Release Candidate 1

Last version that worked well

Release Candidate 1

Affected platforms

Windows

Affected platform versions

Did you find any workaround?

No

Relevant log output

"C:\Users\danis\Desktop\AutomationClient\AutomationClient.MAUI\AutomationClient.MAUI.csproj" (Restore target) (1) ->
(Restore target) ->
  C:\Users\danis\Desktop\AutomationClient\AutomationClient.MAUI\AutomationClient.MAUI.csproj : error NU1201: Project AutomationClient.Shared is not compatible with net6.0-android31.0 (.NETCoreApp,Version=v6.0). Project AutomationClient.Shared supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
  C:\Users\danis\Desktop\AutomationClient\AutomationClient.MAUI\AutomationClient.MAUI.csproj : error NU1201: Project AutomationClient.Shared is not compatible with net6.0-ios15.4 (.NETCoreApp,Version=v6.0). Project AutomationClient.Shared supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
  C:\Users\danis\Desktop\AutomationClient\AutomationClient.MAUI\AutomationClient.MAUI.csproj : error NU1201: Project AutomationClient.Shared is not compatible with net6.0-maccatalyst15.4 (.NETCoreApp,Version=v6.0). Project AutomationClient.Shared supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
  C:\Users\danis\Desktop\AutomationClient\AutomationClient.MAUI\AutomationClient.MAUI.csproj : error NU1201: Project AutomationClient.Shared is not compatible with net6.0-android31.0 (.NETCoreApp,Version=v6.0) / win10-x64. Project AutomationClient.Shared supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
  C:\Users\danis\Desktop\AutomationClient\AutomationClient.MAUI\AutomationClient.MAUI.csproj : error NU1201: Project AutomationClient.Shared is not compatible with net6.0-ios15.4 (.NETCoreApp,Version=v6.0) / win10-x64. Project AutomationClient.Shared supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
  C:\Users\danis\Desktop\AutomationClient\AutomationClient.MAUI\AutomationClient.MAUI.csproj : error NU1201: Project AutomationClient.Shared is not compatible with net6.0-maccatalyst15.4 (.NETCoreApp,Version=v6.0) / win10-x64. Project AutomationClient.Shared supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)

    0 Warning(s)
    6 Error(s)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:26 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
Dbquitycommented, May 5, 2022

@mattleibow Thanks for the explanation! Now I can ditch my hefty workaround of going via nuget packages for my 10ish .NET 6 class libraries 😃

1reaction
mattleibowcommented, May 5, 2022

OK, so some interesting news and this feels like either a bug or a limitation of msbuild.

If you switch to dotnet build you get an error about TFMs, but this is easily fixed by adding a .0 to the end of the windows TFM:

dotnet build MauiApp1 /p:TargetFramework=net6.0-windows10.0.19041

However, for msbuild, it appears the single command of msbuild /restore throws off the part with the TFM. If you do it in 2 steps then it works:

msbuild /t:restore MauiApp1
msbuild MauiApp1 /p:TargetFramework=net6.0-windows10.0.19041.0

I think the fact that you specify a TFM during the restore somehow throws of the restore process. This can be repro-ed with just the restore target:

msbuild /t:restore MauiApp1 /p:TargetFramework=net6.0-windows10.0.19041.0

There is another workaround for this and it is probably due to the fact that the CLI arguments OVERWRITE the properties in the csproj. The workaround is to just change the singular <TargetFramework> in the class library to the plural version <TargetFrameworks>.

As a result, the CLI argument of /p:TargetFramework=net6.0-windows10.0.19041.0 no longer OVERWRITES the property but instructs the build to SELECT the best matching TFM.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to add my custom .NET MAUI class library output dlls ...
I have created a .NET MAUI class library single project that when built it generates multiple dlls each one inside platform specific folder....
Read more >
.NET 6 Library referenced in MAUI project fails to compile ...
I have a MAUI project which references a .NET 6 Class Library (itself including an EF Core context with related NuGet packages and...
Read more >
Cannot debug net6.0-macos Apps - Developer Community
The error is the same for a new project. There are no errors in the list and I pasted in the output window...
Read more >
Is .NET MAUI worth it?
NET MAUI project and I think I've seen enough to help answer the question of whether .NET MAUI is ready for your next...
Read more >
Publish MAUI - Telerik App - Error in UI for .NET MAUI
Hi,I tried to publish the app and I got this error.Any specials requirement to publish this app for testing.03/04/2022 10:45:16 System.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found