1

Our app is built in WPF but we are adding notifications with UWP. We have a packaging project, a UWP background task project, and an empty UWP app project that references the background task project, in addition to many other unrelated projects in the solution. The packaging project references the main WPF project and the empty UWP project. Building works fine in Visual Studio but fails when building with msbuild from the command line or our build system. We get this error:

"C:\repos\appName\BuildAll\appName.sln" (default target) (1) ->
"C:\repos\appName\BuildAll\..\appName.DesktopBridge\appName.DesktopBridge.wapproj.metaproj" (default target) (18) ->
"C:\repos\appName\appName.DesktopBridge\appName.DesktopBridge.wapproj" (default target) (19) ->
(_ValidateAppxManifest target) ->
  C:\repos\appName\appName.DesktopBridge\bin\x86\Debug\AppxManifest.xml : error APPX0501: Validation error. error 800
80204: App manifest validation error: Line 64, Column 27, Reason: The field "*[local-name()='Extensions']/*[local-name(
)='Extension']/*[local-name()='InProcessServer']/*[local-name()='ActivatableClass']" with value "Microsoft.UI.Xaml.Mark
up.ReflectionXamlMetadataProvider" must only be declared once. A duplicate exists on Line 57, Column 27. [C:\repos\appName\appName.DesktopBridge\appName.DesktopBridge.wapproj]

This is because when using msbuild the extensions sections of AppxManifest.xml looks like this:

<Extensions>
    <Extension Category="windows.activatableClass.inProcessServer">
      <InProcessServer>
        <Path>appName.exe</Path>
        <ActivatableClass ActivatableClassId="Microsoft.UI.Xaml.Markup.ReflectionXamlMetadataProvider" ThreadingModel="both" />
        <ActivatableClass ActivatableClassId="appName.BackgroundTasks.IncomingCallPushTask" ThreadingModel="both" />
      </InProcessServer>
    </Extension>
    <Extension Category="windows.activatableClass.inProcessServer">
      <InProcessServer>
        <Path>CLRHost.dll</Path>
        <ActivatableClass ActivatableClassId="Microsoft.UI.Xaml.Markup.ReflectionXamlMetadataProvider" ThreadingModel="both" />
        <ActivatableClass ActivatableClassId="appName.BackgroundTasks.IncomingCallPushTask" ThreadingModel="both" />
      </InProcessServer>
    </Extension>
  </Extensions>

When building with Visual studio it looks like this and works fine:

<Extensions>
        <Extension Category="windows.backgroundTasks" EntryPoint="appName.BackgroundTasks.IncomingCallPushTask" Executable="appName.exe">
          <BackgroundTasks>
            <Task Type="pushNotification" />
          </BackgroundTasks>
        </Extension>
      </Extensions>

I have tried specifying the extensions in Package.appxmanifest to look like what needs to appear in AppxManifest.xml but have not been able to get msbuild to generate a valid AppxManifest file.

Alex Smith
  • 11
  • 2
  • Derive from the error message `ReflectionXamlMetadataProvider" must only be declared once.`, could you try to remove one of them? – Nico Zhu May 11 '20 at 02:13
  • @NicoZhu-MSFT the problem is that the file AppxManifest.xml where it is declared twice is auto generated by MSbuild. – Alex Smith May 11 '20 at 06:48
  • @AlexSmith have you found the solution? it is happening to me since I upgraded to visual studio 16.8 – Carlos Rafael Ramirez Nov 10 '20 at 22:15
  • I also started to get this problem with 16.8 – tipa Nov 17 '20 at 07:40
  • I created an issue for this here - please upvote & add info that could help as a comment: https://developercommunity.visualstudio.com/content/problem/1258250/error-when-building-uwp-app-with-packaging-project.html – tipa Nov 17 '20 at 10:25
  • I got around this issue but it was not a real fix. The code where this was happening on was a branch that hadn't been merged in yet because of this issue. I made a new branch and added in the required code slowly and kept checking if this error would come back. I was able to get the new branch doing the required work without this issue happening again. I really don't know what change caused this though. – Alex Smith Nov 25 '20 at 20:05

0 Answers0