Post-构建指令语法

Post-build ditrective syntax

当我将项目部署到服务器时,我收到了这个与 ClosedXML 相关的可怕错误。

虽然该项目在本地运行。

Could not load file or assembly 'DocumentFormat.OpenXml, Version=2.5.5631.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

所以我把"missing" DLL文件放在/binDLL

然后我添加了以下 cmd 行指令:

Copy "$(SolutionDir)binDLL\DocumentFormat.OpenXml.dll" "$(ProjectDir)$(OutDir)"

构建时出现构建错误

Error   17  The command "Copy "C:\Projects\MyProject\binDLL\DocumentFormat.OpenXml.dll" "C:\Projects\MyProject\bin\"" exited with code 1

我没有理由这样做。只需在解决方案资源管理器中打开引用,右键单击有问题的引用,选择 Properties 并将 Copy Local 设置为 True。这应该可以解决问题。