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

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"
    

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 37 (14 by maintainers)

Most upvoted comments

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?