microsoft / microsoft-ui-xaml

Windows UI Library: the latest Windows 10 native controls and Fluent styles for your applications
MIT License
6.34k stars 677 forks source link

[WinUI] Copy packages from output location to the installer location does not work after selecting "Copy and Close" button #7984

Open kanglinqian opened 1 year ago

kanglinqian commented 1 year ago

Describe the bug

Actual behavior: Installer location (e.g.: C:\Users\xxx\Desktop\Test) is empty. image

Steps to reproduce the bug

Environment: Affected Branch: main Affected Build: 33201.295

Steps to reproduce:

  1. Create a C# Blank App, Packaged (WinUI 3 in Desktop)
  2. Right click on project node -> Manage NuGet Packages -> Microsoft.WindowsAppSDK -> select the latest version
  3. Right click on project node -> Package and Publish -> Create App Packages
  4. Select Sideloading with "Enable automatic updates" checked
  5. Select "Yes, select a certificate" -> Create -> Next -> Next
  6. Create a new Publishing profile -> Next
  7. Type a valid location in Installer location (e.g.: C:\Users\xxx\Desktop\Test) -> Create
  8. After packaging successfully, click "Copy and Close"
  9. Check if the Installer location contains created packages

Expected behavior

Installer location (e.g.: C:\Users\xxx\Desktop\Test) should contain created packages.

Screenshots

No response

NuGet package version

None

Windows version

No response

Additional context

No response

Scottj1s commented 10 months ago

@kanglinqian Thanks for reporting this. The packaging and publishing feature is provided by Visual Studio. Please enter an issue here: https://developercommunity.visualstudio.com/VisualStudio/report?

MSLukeWest commented 7 months ago

@Scottj1s We looked into this issue from the Visual Studio side and determined that the problem is in the WinUI targets. Take a look at the "GenerateMsixPackage" target in Microsoft.Build.Msix.Packaging.targets, this does everything that's needed to write the file VS uses when clicking the "Copy and Close" button. The problem is that the condition on the target is never true:

Condition="'$(_GenerateMsixPackage)'=='true' "

I confirmed that if I perform the repro steps listed above with the small addition of setting the _GenerateMsixPackage property in my project file to true this scenario works, all the necessary app installer files are copied.

Please re-open this issue. cc @evelynwu-msft

evelynwu-msft commented 7 months ago

@MSLukeWest We set _GenerateMsixPackage to true only if either GenerateAppxPackageOnBuild or PublishAppxPackage are true (I think the original expectation was that the latter would be set by somebody?). What properties are set and target invoked by VS when it goes through this workflow?

MSLukeWest commented 7 months ago

@evelynwu-msft The equivalent condition in the VS Appx targets is just 'AppxPackage==true', which should be the case for all packageable projects. I confirmed this is set to true for WinUI projects.

evelynwu-msft commented 7 months ago

Got it. Looking over the .targets it appears that the semantics we've assigned to AppxPackage aren't quite the same as what VS has assigned. Specifically, we don't use AppxPackage as the primary knob for enabling packaging.

@Scottj1s I'm reopening this issue.

MSLukeWest commented 6 months ago

Adding an additional note, after noticing that this almost works for MAUI projects. In that scenario the _GenerateMsixPackage property is true, and the package, cert and dependencies all get copied to the app installer folder, but it's missing two files at the root:

  1. .AppInstaller
  2. Index.html

So, I imagine that if a WinAppSDK fix is made that fixes the issue I describe above, there will still be this problem where the appinstaller file and index.html aren't present.