来自" How to handle VSTO prerequisites in SideWaffle project template"我发现在项目属性中选择“发布”选项卡时,从已安装的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)\OfficeTools\Microsoft.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="#Software\Microsoft\Office\15.0\Visio\InstallRoot\Path#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)\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets" Condition="'$(VSToolsPath)' != ''" />
<!-- This section defines VSTO properties that describe the host-changeable project properties. -->
</Project>
有没有一种好方法可以阻止它被排除?
答案 0 :(得分:2)
安装TemplateBuilder时,会在“属性”下的项目中添加.props文件。默认情况下,在构建项目模板时,将删除ProjectExtensions。要禁用它,请将以下属性添加到.props文件中。
<ls-enable-remove-proj-extensions>false</ls-enable-remove-proj-extensions>