首页 > 解决方案 > 是否可以使用 Windows 应用程序打包项目打包两个 UWP 应用程序?

问题描述

我有两个 UWP 项目,一个用于自定义共享 UI,它是一个 ShareTarget 应用程序和一个主应用程序,两者都是 uwp。

而且,我有以下应用程序结构。(本例中的所有示例应用,都是从“新项目”创建的,除了默认内容外,基本上没有任何内容)

在此处输入图像描述

但是,当我构建 WapProjTemplate1 时,我得到以下错误日志,

错误 APPX1101 有效负载包含两个或多个具有相同目标路径“App.xbf”的文件。源文件:\source\repos\WapProjTemplate1\App1\bin\x64\Debug\App.xbf source\repos\WapProjTemplate1\App2\bin\x64\Debug\App.xbf WapProjTemplate1 D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\VisualStudio\v15.0\AppxPackage\Microsoft.AppXPackage.Targets 1766

甚至可以有两个应用程序吗?

我想要两个应用程序的原因是,我想从 ShareUI 调用主应用程序。

标签: c#.netuwpwin-universal-appwindows-10-universal

解决方案


You shouldn't have two separate apps for enabling Sharing. Your main app will just declare itself as the receptor of Sharing in its manifest as per docs.

It will then launch (if it's not running) or get re-activated if it is, with the following OnShareTargetActivated event;

protected override async void OnShareTargetActivated(ShareTargetActivatedEventArgs args)

Here is where you can redirect to a different page, or pop open a new window populated with the data from the share.


推荐阅读