构建 Office 加载项时的程序集绑定错误:“FindRibbons"任务意外失败 [英] Assembly binding error when building Office add-in: "FindRibbons" task failed unexpectedly

查看:16
本文介绍了构建 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) and ExplicitBind!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:

  1. 在 xml 编辑器中打开以下文件(首先进行备份):C:Program Files (x86)MSBuildMicrosoftVisualStudiov10.0OfficeToolsMicrosoft.VisualStudio.Tools.Office.目标(v10.0 部分对你来说可能不同,例如它可能是 v14.0)
  2. 删除以下部分:

  1. 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)
  2. 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"任务意外失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆