Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multi project template for dotnet new

I am creating a multi-project template, that has a few optional projects and solution folders. I have been through quite a few different documentations and code in github to achieve this, but with very little success. I really appreciate if someone could give me some clarity on some of these questions?

  1. Is VSTemplate xml file still relevant? This blog suggests making changes in the template.json file, however when I check for examples in github, people use VSTemplate to make to create the project, and also SideWaffle plugin still creates the VSTemplate file. If its still relevant, Would like to know how does it differ from the json file?
  2. Using the above VSTemplate I attempted to create a multi project template,using the ProjectCollection tage, when I run the dotnet run command, the template gets executed but the project does not get created.

    <ProjectTemplateLink ProjectName="$safeprojectname$.Forms.Plugin.Abstractions">
      Forms.Plugin.Abstractions\Forms.Plugin.Abstractions.vstemplate
    </ProjectTemplateLink>
    <ProjectTemplateLink ProjectName="$safeprojectname$.Forms.Plugin.iOS">
      Forms.Plugin.iOS\Forms.Plugin.iOS.vstemplate
    </ProjectTemplateLink>
    <ProjectTemplateLink ProjectName="$safeprojectname$.Forms.Plugin.iOSUnified">
      Forms.Plugin.iOSUnified\Forms.Plugin.iOSUnified.vstemplate
    </ProjectTemplateLink>
    <ProjectTemplateLink ProjectName="$safeprojectname$.Forms.Plugin.Android">
      Forms.Plugin.Android\Forms.Plugin.Android.vstemplate
    </ProjectTemplateLink>
    <ProjectTemplateLink ProjectName="$safeprojectname$.Forms.Plugin.WindowsPhone">
      Forms.Plugin.WindowsPhone\Forms.Plugin.WindowsPhone.vstemplate
    </ProjectTemplateLink>
    </ProjectCollection>```
    

Can we create a multi-project template using template.json file?

Would appreciate if anyone can help me get started.

like image 483
Libin Joseph Avatar asked May 20 '19 07:05

Libin Joseph


1 Answers

I have managed to get the multi-project template working by making the changes in the template.json file

this is the final template.json file looks like

This is my updated template.json file

    {
    "author": "Libin Joseph",
    "classifications": ["Xamarin", "Sample"],
    "name": "Sample Enterprise Template",
    "tags": {
        "language": "C#"
    },
    "identity": "libin.sampletemplate",
    "shortName": "sampletemplate",
    "sourceName": "SampleTemplate",
    "guids": [
        "{41F47D3C-C9E4-45D1-A289-3BDC31E44C19}",
        "{980FBE34-066B-4E87-AFC9-C3205844D980}",
        "{FD448FB5-B24B-4CD2-8E3C-2500CF0E4601}",
        "{D8FC665A-7739-4ADE-85E9-C69AA107EEE6}",
        "{92D25D7D-F637-4634-B939-BB38DE53B606}",
        "{5D52EDF7-47B8-48D2-83B6-104B18568CE4}",
        "{12E171B1-0F36-401A-A171-614F1A1C83E9}",
        "{7A4597AE-2C39-4197-94C9-F5B6B45B2106}"

    ],
    "primaryOutputs": [{
            "path": "SampleTemplate\\SampleTemplate.Android\\SampleTemplate.Android.csproj"
        },
        {
            "path": "SampleTemplate\\SampleTemplate.iOS\\SampleTemplate.iOS.csproj"
        },
        {
            "path": "SampleTemplate\\SampleTemplate\\SampleTemplate.csproj"
        },
        {
            "path": "SampleTemplate.UnitTest\\SampleTemplate.UnitTest.csproj"
        },
        {
            "path": "SampleTemplate.UITest\\SampleTemplate.UITest.csproj"
        },
        {
            "path": "SampleTemplate.Core\\SampleTemplate.Core.csproj"
        }
    ],
    "exclude": ["**/[Bb]in/**", "**/[Oo]bj/**", ".template.config/**/*", "**/*.lock.json"]
    }
like image 187
Libin Joseph Avatar answered Nov 06 '22 13:11

Libin Joseph