Any way to modify existing files in a Visual Studio template?

I am currently using the New Element template to create multiple classes in my project based on the name entered. What I would like to do is also add some lines to an existing file in the project. Is there any way to do this? Is there a way to run some kind of script from a .vstemplate file?

+4
source share
2 answers

For the vanilla element template in Visual Studio, this does not exist. Element and project templates allow you to add new files to the project and allow the customization of these files. But they cannot be used to modify existing files.

You may be able to achieve what you are looking for, but with the help of the template wizard. This allows arbitrary code to be executed during template processing. You should be able to modify existing files in awe of this.

Study Guide Link:

+4
source

EDIT : Sorry, I did not understand this question.

Original answer:
Well, the default templates are in 2 places:
\ Program Files \ Microsoft Visual Studio 8 \ Common7 \ IDE \ ItemTemplatesCache \ CSharp \ 1033
\ Program Files \ Microsoft Visual Studio 8 \ Common7 \ IDE \ ItemTemplates \ CSharp \ 1033

You can change the contents of the template for new classes and new forms there at your leisure ... You don’t know where the user-created templates are created, but there are no reasons why you could not do the same with these (as far as I know.)

0
source

All Articles