【问题标题】:creating a collection variable in MSBuild .targets在 MSBuild .targets 中创建集合变量
【发布时间】:2012-11-26 17:16:59
【问题描述】:

上下文

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

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

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

这里详细描述了 VSTO 错误和解决方法:"FindRibbons" task failed unexpectedly

.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 属性?

【问题讨论】:

  • 链接中提到的其他解决方法无效?
  • @KMoraz 不,尝试了所有其他方法,但没有一个对我有用

标签: c# visual-studio msbuild vsto build-process


【解决方案1】:

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

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

【讨论】:

    【解决方案2】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多