Search code examples
c#winformsmsbuildvsixvisual-studio-templates

How to compile Item Template Project for Form with substitute parameters


I am trying to make an ItemTemplate for a Form. I create a "c# Item Tamplate"-Project, make my Form, and create my Template by Building the project. That works fine.

Now I want to add Templateparameters but as soon as I do, the project wont compile any more. It throws many different exceptions because the code is no longer valid. How can I solve this problem?

Here is what I tried so far:

  • Replacing every occurrence of my Classname with $safeitemname$. This, as I already said, throws exception because now the code is invalid and the project can not be built.
  • Creating CustomParameters in my .vstemplate to change a valid class name to my desired parameter (Classname -> $safeitemname$). This does nothing, even though I set "Replaceparameters="True"".
  • Ignoring the compiler warnings and implementing the project in my .vsix project anyway. This does nothing either, because the .zip for my template still can not be.
  • Setting DependentUpon of my Classname.Designer.cs to my Classname.cs. This does nothing either.
  • Trying a simple ItemTemplate with one class that's divided in two partial classes that have one Property each. Same thing as with the Form. It can no longer be build.

Solution

  • As Reza Aghaei suggested in his comment, the problem was, that I didn't set the build action for the files in my project to 'None'.