2017-03-17 2 views
0

클래스 이름이 사용자가 제공 한 프로젝트 이름과 일치하도록 프로젝트 템플릿을 만들려고합니다.VS 프로젝트 템플릿의 클래스 이름 변경

내 클래스는 (수출 ProjectTemplate에서)으로 정의된다 : 내 프로젝트 이름이 ABCProj입니다

namespace $safeprojectname$.ViewModels 
{ 
    [Export("$safeprojectname$.ViewModels.TestClassViewModel ",typeof(ContentPaneViewModel))] 
    [PartCreationPolicy(CreationPolicy.NonShared)] 
    public class TestClassViewModel : ContentPaneViewModel 
    { 
     [ImportingConstructor] 
     public TestClassViewModel ([Import("$safeprojectname$.Views.TestClassView")]IView theView) 
     { 
      View = theView; 
      View.ViewModel = this; 
     } 
    } 
} 

경우에, 나는 TestClassViewModel가 ABCProjViewModel로 만들려. 이를 달성하기 위해 프로젝트 템플릿의 클래스 파일을 다음과 같이 업데이트했습니다.

namespace $safeprojectname$.ViewModels 
{ 
    [Export("$safeprojectname$.ViewModels.$safeprojectname$",typeof(ContentPaneViewModel))] 
    [PartCreationPolicy(CreationPolicy.NonShared)] 
    public class $safeprojectname$: ContentPaneViewModel 
    { 
     [ImportingConstructor] 
     public $safeprojectname$([Import("$safeprojectname$.Views.TestClassView")]IView theView) 
     { 
      View = theView; 
      View.ViewModel = this; 
     } 
    } 
} 

변경 사항을 저장하고 프로젝트 템플릿 zip 파일을 다시 만들었습니다. 그러나이 템플릿을 사용하여 프로젝트를 만들었을 때 TestClassViewModel 클래스 이름을 얻었습니다.

내가 여기서 잘못하고있는 것은 무엇입니까?

감사합니다, 나는 그것을하는 더 나은 방법을 알아 낸

답변

0

RDV :

1. Install visual studio extensibility tools for creating templates. 
2. Create Project & Item templates separately. 
3. In Project template just create folders, references, and resource dictionary, if any. 
4. Create class files in item template 
5. Make sure when putting a variable like $safeitemname$ or $projectname$, make sure .vstemplate & project.csproj has the same filename. 

감사합니다,

RDV

관련 문제