Zachary Yates
Zachary Yates

Reputation: 13386

Visual Studio class/file templates: Is there a way to change their content automatically per project/solution?

I've updated my default templates in Visual Studio for classes, interfaces, code files, etc. I removed the default namespaces and added a copyright header blurb.

Is there a way to use a variable or something in the template so I don't have to zip/unzip and re-run the vs installer to change the copyright header? (I'm a consultant, the code-owner isn't always me or my company).

Upvotes: 1

Views: 1299

Answers (2)

Ashraf Alam
Ashraf Alam

Reputation: 3650

You can get the complete example implemented here: Multi-Project Templates with Wizard: Visual Studio 2010 Sample

Upvotes: 0

John Saunders
John Saunders

Reputation: 161801

Yes, you can. The documentation for this sort of thing is part of the Visual Studio SDK. There are already many variables you can use.

If you find you want to get fancy, look into the Guidance Automation Toolkit. A template using GAT can accept user input as well as information from the project and environment, can unfold one or more templates, filling in placeholders with the data gathered, and then can execute various actions against the unfolded templates, the project, or whatever.

Upvotes: 1

Related Questions