继"如何处理 SideWaffle 项目模板中的 VSTO 先决条件"之后,我发现从已安装的 VSIX 创建的新项目在项目属性中选择"发布"选项卡时使 Visual Studio 崩溃。 从原始项目模板和新生成的项目对项目文件执行差异,似乎ProjectExtensions
节点无法进入新文件。
下面是原始项目文件片段:
<Project>
<!-- Include the build rules for a C# project. -->
<Import Project="$(MSBuildToolsPath)Microsoft.CSharp.targets" />
<!-- Include additional build rules for an Office application add-in. -->
<Import Project="$(VSToolsPath)OfficeToolsMicrosoft.VisualStudio.Tools.Office.targets" Condition="'$(VSToolsPath)' != ''" />
<!-- This section defines VSTO properties that describe the host-changeable project properties. -->
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{BAA0C2D2-18E2-41B9-852F-F413020CAA33}">
<ProjectProperties HostName="Visio" HostPackage="{29A7B9D7-A7F1-4328-8EF0-6B2D1A56B2C1}" OfficeVersion="15.0" VstxVersion="4.0" ApplicationType="Visio" Language="cs" TemplatesPath="" DebugInfoExeName="#SoftwareMicrosoftOffice15.0VisioInstallRootPath#visio.exe" AddItemTemplatesGuid="{51063C3A-E220-4D12-8922-BDA915ACD783}" />
<Host Name="Visio" GeneratedCodeNamespace="VisioVstoTemplate" IconIndex="0">
<HostItem Name="ThisAddIn" Code="ThisAddIn.cs" CanonicalName="AddIn" CanActivate="false" IconIndex="1" Blueprint="ThisAddIn.Designer.xml" GeneratedCode="ThisAddIn.Designer.cs" />
</Host>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
</Project>
。这是新项目文件中的相同代码片段:
<Project>
<!-- Include the build rules for a C# project. -->
<Import Project="$(MSBuildToolsPath)Microsoft.CSharp.targets" />
<!-- Include additional build rules for an Office application add-in. -->
<Import Project="$(VSToolsPath)OfficeToolsMicrosoft.VisualStudio.Tools.Office.targets" Condition="'$(VSToolsPath)' != ''" />
<!-- This section defines VSTO properties that describe the host-changeable project properties. -->
</Project>
有没有好方法可以阻止这种情况被排除在外?
安装 TemplateBuilder 时,.props 文件将添加到项目中的"属性"下。默认情况下,生成项目模板时,将删除项目扩展。若要禁用此功能,请将以下属性添加到 .props 文件中。
<ls-enable-remove-proj-extensions>false</ls-enable-remove-proj-extensions>