CommunityToolkit / Microsoft.Toolkit.Win32

ARCHIVE - This repository contained XAML Islands wrapper controls and tooling for XAML Islands with WinUI 2, see readme for more info about XAML Islands with WinUI 3 and the WindowsAppSDK.
https://aka.ms/windowsappsdk
Other
384 stars 89 forks source link

80080204: App manifest validation error during building XamlIsland apps #328

Open michalleptuch opened 2 years ago

michalleptuch commented 2 years ago

Describe the bug

I can't build my XamlIsland apps in Visual Studio 2019 v16.10 and higher. Even Visual Studio 2022 Preview doesn't handle it. Visual Studio 2019 v16.9.8 is the last tested and working version.

Error   APPX0501    Validation error. error 80080204: App manifest validation error: Line 66, Column 27, Reason: The field "*[local-name()='Extensions']/*[local-name()='Extension']/*[local-name()='InProcessServer']/*[local-name()='ActivatableClass']" with value "Microsoft.Toolkit.Win32.UI.XamlHost.XamlApplication" must only be declared once. A duplicate exists on Line 60, Column 27.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Clone this repo: https://github.com/michalleptuch/rounded-flyout
  2. Open in VS and try to build

Expected behavior

Correctly building of solution

Environment

Project .NET Version:
-  .NET Core 3.1

Packages:
- Microsoft.Toolkit.Win32.UI.XamlApplication (6.0.0-6.1.3)

Windows 10 Build Number:
- 18362-22000

App min and target version:
- 18362-22000

Device form factor:
- Desktop

Visual Studio 
- 2019 (version: 16.10.x) 
- 2022 Preview (version: 17.0)
- 2022

Additional context

I found similar issues that describe the same situations but solutions don't work for me:

ghost commented 2 years ago

Hello michalleptuch, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌

ghost commented 2 years ago

This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.

ghost commented 2 years ago

This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.

michael-hawker commented 2 years ago

FYI @marb2000 @ocalvo

Samuel12321 commented 2 years ago

The ModernFlyouts Team is also experiencing this issue. This is a major breaking bug that has had no solution for 4 months. @marb2000 @ocalvo @michael-hawker

atiyka commented 2 years ago

I also experienced the same issue when I updated the VisualStudio2019. As a temporal solution I had to go back to the previous version and I can't upgrade until this bug won't be fixed.

michael-hawker commented 2 years ago

Has anyone filed a new issue with the Visual Studio team for this regression? If so, can they link to that issue here?

Samuel12321 commented 2 years ago

Has been reported here https://developercommunity2.visualstudio.com/t/Visual-Studio-16100-breaks-support-for/1634426?q=microsoft.toolkit&ftype=problem&space=8&stateGroup=active&sort=newest

Samuel12321 commented 2 years ago

Has been reported here https://developercommunity2.visualstudio.com/t/Visual-Studio-16100-breaks-support-for/1634426?q=microsoft.toolkit&ftype=problem&space=8&stateGroup=active&sort=newest

Can everyone please upvote this issue so it can get fixed.

ocalvo commented 2 years ago

It seems that the toolkit msbuild code that detects if the Xaml Applicaton dll has been added already is now not detecting it and ends up adding 2 entries of the same dll.

ocalvo commented 2 years ago

Please replace this section of your wap project as follows:

  <ItemGroup>
    <ProjectReference Include="..\RoundedFlyout.Uwp\RoundedFlyout.Uwp.csproj" />
    <ProjectReference Include="..\RoundedFlyout.Wpf\RoundedFlyout.Wpf.csproj" />
  </ItemGroup>
  <Target Name="_RemoveWinMDFromAppxManifest" BeforeTargets="_GenerateCurrentProjectAppxManifest">
    <ItemGroup>
      <_AppxWinmdFilesToHarvest Remove="@(_AppxWinmdFilesToHarvest)" />
    </ItemGroup>
  </Target>
  <Target Name="_StompSourceProjectForWapProject" BeforeTargets="_ConvertItems">
    <ItemGroup>
      <_TemporaryFilteredWapProjOutput Include="@(_FilteredNonWapProjProjectOutput)" />
      <_FilteredNonWapProjProjectOutput Remove="@(_TemporaryFilteredWapProjOutput)" />
      <_FilteredNonWapProjProjectOutput Include="@(_TemporaryFilteredWapProjOutput)">
        <SourceProject>
        </SourceProject>
      </_FilteredNonWapProjProjectOutput>
      <_DetailedPriXml Remove="@(_DetailedPriXml)" />
    </ItemGroup>
  </Target>
Samuel12321 commented 2 years ago

Seems to work, Thanks @ocalvo. When should we expect this to be properly fixed?

michalleptuch commented 2 years ago

@ocalvo Yes, it works for building, but during packaging app for the Store I get this error:

1>PRI175: 0x80073b0f - Processing Resources failed with error: Duplicate Entry.
1>PRI222: 0x80073b0f - Unspecified error occurred.

Branch: FixForVS

atiyka commented 2 years ago

Thank you @ocalvo, it works for me as well

atiyka commented 2 years ago

@ocalvo, after I added your suggestion to the project, I submitted the build to the Store, but the certification process did not start at all. After 4 days of waiting we received an email from the support: The submission has been cancelled due to an invalid package. Error details: Error: DirectWriteForwarder : Gatekeeper error GK0028 : GK0028 Assembly ‘DirectWriteForwarder’ is a mixed mode assembly containing managed and native code. Only pure managed assemblies are compatible with .NET Native. I reverted this change, created an app package with an older VS 2019 (16.9.1) and tried to submit to the store. Almost immediatelly started the certification process, so I think this workaround cause the issue.

Do you have any idea?

michalleptuch commented 2 years ago

@atiyka How did you create an app package? I stucked on this https://github.com/CommunityToolkit/Microsoft.Toolkit.Win32/issues/328#issuecomment-1021592542.

atiyka commented 2 years ago

Well, I just added the code above (except the first 4 lines) at the end of the .wapproj file in the UWP project before the closing </Project> tag. It created the app package without any issues for the packaging project in VS.

Samuel12321 commented 2 years ago

This is a major breaking bug that has been a problem for 6 months now. Any eta on when we can expect an official solution / patch shipped? @marb2000 @ocalvo @michael-hawker

aquinn39 commented 1 year ago

Also reported here: https://github.com/MicrosoftDocs/windows-dev-docs/issues/3544. This issue still exists in the latest version of Visual Studio 2022 unfortunately so I'm still stuck using Visual Studio 2019 16.9.8.