语境
存在一个烦人的 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 属性?