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.

Can't publish a Maui app that references a class library on Windows without modifying the project

See original GitHub issue

Description

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

  1. Create a Maui application.
  2. Create a class library.
  3. Reference the class library from the Maui application.
  4. Open a developer command prompt.
  5. Navigate to the Maui app folder.
  6. 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:open
  • Created a year ago
  • Comments:32 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
heron1commented, Dec 11, 2022

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?

0reactions
hiten247commented, Jul 26, 2023

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.

Read more comments on GitHub >

github_iconTop 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 >

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