Quantcast
Channel: Visual Studio and Visual Web Developer Express
Viewing all articles
Browse latest Browse all 3509

How to automate the process of creating new project in Visual Studio?

$
0
0

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:

solution.GetProjectTemplate(applicationProjectTemplateName);

Viewing all articles
Browse latest Browse all 3509

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>