Can't publish a Maui app that references a class library on Windows without modifying the project
See original GitHub issueDescription
A Maui app that references a class library can’t be published without modifying the project file using the following command:
msbuild /restore /t:Publish /p:TargetFramework=net6.0-windows10.0.19041 /p:TargetFrameworks="net6.0-windows10.0.19041;net6.0" /p:configuration=release /p:GenerateAppxPackageOnBuild=true /p:AppxPackageSigningEnabled=true /p:PackageCertificateThumbprint="YOUR_CERT_THUMBPRINT_HERE" /p:PackageCertificatePassword="AnyTestPasswordYouLike"
Steps to reproduce
- Create a Maui application.
- Create a class library.
- Reference the class library from the Maui application.
- Open a developer command prompt.
- Navigate to the Maui app folder.
- Run the command above to publish the app.
Workaround
- Update the project file with the following changes
- <TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks> - <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks> + <TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
- Update the command to use the following:
msbuild /restore /t:Publish /p:configuration=Release /p:GenerateAppxPackageOnBuild=true /p:AppxPackageSigningEnabled=true /p:PackageCertificateThumbprint="<<YOURTHUMBPRINTHERE>>" /p:PackageCertificatePassword="AnyTestPasswordYouLike"
Issue Analytics
- State:
- Created a year ago
- Comments:32 (14 by maintainers)
Top Results From Across the Web
Issue with Razor Class Library in MAUI while publishing ...
While trying publish the MAUI app with Razor Class library for ios, we get below issue. Kindly help to resolve.
Read more >How to build .Net MAUI app referencing a standard .Net 6 ...
I have a standard C# class library that's used for a lot of different projects, and I'd like to use it as a...
Read more >Extracting styles to a .NET MAUI Class Library project does ...
Hi. I am trying to extract my styling for a Telerik TabView into a .NET MAUI Class Library project, which I include in...
Read more >Publishing Your .NET MAUI Apps | .NET Conf: Focus on MAUI
Join this session to learn how to publish your .NET MAUI ... NET MAUI Self-guided Learning on Microsoft Learn: https://aka.ms/ maui /mslearn -...
Read more >Add Authentication to .NET MAUI Apps with Auth0
Learn how to authenticate users of your .NET MAUI application using OpenID Connect and Auth0.
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
I’m curious but isn’t the whole point of .NET to self contain everything in the one sdk? Shouldn’t it all just work without any extra fiddling around and additional dependencies?
Faced this issue again in VS2022 17.6.5. Fix was to close VS, then delete the <project>.csproj.user file followed by the hidden “.vs” folder at solution path. Start VS, open project and rebuild. Issue resolved.