我自己的解决方案模板Visual Studio 2017 xamarin

时间:2017-12-19 10:15:45

标签: visual-studio templates xamarin

我尝试为xamarin表单创建自己的解决方案模板,因此我有3个项目:Main,droid和iOS。我创建了3个模板:project - >导出模板,在此之后我有3个文件夹和一个主要的vstemplate文件。

enter image description here

和vstemplate文件:

<VSTemplate Version="3.0.0"  xmlns="http://schemas.microsoft.com/developer/vstemplate/2005"  Type="Project">
<TemplateData>
<Name>SimpleCoreTest</Name>
<Description>My template</Description>
<ProjectType>CSharp</ProjectType>
<ProjectSubType>
</ProjectSubType>
<SortOrder>1000</SortOrder>
<CreateNewFolder>true</CreateNewFolder>
<DefaultName>SimpleCoreTest</DefaultName>
<ProvideDefaultName>true</ProvideDefaultName>
<LocationField>Enabled</LocationField>
<EnableLocationBrowseButton>true</EnableLocationBrowseButton>
<Icon>__TemplateIcon.ico</Icon>
</TemplateData>
<TemplateContent>
<ProjectCollection>
    <ProjectTemplateLink ProjectName="$projectname$">
        SimpleCoreTest\SimpleCoreTest.vstemplate
    </ProjectTemplateLink>
    <ProjectTemplateLink ProjectName="$projectname$.Droid">
        SimpleCoreTest.Droid\SimpleCoreTest.vstemplate
    </ProjectTemplateLink>
    <ProjectTemplateLink ProjectName="$projectname$.iOS">
        SimpleCoreTest.iOS\SimpleCoreTest.vstemplate
    </ProjectTemplateLink>
</ProjectCollection>
</TemplateContent>
</VSTemplate>

这是droid项目,但iOS和主要看起来相似:

enter image description here

<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005"   Type="Project">
<TemplateData>
<Name>SimpleCoreTest.Droid</Name>
<Description>simple core droid</Description>
<ProjectType>CSharp</ProjectType>
<ProjectSubType>
</ProjectSubType>
<SortOrder>1000</SortOrder>
<CreateNewFolder>true</CreateNewFolder>
<DefaultName>SimpleCoreTestDroid</DefaultName>
<ProvideDefaultName>true</ProvideDefaultName>
<LocationField>Enabled</LocationField>
<EnableLocationBrowseButton>true</EnableLocationBrowseButton>
<Icon>__TemplateIcon.ico</Icon>
</TemplateData>
<TemplateContent>
<Project TargetFileName="SimpleCoreTest.Droid.csproj"   File="SimpleCoreTest.Droid.csproj" ReplaceParameters="true">
  <ProjectItem ReplaceParameters="true"   TargetFileName="AndroidBug5497WorkaroundForXamarinAndroid.cs">AndroidBug549  7WorkaroundForXamarinAndroid.cs</ProjectItem>
  <Folder Name="Assets" TargetFolderName="Assets">
    <ProjectItem ReplaceParameters="true"   TargetFileName="AboutAssets.txt">AboutAssets.txt</ProjectItem>
  </Folder>
  <Folder Name="Helpers" TargetFolderName="Helpers">
    <ProjectItem ReplaceParameters="true"   TargetFileName="Settings.cs">Settings.cs</ProjectItem>
  </Folder>
  <ProjectItem ReplaceParameters="true"   TargetFileName="MainActivity.cs">MainActivity.cs</ProjectItem>
  <ProjectItem ReplaceParameters="true" TargetFileName="packages.config">packages.config</ProjectItem>
  <Folder Name="Properties" TargetFolderName="Properties">
    <ProjectItem ReplaceParameters="true" TargetFileName="AndroidManifest.xml">AndroidManifest.xml</ProjectItem>
    <ProjectItem ReplaceParameters="true" TargetFileName="AssemblyInfo.cs">AssemblyInfo.cs</ProjectItem>
  </Folder>
  <Folder Name="Resources" TargetFolderName="Resources">
    <ProjectItem ReplaceParameters="true" TargetFileName="AboutResources.txt">AboutResources.txt</ProjectItem>
    <Folder Name="drawable" TargetFolderName="drawable">
      <ProjectItem ReplaceParameters="false" TargetFileName="hamburger.png">hamburger.png</ProjectItem>
      <ProjectItem ReplaceParameters="false" TargetFileName="icon.png">icon.png</ProjectItem>
      <ProjectItem ReplaceParameters="false"  TargetFileName="login_simple_image.png">login_simple_image.png</ProjectItem >
      <ProjectItem ReplaceParameters="false" TargetFileName="schedule.png">schedule.png</ProjectItem>
    </Folder>
    <Folder Name="drawable-hdpi" TargetFolderName="drawable-hdpi">
      <ProjectItem ReplaceParameters="false" TargetFileName="icon.png">icon.png</ProjectItem>
    </Folder>
    <Folder Name="drawable-xhdpi" TargetFolderName="drawable-xhdpi">
      <ProjectItem ReplaceParameters="false" TargetFileName="icon.png">icon.png</ProjectItem>
    </Folder>
    <Folder Name="drawable-xxhdpi" TargetFolderName="drawable-xxhdpi">
      <ProjectItem ReplaceParameters="false" TargetFileName="icon.png">icon.png</ProjectItem>
    </Folder>
    <Folder Name="layout" TargetFolderName="layout">
      <ProjectItem ReplaceParameters="false" TargetFileName="Tabbar.axml">Tabbar.axml</ProjectItem>
      <ProjectItem ReplaceParameters="false" TargetFileName="Toolbar.axml">Toolbar.axml</ProjectItem>
    </Folder>
    <ProjectItem ReplaceParameters="true" TargetFileName="Resource.designer.cs">Resource.designer.cs</ProjectItem>
    <Folder Name="values" TargetFolderName="values">
      <ProjectItem ReplaceParameters="true" TargetFileName="styles.xml">styles.xml</ProjectItem>
    </Folder>
  </Folder>
</Project>
</TemplateContent>
</VSTemplate>

我将这3个文件夹和主要的vsTemplate文件放到一个zip文件夹中并将其放在模板文件夹中。当我想创建新项目时,我看到了这个模板,但在设置了名称并单击确定后,我获得了创建新项目成功完成的信息。没有别的。我的文件夹中没有这个项目的解决方案。你知道我做错了什么吗?

===== EDIT =====

好的,我知道我做错了什么。在我的vstemplate文件中,我必须写:

Type="ProjectGroup"

Type="Project"

0 个答案:

没有答案