0

Following on from "How to handle VSTO prerequisites in SideWaffle project template" I've found that the new project created from the installed VSIX crashes Visual Studio when selecting the Publish tab in project properties. Doing a diff on the project files from the original project template and the newly generated project it appears that the ProjectExtensions node doesn't make it through to the new file.

Here's the original project file snippet:

<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>

...and here's the same snippet from the new project file:

<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>

Is there a good way to stop this from being excluded?

Community
  • 1
  • 1
JohnGoldsmith
  • 2,638
  • 14
  • 26

1 Answers1

2

When you install TemplateBuilder a .props file is added to your project under Properties. By default when the project template is built ProjectExtensions is removed. To disable that add the following property into the .props file.

<ls-enable-remove-proj-extensions>false</ls-enable-remove-proj-extensions>
JohnGoldsmith
  • 2,638
  • 14
  • 26
Sayed Ibrahim Hashimi
  • 43,864
  • 17
  • 144
  • 178
  • Great, this works perfectly (when set to false - is that a typo?) and the GeneratedCodeNamespace attribute gets replaced correctly too. Out of interest, what's the rationale for removing ProjectExtensions by default? Thanks again. – JohnGoldsmith Jan 26 '15 at 10:01
  • @JohnGoldsmith web projects (and other proj types i think) store values that are temporary and specific to that project (i.e IIS Express port). So they should be re-created when the project is opened in VS. – Sayed Ibrahim Hashimi Jan 26 '15 at 16:23
  • If you could add a note about this to https://github.com/ligershark/side-waffle/wiki/Common-errors-and-gotchas I would appreciate that. – Sayed Ibrahim Hashimi Jan 26 '15 at 17:40
  • @JohnGoldsmith thanks for the wiki contribution, I really appreciate that. SideWaffle is a true community effort :) – Sayed Ibrahim Hashimi Jan 27 '15 at 17:47