maui icon indicating copy to clipboard operation
maui copied to clipboard

[Windows] Msix creation failed for an application with a custom library referred directly

Open AlanGusLive opened this issue 3 years ago • 8 comments

Description

When a program use a ".Net MAUI Class Library" the creation of the Msix package for Windows generate the following message : "Improper project configuration: WindowsPackageType is set to None, but PublishAppxPackage is set to true."

Related issues: https://github.com/dotnet/maui/issues/7268 https://github.com/dotnet/maui/issues/5881

Steps to Reproduce

Create a MAUI Application Build the solution in Release Mode With the main project in visual studio, right click with the mouse to call "Publish..." Select Sideloading and uncheck "Enable automatic updates" Create a new certificate and press "Next" button Create a Publishing profile (configuration=Release|Any CPU, Target Runtime=win10-x64, Self Contained= True, Package Location=bin\Release\net6.0-windows10.0.19041.0\win10-x64\AppPackages) Click on the "Create" button to generate the package. It Works.

Now in the solution add a ".Net MAUI Class Library" and refer to the application. Build the solution in Release Mode With the main project in visual studio, right click with the mouse to call "Publish..." Select Sideloading and uncheck "Enable automatic updates" Press the "Next" button (the certificate is already selected) Click on the "Create" button to generate the package. An ERROR occurs with the message "Improper project configuration: WindowsPackageType is set to None, but PublishAppxPackage is set to true."

PublishMsix.zip

Version with bug

6.0.486 (current)

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

Windows SDK 10.0.19041.0

Did you find any workaround?

None

Relevant log output

No response

VS bug #1786631

Depends on

  • [ ] https://github.com/microsoft/WindowsAppSDK/issues/3337

AlanGusLive avatar Aug 19 '22 13:08 AlanGusLive

@lutzroeder this UI is not yet ready to be used for .NET MAUI apps is it? Seems it works for one scenario, but it's still being worked on, right?

jfversluis avatar Aug 23 '22 13:08 jfversluis

@oliag @mariaghiondea @sbanni

lutzroeder avatar Aug 23 '22 14:08 lutzroeder

Duplicate of #9879

Unfortunately, there seems to be a bug in the Windows App SDK: https://github.com/dotnet/maui/issues/9879#issuecomment-1238628696

mattleibow avatar Sep 06 '22 22:09 mattleibow

Actually, this looks like a parallel issue. The error is from the other issue, but the cause may be a bit different. It appears that some of the properties meant for the app is reaching the class library - most notably penerateAppxPackageOnBuild as that tells the build system to generate a MSIX, but that is impossible for the class library.

mattleibow avatar Sep 06 '22 22:09 mattleibow

@mattleibow I tested your workaround and it works. I can now create a MSIX to install the package in Windows with an application which contains a custom library referred directly. Thanks for the workaround.

For information, I noticed that when you add a new ".NET MAUI Class Library" in a project, the Deploy of the library is automaticaly checked in Debug & Release Mode and need to be unchecked.

image

AlanGusLive avatar Sep 08 '22 08:09 AlanGusLive

Looking into this a bit more and I see the <PublishAppxPackage>true</PublishAppxPackage> property in the publish profile is giving the specific error for:

Improper project configuration: WindowsPackageType is set to None, but PublishAppxPackage is set to true.

This seems to be because all those properties in that file get applied to all project in the publish. I am not sure I agree with that, but that is a separate issue.

Once I removed this property, we fall back into the issue we always had:

https://github.com/microsoft/WindowsAppSDK/issues/3337

mattleibow avatar Jul 12 '23 19:07 mattleibow

Verified this issue with Visual Studio Enterprise 17.8.0 Preview 1.0(.NET8). Can repro this issue with sample project. PublishMsix.zip image

homeyf avatar Aug 15 '23 09:08 homeyf

This is still an issue in net8.0.3. Any chances this is fixed soon? I added a simple repro here. https://github.com/dotnet/maui/issues/8304#issuecomment-1838262839

AndreasReitberger avatar Dec 04 '23 11:12 AndreasReitberger

This is still an issue in net8.0.3. Any chances this is fixed soon? I added a simple repro here. #8304 (comment)

Just a note that, I tried removing the reference in the csproj file. "It works" in the sense that the solution compiles, but actually it does not work, because then all the references and using statements (from the razor class library project) do not work in the main/startup project anymore.

anlocnghg avatar Jun 20 '24 01:06 anlocnghg