Visual Studio Intelligent Project Templates

I need to create a Visual Studio project template that has a certain amount of intelligence. I discovered a way to get Visual Studio to call its own code when creating a new project from my template, the custom code displays a dialog box and gathers information from the user, and then defines additional replacements that the project template can use. All is well and good.

This pattern was previously a set of several very similar patterns that differed only in which interface the main class implemented. My goal is to condense this set of templates into one "smart template" that automatically implements the correct interface based on user input.

To do this, I need to change the generated code at the time of its creation. Visual Studio calls my custom wizard code after creating a new project, then I would like to navigate to the newly generated C # code and add the interface implementation programmatically. I would like to add ": IMyInterface" after the main class and then start IntelliSense to extend the implementation for me. This is the part I don't know how to do.

Can anyone give me some pointers on how to automate the movement of an interface using the Visual Studio object model?

+2


source to share


3 answers


If you can open the file itself and load it as text, you should just put a placeholder in place of the original interface (say # interface_placeholder #) and then search / replace on what's in string and add that to the project instead of the original file. I think it should be possible. Does this make sense?



0


source


I think the best solution that suits you is using GAT and GAX.



It takes a bit of work to make it work well, but it can definitely help you: http://msdn.microsoft.com/en-us/teamsystem/aa718948.aspx

0


source


The problem with using GAX requires end users to download the framework before installing a template that was built using GAX.

The best solution is to use the VS 2010 SDK to build a VSIX, which will not require end users to download any additional plugin to install your template. You can take a look here: Multi-project templates with wizard: Visual Studio 2010 Example

0


source







All Articles