Home > Software engineering >  How do I generate a project template within code?
How do I generate a project template within code?

Time:03-14

I'm currently working on an ASP.NET Core Web API. One of my scenarios looks like this: the user selects a certain project type/language. Lets say the user selects Python or C#, meaning the user wants to create a Python or C# project template. Is it possible/is there an easy way to create such a project template within the code or would I have to create all files manually in the code? This is actually simply simulating the scenario when a user wants to create a new project in Visual Studio where he selects a template from the create a new project menu, its just that I want to do this with my own service.

CodePudding user response:

For .NET: I would make use of the dotnet new cli tool, and use the ProcessStartInfo together with the Process.Start.

For Python, I would do the same, but require the intallation of pyscaffold.

CodePudding user response:

You can use an embedded resource which is e.g. a ZIP file that contains all the files you need to make a project. You can then extract the ZIP file in your code. That way you can simply update the ZIP file in case you want to add something or update to a newer version of Visual Studio.

  • Related