Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a Visual Studio project template that includes linked files?

In Visual Studio 2010, I want to create a project template that includes links to two files that should exist on the system. One of them is a common AssemblyInfo.cs file. Another is the strong name key file (*.snk).

I need these references to be relative, because each developer's workspace will be set up differently. Is it possible for the project template to somehow figure out where these files reside in each developer's environment?

From reading about templates, it sound like they're pretty static so I wonder if tricks can be done to do something like this. If nothing else, I can add bogus references that will cause compilation errors and force the developer to hook these files in. But if I can do it for them, that would be better.

like image 860
bsh152s Avatar asked May 25 '11 17:05

bsh152s


People also ask

How do I save a Visual Studio project as a template?

On the Project menu, choose Export Template. The Export Template Wizard opens. On the Choose Template Type page, select Project Template. Select the project you want to export to a template, and then choose Next.

How do I create a Visual Studio template?

The default location is %USERPROFILE%\Documents\Visual Studio <version>\Templates\ItemTemplates. Close Visual Studio and then reopen it. Create a new project, or open an existing project, and then choose Project > Add New Item or press Ctrl+Shift+A. The item template appears in the Add New Item dialog box.


1 Answers

You should set the CreateInPlace property to true in the vstemplate. The documentation says

Specifies whether to create the project and perform parameter replacement in the specified location, or perform parameter replacement in a temporary location and then save the project to the specified location.

If you want relative paths to work, you need the parameter replacement to occur in the place where you're creating the project, not in a temporary location.

like image 187
Wilhelm Medetz Avatar answered Oct 14 '22 23:10

Wilhelm Medetz