I have a Web API project which have some classes for exception handling, response formats and other handlers. Also, I have reference to 2 class libraries(Business and DAL layer).
I create this solution repeatedly for different projects. How can I automate this process to create the solution which have a Web API project with some classes, 2 class libraries.
I did some research and saw I can create project templates. But I did not find good article for my task.
If anyone can help me with some direction towards solving it.
{
Type type = Type.GetTypeFromProgID("VisualStudio.DTE.11.0");
var visualStudio = Activator.CreateInstance(type, true);
var dte = visualStudio.Instance;
var solution = (Solution2)dte.Solution;
solution.Create(destinationFolder, solutionName);
string templateFile = solution.GetProjectTemplate(applicationProjectTemplateName);
var project = solution.AddProjectFromTemplate(projectName, DestinationFolder, templateFile);
visualStudio.SaveAll();
}
I found above code which I can use but I dont understand
Solution2, and "applicationProjectTemplateName" parameter value in following:
According to your description, you could use the feature of export template in visual studio to implement it, and then use visual studio package to package the template, after above, you could generate a file of VSIX install, then you could use it to install
your template on any computers.
Here has example, you could refer to the following link.
Member
73 Points
43 Posts
How to automate the process of creating new project in Visual Studio?
Jun 01, 2017 09:02 AM|Rajesh Mishra|LINK
I have a Web API project which have some classes for exception handling, response formats and other handlers. Also, I have reference to 2 class libraries(Business and DAL layer).
I create this solution repeatedly for different projects. How can I automate this process to create the solution which have a Web API project with some classes, 2 class libraries.
I did some research and saw I can create project templates. But I did not find good article for my task.
If anyone can help me with some direction towards solving it.
I found above code which I can use but I dont understand
Solution2, and "applicationProjectTemplateName" parameter value in following:
Rajesh Mishra
Senior Development Engineer
All-Star
194524 Points
28081 Posts
Moderator
Re: How to automate the process of creating new project in Visual Studio?
Jun 01, 2017 09:34 AM|Mikesdotnetting|LINK
Try this: https://docs.microsoft.com/en-gb/visualstudio/ide/how-to-create-project-templates
Member
520 Points
286 Posts
Re: How to automate the process of creating new project in Visual Studio?
Jun 02, 2017 06:09 AM|EvenMa|LINK
Hi Rajesh Mishra,
According to your description, you could use the feature of export template in visual studio to implement it, and then use visual studio package to package the template, after above, you could generate a file of VSIX install, then you could use it to install your template on any computers.
Here has example, you could refer to the following link.
https://www.codeproject.com/Articles/657765/Project-Template-in-Visual-Studio
If you have any other questions, please feel free to contact me any time.
Best Regards
Even