Assembly binding error when building Office add-in: quot;FindRibbonsquot; task failed unexpectedly(构建 Office 加载项时的程序集绑定错误:“FindRibbons任务意外失败)
问题描述
我们正在尝试设置 Jenkins(构建服务器)作业来构建基于 VSTO 的 Office 加载项.但是,在将 DLL 复制到项目的 bin
目录后,我不断收到一个奇怪的错误,即构建过程失败:
We're trying to set up a Jenkins (build server) job to build our Office add-in based on VSTO. However, I keep getting a strange error that fails the build process after the DLL is copied to the bin
directory of the project:
Error 11 The "FindRibbons" task failed unexpectedly.
System.IO.FileNotFoundException:
Could not load file or assembly 'MyAddIn, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null' or one of its dependencies.
The system cannot find the file specified.
File name: 'MyAddIn, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
所以问题是由 Office 加载项构建目标触发的FindRibbons"任务已成功将 MyAddIn DLL 识别为 Office 加载项,但无法找到并加载它!
So the problem is that the "FindRibbons" task, triggered by the Office add-in build target, has successfully identified the MyAddIn DLL as being an Office Add-In, but is not able to locate and load it!
有什么想法吗?我希望能够直接调试 FindRibbons 任务,但挂钩和调试编译过程似乎有点极端......
Any ideas? I'd love to be able to debug the FindRibbons task directly but hooking into and debugging the compile process seems a little extreme...
以下是一些观察:
- 在我们用于绑定 MyAddIn 程序集的构建服务器的 Fusion 日志中,它看起来像是在 MSBuild.exe 所在的文件夹中查找 (
C:WindowsMicrosoft.NETFrameworkv4.0.30319
) 其他地方都没有.在我的开发机器上,没有 MyAddIn 的 Fusion 日志条目!但构建过程成功并且 Kivo 工作正常. - 在我的开发和构建机器上,我还有
WhereRefBind!Host=(LocalMachine)!FileName=(PresentationCore.dll)
和ExplicitBind!FileName=(MyAddIn.dll)
显示绑定成功. - 无论我是从命令行使用 Visual Studio 还是 MSBuild 来构建项目,构建服务器都会出现此错误.
- 我已确保我的开发机器和构建服务器上的 .NET/MSBuild/VS2012 版本相同,并且错误仍然存在.唯一的区别似乎是构建服务器运行的是 Windows Server 2012(因为它是 Azure,我们无法启动 Windows 7 映像).
- In our build server's Fusion logs for binding the MyAddIn assembly it looks like it's looking in the folder where MSBuild.exe lives (
C:WindowsMicrosoft.NETFrameworkv4.0.30319
) and nowhere else. On my dev machine, there is no Fusion log entry for MyAddIn! But the build process succeeds and Kivo works fine. - On both my dev and build machines I also have Fusion log entries for
WhereRefBind!Host=(LocalMachine)!FileName=(PresentationCore.dll)
andExplicitBind!FileName=(MyAddIn.dll)
which show the binding succeeding. - This error comes up on the build server whether I use Visual Studio or MSBuild from the command line to build the project.
- I've ensured that the .NET/MSBuild/VS2012 versions are identical on both my dev machine and the build server and the error still occurs. The only difference seems to be that the build server is running Windows Server 2012 (since it's Azure, and we can't spin up a Windows 7 image).
推荐答案
这对我每次升级 Visual Studio 时都有效——顺便说一句,我不使用功能区.
This has worked for me everytime I upgrade Visual Studio - I don't use ribbons btw.
这适用于我的解决方案,但使用风险自负:
This worked for my solution, but use at your own risk:
- 在 xml 编辑器中打开以下文件(首先进行备份):
C:Program Files (x86)MSBuildMicrosoftVisualStudiov10.0OfficeToolsMicrosoft.VisualStudio.Tools.Office.目标
(v10.0 部分对你来说可能不同,例如它可能是 v14.0) 删除以下部分:
- Open the following file in an xml editor (make a backup first):
C:Program Files (x86)MSBuildMicrosoftVisualStudiov10.0OfficeToolsMicrosoft.VisualStudio.Tools.Office.targets
(the v10.0 part may be different for you, e.g. it might be v14.0) Remove the following section:
<FindRibbons AssemblyName="$(AbsolutePathToCustomization)" TargetFramework="$(TargetFrameworkVersion)">
<Output TaskParameter="RibbonTypes" ItemName="RibbonTypesCollection"/>
</FindRibbons>
将所有出现的 "@(RibbonTypesCollection)"
替换为 "" 4. 保存文件并重新启动 Visual Studio
Replace all occurrences of "@(RibbonTypesCollection)"
with "" 4. Save the file and restart visual studio
这篇关于构建 Office 加载项时的程序集绑定错误:“FindRibbons"任务意外失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:构建 Office 加载项时的程序集绑定错误:“FindRib
基础教程推荐
- MS Visual Studio .NET 的替代品 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- c# Math.Sqrt 实现 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01