2

语境

存在一个烦人的 Excel 加载项编译错误,我目前能够解决它的唯一方法是编辑 VSTO MSBuild .targets 文件

  • C:\Program Files\MSBuild\Microsoft\VisualStudio\v11.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets

通过下面的修改,我可以编译 Excel 加载项,但副作用是不再显示我的自定义功能区

此处详细描述了 VSTO 错误和解决方法:“FindRibbons”任务意外失败

.targets 修改具有空 RibbonTypes 的不良副作用

<!--  This part is causing the compilation to fail and has to be commented out -->
<!--  <FindRibbons-->
<!--           AssemblyName="$(AbsolutePathToCustomization)"-->
<!--           TargetFramework="$(TargetFrameworkVersion)"-->
<!--        >-->
<!--  <Output TaskParameter="RibbonTypes" ItemName="RibbonTypesCollection"/>-->
<!--  </FindRibbons>-->


<!-- Now RibbonTypes is empty, causing the side-effect-->       
<!-- Used to be RibbonTypes="@(RibbonTypesCollection)"-->       
<!-- Can I manually recreate @(RibbonTypesCollection)?-->       
<GenerateOfficeDocumentManifest Condition="'$(VSTO_ProjectType)' == 'Document'"
    SolutionID="$(SolutionID)"
    RibbonTypes=""
    TargetFramework="$(TargetFrameworkVersion)"
>

手动填写参数?

现在我需要提供如下内容

“ProjectNamespace.RibbonName、AssemblyName、Version=1.0.0.0、Culture=neutral、PublicKeyToken=null”

  • 但我不确切知道数据必须采用什么形式,而且我也不知道 MSBuild 语法?
  • 怎么可能手动填充 RibbonTypes 属性?
4

2 回答 2

1

我有这个问题。这显然是因为我将参考“Microsoft.Office.Tools.Common.v4.0.Utilities”上的“复制本地”设置从 True 更改为 False。

我已经将一个项目从 VS2012 升级到 VS2013,并注意到该引用是唯一设置为“Copy Local = True”的引用。所以我把它设置为假。因为它是不同的。

于 2015-07-08T06:07:18.787 回答
0

我有同样的问题。就我而言,它依赖于我的解决方案中的一个项目。由于该组件正在使用第三方库,它必须编译为 x86,而不是插件推荐的“任何 CPU”。

幸运的是,在我的情况下,修复很简单——将组件拆分为“API”和“Impl”部分,将 API 部分编译为“Any CPU”,然后引用它而不是完整的组件。

于 2013-01-24T18:07:20.523 回答