Visual Studio Custom Project templates

Source: Internet
Author: User

Often we need to create a new project, and then create our view folder, ViewModel folder, model folder, and put our viewmodelbase into our ViewModel, if you still use the framework, but also need to add a lot.

And I usually use nine of the statistics, need to modify a lot of things, every new project to do this, so I feel bad, on the internet to see a custom template, but the garbage Microsoft official said good bad, do not understand, look at the old weeks, or feel that I do not understand, I will come.

We need to open our catalog: C:\Program Files (x86) \microsoft Visual Studio 14.0\common7\ide\projecttemplates\csharp\windows root\ Windows UAP

There are folders inside, generally we open the last one, I don't know you see me this piece, the garbage Microsoft to change it to the maximum how much, so, one to come, I now open 1033, (1033 is the old week blog write) I actually have more later, this if all is the number, chooses the biggest.

We first copy the folder to our user's document or the project location of our own program, and then compress a save, because afraid of the damage

Then we open the file with Visual Studio, remember, to open the. csproj to open it with a file.

Let's open the Blankapplication first blankapplication.vstemplate.

We want to modify is our project contains files TemplateContent is the file that our project contains

We include the project Application.csproj, but after we replaceparameters= "true" we'll replace the things, and I'll talk about them later.

And then there's our project contains files, <projectitem replaceparameters= "true" Targetfilename= "App.xaml" >App.xaml</ProjectItem> We find the App.xaml file locally, and we need to replace it before the App.xaml of the new item is placed, because replaceparameters= "true"

So what are we going to do, we open the App.xaml

See $safeprojectname$ This is what we replace and can be substituted

Parameters

Describe

clrversion

The current version of the common language runtime (CLR).

GUID [1-10]

The GUID used to replace the project GUID in the project file. You can specify up to 10 unique GUIDs (for example, GUID1)).

ItemName

The name provided by the user in the Add New Item dialog box.

MachineName

The current computer name (for example, Computer01).

ProjectName

The name provided by the user in the New Project dialog box.

RegisteredOrganization

The registry key value in the HKLM\Software\Microsoft\Windows Nt\currentversion\registeredorganization.

RootNamespace

The root namespace of the current project. This parameter applies only to project templates.

Safeitemname

The name provided by the user in the Add New Item dialog box, with all unsafe characters and spaces removed from the name.

Safeprojectname

The name provided by the user in the New Project dialog box, with all unsafe characters and spaces removed from the name.

Time

The current time in dd/mm/yyyy 00:00:00 format.

Specificsolutionname

The name of the solution. Specificsolutionname has the name of the solution when the directory for creating the solution is selected. When the "Create solution directory" is not selected,specificsolutionname is empty.

UserDomain

The current user domain.

username

The current user name.

Webnamespace

The name of the current Web site. Use this parameter in a Web forms template to ensure that the class name is unique. If the Web site is located under the root directory of the Web server, this template parameter resolves to the root directory of the Web server.

Year

The current year in YYYY format.

We are adding our files if need be placed in the item's folder, we need <projectitem replaceparameters= "true" Targetfilename= "Properties\assemblyinfo.cs" >AssemblyInfo.cs</ProjectItem> Write a position relative

Finished writing we opened Application.csprojitemgroup is our project file, we need to write our file is compiled or content, we add a lot is compiled

<compile include= "Viewmodel\notifyproperty.cs"/>

If we need a folder with no content in it, we can

    <folder include= "Model\"/>

This saves, replicates C:\Program Files (x86) \microsoft Visual Studio 14.0\common7\ide\projecttemplates\csharp\windows root\windows Uap\2052\blankapplication This position needs to be the same as the location you copied.

Administrator Required

We create a new project if the file is not found, open C:\Program files (x86) \microsoft Visual Studio 14.0\common7\ide\projecttemplatescache The same location, copy the files, Because this is temporary, Visual Studio will read in the folder, generally turn off Visual Studio will be good, but then someone said this is not good, we will manually copy the file


This work is licensed with the knowledge sharing signature-non-commercial use-sharing 4.0 International license agreement in the same way. Welcome to reprint, use, republish, but be sure to keep the article signed Lindesi (including Links: HTTP://BLOG.CSDN.NET/LINDEXI_GD), not for commercial purposes, based on the modified work of this article must be issued with the same license. If you have any questions, please contact me.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.