Visual Studio project template contained in, and limited to, specific solution

TheHvidsten 0 Reputation points
2024-04-17T12:03:45.8033333+00:00

I have a solution where certain rules needs to be applied to certain projects. This makes it perfect to be "templatized".
However, I only want the template to be available to this specific solution, so I don't want to have it installed in C:\Users\Whomever\Documents\Visual Studio yyyy\Templates as the each user will then have to manually install the template. The template should be contained in the source control repo, so it needs to be tightly bound to this specific solution (without necessarilly having to reside in the same folder as the .sln file). That way the users should all get it automatically.

It would also be very nice if the template could also be "bound" to a specific solution folder so that the template only shows up when users try to create a new project in the solution folder.

I have already created a project template using the Project > Export Template... wizard, so that's not a part of the question.

I found a suggestion of adding this to the .sln file:

GlobalSection(SolutionProperties) = preSolution
    CustomTemplatePath = ProjectTemplates
EndGlobalSection

Where ProjectTemplates is the name of a folder in the same location as the .sln file, and this folder contains the template ZIP file. This had no effect (the template didn't show up in Add > New Project...)

Is this even possible? If it is, then how can it be done?

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,614 questions
{count} votes