Poma
Poma

Reputation: 8484

How to generate unique id for each instance of C# project template?

I want to develop a C# template for visual studio. I need to assign a different GUID for each project generated with this template (it should remain the same for multiple builds of the same project). I believe there is already some mechanism to do that ([assembly: Guid] attribute or project guid I don't know). So what is the correct way to do that?

Upvotes: 0

Views: 2717

Answers (1)

Hans Passant
Hans Passant

Reputation: 941873

Navigate to the VS install directory, then drill into Common7\IDE\ProjectTemplates\CSharp\Windows\1033\ClassLibrary.zip. You'll find the template version of assemblyinfo.cs there. Copy that to your own template .zip file. Note that 1033 is English, it may a different code page on yours.

The relevant line in the file is

 [assembly: Guid("$guid1$")]

The IDE replaces the parts of the file between $dollars$ with an appropriate substitution when you create a project from your template. Template parameters are documented here.

Upvotes: 3

Related Questions