windows应用打包项目创建应用包复制dll失败

Creating an App Package through a windows application packaging project fails to copy a dll

我有一个新创建的(空的).net core 3.1 WinForm 项目,我想在其中使用 CefSharp。该应用程序本身运行良好,但我无法创建应用程序包。如果我不添加 CefSharp NuGet 包,我可以创建一个应用程序包,这让我觉得有些不兼容。

详细信息和步骤:

我在 .net core 3.1 Winform 项目中使用 CefSharp.Wpf 83.4.20。为了澄清,我也尝试使用 Cefsharp.WinForms,结果相同。我使用 Microsoft Visual Studio Community 2019,版本 16.6.4.

我将 CefSharp 安装为 NuGet,select x64 作为目标,编译并运行良好。

我创建了一个 windows 应用程序打包项目并添加了对我的应用程序的引用。

当我select发布->创建应用程序包时出现问题;弹出以下警告,然后以“发生未指定的错误”终止:

Could not copy "C:\Users\xyz.nuget\packages\cefsharp.common.4.20\CefSharp\x64\CefSharp.Core.dll" to "obj\x64\Release\PackageLayout\StockCalc\CefSharp.Core.dll". Beginning retry 1 in 1000ms. The process cannot access the file 'obj\x64\Release\PackageLayout\StockCalc\CefSharp.Core.dll' because it is being used by another process. The file is locked by: "MSBuild.exe (13748)" WapProj C:\Program Files (x86)\Microsoft Visual Studio19\Community\MSBuild\Microsoft\VisualStudio\v16.0\AppxPackage\Microsoft.AppXPackage.Targets 3986

..文件 CefSharp.Core.dll 似乎被 MSBuild.exe 锁定了。

即使在重新启动计算机、使用不同版本的 CefSharp 并安装 visual studio 2019 的一些更新后,也会发生这种情况。

我也尝试用他们提供的 MinimalExample (CefSharp.MinimalExample) 重现错误,编译正常。我创建一个 windows 应用程序打包项目并添加对 CefSharp.MinimalExample.WinForms.NetCore 项目的引用。

我在这里遇到了完全相同的错误:

Could not copy "C:\Users\xyz.nuget\packages\cefsharp.common.4.20\CefSharp\x64\CefSharp.Core.dll" to "obj\x64\Release\PackageLayout\CefSharp.MinimalExample.WinForms.netcore\CefSharp.Core.dll". Beginning retry 1 in 1000ms. The process cannot access the file 'obj\x64\Release\PackageLayout\CefSharp.MinimalExample.WinForms.netcore\CefSharp.Core.dll' because it is being used by another process. WapProjTemplate1 C:\Program Files (x86)\Microsoft Visual Studio19\Community\MSBuild\Microsoft\VisualStudio\v16.0\AppxPackage\Microsoft.AppXPackage.Targets 3986

我收到的错误信息是:

Error PRI222: 0xdef00001 - Unspecified error occurred. WapProjTemplate1 GENERATEPROJECTPRIFILE 1
Error PRI175: 0x8007000b - Processing Resources failed with error: An attempt was made to load a program with an incorrect format. WapProjTemplate1 GENERATEPROJECTPRIFILE 1

此外,当我尝试发布一个最小示例时,我收到了这些警告:

Warning NU1701 Package 'System.Windows.Interactivity.WPF 2.0.20525' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETCoreApp,Version=v3.0'. This package may not be fully compatible with your project. CefSharp.MinimalExample.Wpf.netcore ...\CefSharp.MinimalExample-master\CefSharp.MinimalExample-master\CefSharp.MinimalExample.Wpf\CefSharp.MinimalExample.Wpf.netcore.csproj 1

Warning The plugin credential provider could not acquire credentials. Authentication may require manual action. Consider re-running the command with --interactive for dotnet, /p:NuGetInteractive="true" for MSBuild or removing the -NonInteractive switch for NuGet WapProjTemplate1 C:\Program Files (x86)\Microsoft Visual Studio19\Community\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets 129

我试图提供尽可能多的关于这个的信息,因为它一直在工作。恐怕错误是在 visual studio 的一些更新后开始发生的,但我不知道它是什么时候开始崩溃的。

感谢您对此的任何帮助。

Creating an App Package through a windows application packaging project fails to copy a dll

对于你的第一期,

,请尝试clean all nuget caches

然后关闭VS,使用任务管理器杀死任何VS相关的进程。

还有,不要忘记删除Winform项目的binobj文件夹。

之后,重启你的项目,在你的winforms项目中重新安装CefSharp.Wpf 83.4.20 nuget包再次测试。

Error PRI222: 0xdef00001 - Unspecified error occurred. WapProjTemplate1 GENERATEPROJECTPRIFILE 1 Error PRI175: 0x8007000b - Processing Resources failed with error: An attempt was made to load a program with an incorrect format. WapProjTemplate1 GENERATEPROJECTPRIFILE 1

对于第二个问题,首先你应该使用确保你的打包项目使用x64平台

除了,在创建包之前,您应该添加

<FilterSatelliteAssembliesForMakePri>false</FilterSatelliteAssembliesForMakePri>

WapProjTemplate1.csproj 文件的打包 xml 节点下:

或者你应该这样添加:

按照步骤,我可以成功创建安装程序包。