我正在尝试在VSTO加载项项目文件中使用自定义属性,以减轻在安装了不同版本的Office的VM之间切换时的痛苦。鉴于PropertyGroup:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug2010|AnyCPU' ">
<OfficeVersion>14.0</OfficeVersion>
</PropertyGroup>
这有效:
<ProjectProperties HostName="Word" HostPackage="{29A7B9D7-A7F1-4328-8EF0-6B2D1A56B2C1}" OfficeVersion="$(OfficeVersion)" VstxVersion="4.0" ApplicationType="Word" Language="cs" TemplatesPath="VSTOTemplates" DebugInfoExeName="#Software\Microsoft\Office\14.0\Word\InstallRoot\Path#WINWORD.EXE" DebugInfoCommandLine="/x" AddItemTemplatesGuid="{51063C3A-E220-4D12-8922-BDA915ACD783}" />
这不是:
<ProjectProperties HostName="Word" HostPackage="{29A7B9D7-A7F1-4328-8EF0-6B2D1A56B2C1}" OfficeVersion="$(OfficeVersion)" VstxVersion="4.0" ApplicationType="Word" Language="cs" TemplatesPath="VSTOTemplates" DebugInfoExeName="#Software\Microsoft\Office\$(OfficeVersion)\Word\InstallRoot\Path#WINWORD.EXE" DebugInfoCommandLine="/x" AddItemTemplatesGuid="{51063C3A-E220-4D12-8922-BDA915ACD783}" />
唯一的区别是第一个实例中的文本14.0到DebugInfoExeName,第二个实例中是对OfficeVersion的引用。有没有办法解决这个问题?