Added templates for dotnet new.

This commit is contained in:
José Pedro 2018-03-23 23:08:04 +00:00
parent 274fa3e9a5
commit fb2251df65
No known key found for this signature in database
GPG key ID: B8247B9301707B83
13 changed files with 198 additions and 0 deletions

View file

@ -2,6 +2,7 @@
<Import Project="StrongName.targets" />
<Import Project="Templates.targets" Condition="'$(IsTemplatesProject)' == 'True'" />
<Import Project="Tests.targets" Condition="'$(IsTestProject)' == 'True'" />
<Import Project="VSIX.targets" Condition="'$(IsVsixProject)' == 'True'" />

View file

@ -0,0 +1,42 @@
<Project>
<PropertyGroup>
<TargetFramework>netstandard1.0</TargetFramework>
<PackageOutputPath>$(ArtifactsDir)packages\</PackageOutputPath>
<NoBuild>True</NoBuild>
<IncludeBuildOutput>False</IncludeBuildOutput>
</PropertyGroup>
<PropertyGroup>
<PackageInstallationDir>$(UserProfile)\.cosmos\packages\</PackageInstallationDir>
</PropertyGroup>
<ItemGroup>
<Content Include="content\**" Pack="True" PackagePath="content\" />
</ItemGroup>
<Target Name="InstallTemplates" DependsOnTargets="Pack">
<MakeDir Directories="$(PackageInstallationDir)" />
<MSBuild Projects="$(MSBuildProjectFullPath)"
Targets="_GetOutputItemsFromPack">
<Output TaskParameter="TargetOutputs" ItemName="PackageFile" />
</MSBuild>
<ItemGroup>
<PackageFile Remove="@(PackageFile)" Condition="'%(Extension)' != '.nupkg'" />
</ItemGroup>
<PropertyGroup>
<TemplatePackagePath>@(PackageFile)</TemplatePackagePath>
</PropertyGroup>
<Copy SourceFiles="@(TemplatePackagePath)"
DestinationFolder="$(PackageInstallationDir)" />
<Exec Command="dotnet new -i $(PackageInstallationDir)$([System.IO.Path]::GetFilename('$(TemplatePackagePath)'))" />
</Target>
</Project>

View file

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<IsTemplatesProject>True</IsTemplatesProject>
<PackageDescription>Cosmos kernel templates for C#, Visual Basic and F#.
$(CosmosDescription)</PackageDescription>
</PropertyGroup>
</Project>

View file

@ -0,0 +1,14 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "Cosmos",
"classifications": [ "Kernel", "Cosmos" ],
"groupIdentity": "Cosmos.Templates.Kernel",
"identity": "Cosmos.Templates.Kernel.CSharp",
"name": "Cosmos Kernel",
"shortName": "cosmoskernel",
"tags":{
"language": "C#",
"type": "project"
},
"sourceName": "CosmosKernel"
}

View file

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Cosmos.Build" Version="*" NoWarn="NU1604" />
<PackageReference Include="Cosmos.Debug.Kernel" Version="*" NoWarn="NU1604" />
<PackageReference Include="Cosmos.System2" Version="*" NoWarn="NU1604" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Text;
using Sys = Cosmos.System;
namespace CosmosKernel
{
public class Kernel: Sys.Kernel
{
protected override void BeforeRun()
{
Console.WriteLine("Cosmos booted successfully. Type a line of text to get it echoed back.");
}
protected override void Run()
{
Console.Write("Input: ");
var input = Console.ReadLine();
Console.Write("Text typed: ");
Console.WriteLine(input);
}
}
}

View file

@ -0,0 +1,14 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "Cosmos",
"classifications": [ "Kernel", "Cosmos" ],
"groupIdentity": "Cosmos.Templates.Kernel",
"identity": "Cosmos.Templates.Kernel.FSharp",
"name": "Cosmos Kernel",
"shortName": "cosmoskernel",
"tags":{
"language": "F#",
"type": "project"
},
"sourceName": "CosmosKernel"
}

View file

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Kernel.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Cosmos.Build" Version="*" NoWarn="NU1604" />
<PackageReference Include="Cosmos.Debug.Kernel" Version="*" NoWarn="NU1604" />
<PackageReference Include="Cosmos.System2" Version="*" NoWarn="NU1604" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,12 @@
namespace CosmosKernel
open System
type Kernel() =
inherit Cosmos.System.Kernel()
override u.BeforeRun() = (Console.WriteLine("Cosmos booted successfully. Type a line of text to get it echoed back.");)
override u.Run() =
Console.Write("Input: ");
let input = Console.ReadLine();
Console.Write("Text typed: ");
Console.WriteLine(input);

View file

@ -0,0 +1,14 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "Cosmos",
"classifications": [ "Kernel", "Cosmos" ],
"groupIdentity": "Cosmos.Templates.Kernel",
"identity": "Cosmos.Templates.Kernel.VisualBasic",
"name": "Cosmos Kernel",
"shortName": "cosmoskernel",
"tags":{
"language": "VB",
"type": "project"
},
"sourceName": "CosmosKernel"
}

View file

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Cosmos.Build" Version="*" NoWarn="NU1604" />
<PackageReference Include="Cosmos.Debug.Kernel" Version="*" NoWarn="NU1604" />
<PackageReference Include="Cosmos.System2" Version="*" NoWarn="NU1604" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,23 @@
Imports System
Imports System.Collections.Generic
Imports System.Text
Namespace CosmosKernel
Public Class Kernel
Inherits Cosmos.System.Kernel
Protected Overrides Sub BeforeRun()
Console.WriteLine("Cosmos booted successfully. Type a line of text to get it echoed back.")
End Sub
Protected Overrides Sub Run()
Console.Write("Input: ")
Dim input = Console.ReadLine()
Console.Write("Text typed: ")
Console.WriteLine(input)
End Sub
End Class
End Namespace

View file

@ -0,0 +1,3 @@
@echo off
dotnet msbuild Cosmos.Templates.Kernel\Cosmos.Templates.Kernel.csproj /t:InstallTemplates