简体   繁体   中英

Visual Studio- custom project templates

I want to create a custom project templates in Visual Studio. As the template will have the conditional parameters, I can't use new do.net templates (it only works in terminal, but I want to have a visual form of the template). How could I create the project template with the textfields, conditional parameters and two steps form? It will be a complex project template form and after completing the form I want to get the specific folder with text files inside (without solution project, just a folder with files).

I started creating a custom project templates, but what I get is a folder with solution project. But I want only a folder with the files (not any.csproj file). Is it because of a tag: <ProjectType>Csharp</ProjectType> in.vstemplate?

According to your requirements, it is recommended that you use the way of generating packages with NuGet. Proceed as follows:

  1. Create the Content\GMSTemplate directory under the root directory GMS, and copy the template files and folders into it

  2. The template.json file is modified to:

     { "$schema": "http://json.schemastore.org/template", "author": "5DThinking", "classifications": [ "WinForm" ], "name": "5DThinking WinForm GMS v1.0", "identity": "GMS.WinForm.1.0.Template", "shortName": "gms1.0", "tags": { "language": "C#", "type":"project" }, "sourceName": "Thinking.GMS", "preferNameDirectory": true }
  3. Create a GMSTemplate.nuspec file in the GMS directory with the following content:

     <?xml version="1.0" encoding="utf-8"?> <package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd"> <metadata> <id>GMSTemplate</id> <version>1.0.1</version> <description> GMS(General Management System) For WinForm </description> <authors>5DThinking</authors> <packageTypes> <packageType name="Template" /> </packageTypes> </metadata> </package>
  4. Package with NuGet, execute the command nuget pack GMSTemplate.nuspec -OutputDirectory. in the GMS directory, and then generate the GMSTemplate.1.0.1.nupkg file

  5. Create a CreateYourProject.bat file in the GMS directory, the content is as follows:

     color 4 do.net new -i GMSTemplate.1.0.1.nupkg set /p OP=Please set your project name(for example:Baidu.Api): md.1YourProject cd.1YourProject do.net new gms1.0 -n %OP% cd../ echo "Create Successfully.!!! ^ please see the folder .1YourProject" do.net new -u GMSTemplate echo "Delete Template Successfully" pause
  6. Double-click to execute the CreateYourProject.bat file, follow the prompts to enter the new project name, and you're done.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM