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

0

I have a newly created (empty) .net core 3.1 WinForm project where I want to use CefSharp. The app in itself runs fine, but I cannot create an app package. I can create an app package if I do not add the CefSharp NuGet package, which makes me think there are some incompatibilities.

Details and step-by-step:

I am using CefSharp.Wpf 83.4.20 in a .net core 3.1 Winform project. To clarify, I have tried using Cefsharp.WinForms as well, with the same result. I use Microsoft Visual Studio Community 2019, Version 16.6.4.

I install CefSharp as a NuGet, select x64 as a target, compile and it runs fine.

I create a windows application packaging project and add a reference to my app.

The problem arises when I select Publish->Create App Packages; The following warning pops up, and then it terminates with an "Unspecified error occurred":

Could not copy "C:\Users\xyz.nuget\packages\cefsharp.common\83.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 Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\AppxPackage\Microsoft.AppXPackage.Targets 3986

..it seems the file CefSharp.Core.dll is locked by MSBuild.exe.

This happens even after restarting the computer, using different versions of CefSharp, and installing a few updates of visual studio 2019.

I also tried to reproduce the error with the MinimalExample (CefSharp.MinimalExample) they provide, it compiles fine. I create a windows application packaging project and add a reference to the CefSharp.MinimalExample.WinForms.NetCore project.

I got exactly the same error here:

Could not copy "C:\Users\xyz.nuget\packages\cefsharp.common\83.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 Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\AppxPackage\Microsoft.AppXPackage.Targets 3986

The error messages I get are:

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

Also, when I try to Publish a minimal example, I get these warnings:

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

and

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 Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets 129

I tried to give as much information as possible on this one, as IT HAS BEEN WORKING. I am afraid the error started to happen after some updates of the visual studio, but I have no idea when it started to break.

Thank's for any help with this one.

visual-studio
winforms
.net-core
msbuild
cefsharp
asked on Stack Overflow Aug 10, 2020 by Snorvarg • edited Aug 10, 2020 by Roman Svitukha

1 Answer

1

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

For your first issue,

first, please try to clean all nuget caches

then close VS, use Task Manager to kill any VS related process.

Also, do not forget to delete bin and obj folder of the Winform project.

After that, restart your project, reinstall CefSharp.Wpf 83.4.20 nuget package in your winforms project to test again.

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

For the second issue, first you should use make sure that your packing project use x64 Platform

enter image description here

Besides, before you create the package, you should add

<FilterSatelliteAssembliesForMakePri>false</FilterSatelliteAssembliesForMakePri>

under the packing xml node of WapProjTemplate1.csproj file:

Or you should add like this:

enter image description here

With the steps, I can create the installer package successfully.

answered on Stack Overflow Aug 11, 2020 by Perry Qian-MSFT

User contributions licensed under CC BY-SA 3.0