0

I am trying to follow the steps here: https://msdn.microsoft.com/en-us/library/cc512961.aspx to create a new project system for a custom DSL that I want to add support for in Visual Studio (eventually this will include a lot of functionality, but right now I'm just trying to get something very basic to work).

I can get their example to work, but I have been having trouble trying to make what should be a very simple modification: putting the "AssemblyInfo.cs" file into a "Properties" folder.

My template looks like this:

  • Template
    • AssemblyInfo.cs
    • Program.cs
    • Template.myproj
    • Template.vstemplate

And I want my created project to have the structure:

  • Template
    • Properties
      • AssemblyInfo.cs
    • Program.cs
    • Template.myproj
    • Template.vstemplate

So I have modified my .myproj file to read:

<ItemGroup>
  <Compile Include="Properties\AssemblyInfo.cs" />
  <Compile Include="Program.cs" />
</ItemGroup>

and my .vstemplate file to read:

<TemplateContent>
  <Project File="Template.myproj" ReplaceParameters="true">
    <ProjectItem ReplaceParameters="true" TargetFileName="Properties\AssemblyInfo.cs">AssemblyInfo.cs</ProjectItem>
    <ProjectItem ReplaceParameters="true" OpenInEditor="true">Program.cs</ProjectItem>
  </Project>
</TemplateContent>

This is very simple: I've just added "Properties\" in two places.

However, upon creating a new project, my experimental VS instance complains:

Collection was modified; enumeration operation may not execute.

Needless to say, no code I've written contains any enumerations of any kind... I have tried stepping though the "MPFProj" code, but the error seems to occur at a random place that has nothing to do with the code being stepped though (presumably the error happens on a different thread?).

Oddly, it seems as though I can, without the folders, create a new project and then manually create (as in, in the IDE) a folder, and then I can add a new file (using a "new item" template) into that folder just fine.

Is this a bug in MPFProj? Do I need to override one of the 100,000 undocumented virtual methods in the MPFProj types to handle this? Is the vstemplate file incorrect?

Also: are there any good sources for Visual Studio extensibility for VS 2015? Or best practices to how to implement these things? Or meaningful documentation? I've looked at a few examples (e.g., the IronPython VS plugin) and they are not particularly enlightening, particularly for resolving subtle issues like this one (and without good documentation it's impossible to tell why the differences between different examples exist...).

0 Answers0