I'm in the process of creating a MVC starterkit for work and I'm having problems creating a multi-project template that doesn't require massive manual modification after creation.
What I have is 4 projects that have some dependencies on each other:
- StarterKit.Common - no dependency
- StarterKit.DAL - dependency to StarterKit.Common
- StarterKit.BL - dependency to StarterKit.Common and StarterKit.DAL StarterKit.Web - dependency to the other three
I've tried going the route of exporting each project using the Export Template wizard, creating a root .vstemplate file and zipping it all up. Although this works (I can create a new solution based on this template), it has some serious problems.
Firstly, the export replaces the entire namespace of each project with $safeprojectname$, i.e. StarterKit.DAL => $safeprojectname$, StarterKit.Web => $safeprojectname$ etc.
This means that when the new project is created (let's call it XXX), what was previously in the namespace StarterKit.Web now ends up in the XXX namespace and what was previously StarterKit.BL also ends up in the XXX namespace!
This is obviously not going to work.
Secondly, some using statements are not replaced at all. For example using StarterKit.Common;
is not replaced in the web project because it doesn't have the correct namespace (which is StarterKit.Web).
Thirdly, I have some .tt scripts that contains using statements I want to replace, but even though I set ReplaceParameters="true"
in the project, these are not touched at all.
I also looked into creating a VSIX project, but frankly I don't see how I can use that. To me it looks mostly like a zip utility that creates the .vstemplate for you and renames the .zip to .vsix for me.
What I need to do is:
- Package all the projects in a single deploy file available as a "New Project" template in VS
- When a newproject is created, replace all "StarterKit" namespace references in .csproj, .cs, .cshtml and .tt files with whatever the user selected as the solution name
- Figure out a simple process where I can easily update the templates whenever the base projects change (files added/removed, renamed, content changed etc)
Does anyone have any idea if this is even possible?