Publish MAUI Project with project reference To Class library produces errors.
See original GitHub issueDescription
Publish MAUI Project with project reference To Class library produces errors.
Steps to Reproduce
- Create Maui Project.
- Add Class library A.
- Add Class library B.
- Add project reference from MAUI projects for two class librariles.
- Publish according to this documents: https://docs.microsoft.com/en-us/dotnet/maui/windows/deployment/overview
- 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"
- 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:
- Created a year ago
- Comments:26 (11 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@mattleibow Thanks for the explanation! Now I can ditch my hefty workaround of going via nuget packages for my 10ish .NET 6 class libraries 😃
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:
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: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:
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.