0

So I have a folder that I would like to convert into a template so that I can quickly create skeletons for apps I want to build in the future.

I have the following folder structure:

App
 |-- web (angular/react/etc - no solution file(s) no project file(s)
 |-- api (C# web api)

I can use dotnet install app to create a template locally to use with dotnet new app -n MyApp

However, I want to be able to use this within Visual Studio.

Documentation I have been reading says that a template is just a zip file. However, dotnet new install does not create a zip file.

Documentation also says that you can use a nupkg file, however you have to use dotnet pack to do this, and dotnet cannot create a nupkg file without a project file.

End goal:

I can use dotnet new app -name MyApp from the CLI OR I can do new > project in Visual Studio and find the template, which will then add all of the files that I have in my app folder, maintaining the folder/file structure, and renaming all of the pertinent folders/files/file content with customized content.

Am I expecting too much of dotnet/Visual Studio/Microsoft?

I have tried adding my app folder as an asset in a VSIX manifest file - but you cannot do that, it has to be a file.

I have tried adding the app folder into a template project, but that blows up because the api folder has a solution and other projects within it and custom usings "cannot be found" (because why would they be if the solution/projects are not meant to be compiled for a template?)

EDIT: For all intents and purposes of my goal, Github does not exist. So the referenced "duplicate" question is completely unrelated.

Acceptance Criteria: To be able to, in Visual Studio 2022, select "File > New > Project..." find my template, containing an "app" folder and an "api" folder - "app" being an angular application that is not wrapped in a C# project/solution, and the api folder containing a C# .Net 4.8 Web Api Solution with multiple projects within it. For completeness purpose, both of these folders will contain folders, files, and file contents with MyCustomName which should all be renamed upon project creation.

10
  • 1
    You're confusing unrelated things. Visual Studio is the editor/IDE, just like JetBrains Rider, VS Code or ... Emacs. VS Code is not a version of Visual Studio and doesn't use the same template. The dotnet SDK tool has nothing at all to do with specific editors nor does it generate templates for them. All IDEs provide support the .NET templates one way or another. Commented Sep 10 at 14:44
  • 1
    You'll find the .NET custom template docs here. They aren't packaged as ZIP files but NuGet packages. There's no need for a csproj file but managing multiple templates is a project in itself. Commented Sep 10 at 14:49
  • 1
    Visual Studio templates on the other hand are specific to the IDE (Visual Studio) and have no relation to the .NET (Core) SDK. Visual Studio came out in 1997, almost 20 years before .NET Core 1.0. They anything the IDE supports - Python, Java, database projects etc. That's what VSIX is about. Those are ZIP files with a certain structure. You'll find the docs for VS templates here. You can create your Python project and use the Export Template wizard to create a new template Commented Sep 10 at 14:55
  • Another difference between the two unrelated template systems is that the .NET (Core) SDK templates run on any OS while Visual Studio templates only run on Windows. Commented Sep 10 at 14:57
  • Right, the primary way of using this is intended to be via visual studio UI. But it appears that VS can't handle just unpacking some files and folders into a location and doing renames, which is weird because I was able to pretty much recreate that using just powershell scripts - but that would be more work for a dev which is what I am trying to eliminate. Commented Sep 10 at 15:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.