dotnet new 的多项目模板
Multi project template for dotnet new
我正在创建一个多项目模板,其中包含一些可选项目和解决方案文件夹。我已经通过 github 中的许多不同文档和代码来实现这一点,但收效甚微。如果有人可以让我澄清其中的一些问题,我真的很感激?
- VSTemplate xml 文件是否仍然相关?
这个blog suggests making changes in the template.json file, however when I check for examples in github,人们使用VSTemplate 来创建项目,而且SideWaffle 插件仍然创建VSTemplate 文件。如果它仍然相关,想知道它与 json 文件有何不同?
使用上面的 VSTemplate 我试图创建一个多项目模板,使用 ProjectCollection 标记,当我 运行 dotnet 运行 命令时,模板被执行但是项目没有被创建。
<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>```
我们可以使用 template.json 文件创建多项目模板吗?
如果有人能帮助我入门,我将不胜感激。
通过在 template.json 文件中进行更改,我已设法使 multi-project 模板正常工作
这是最终的 template.json 文件
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"]
}
我正在创建一个多项目模板,其中包含一些可选项目和解决方案文件夹。我已经通过 github 中的许多不同文档和代码来实现这一点,但收效甚微。如果有人可以让我澄清其中的一些问题,我真的很感激?
- VSTemplate xml 文件是否仍然相关? 这个blog suggests making changes in the template.json file, however when I check for examples in github,人们使用VSTemplate 来创建项目,而且SideWaffle 插件仍然创建VSTemplate 文件。如果它仍然相关,想知道它与 json 文件有何不同?
使用上面的 VSTemplate 我试图创建一个多项目模板,使用 ProjectCollection 标记,当我 运行 dotnet 运行 命令时,模板被执行但是项目没有被创建。
<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>```
我们可以使用 template.json 文件创建多项目模板吗?
如果有人能帮助我入门,我将不胜感激。
通过在 template.json 文件中进行更改,我已设法使 multi-project 模板正常工作
这是最终的 template.json 文件
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"]
}