Add dotnet-init

This commit is contained in:
Krzysztof Wicher 2015-11-17 11:40:07 -08:00
parent 1c6087b8e1
commit b566be5de8
7 changed files with 234 additions and 35 deletions

View file

@ -54,6 +54,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.DotNet.Tools.Run"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Dotnet.Cli.Compiler.Common", "src\Microsoft.DotNet.Compiler.Common\Microsoft.Dotnet.Cli.Compiler.Common.xproj", "{A16958E1-24C7-4F1E-B317-204AD91625DD}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.DotNet.Tools.Init", "src\Microsoft.DotNet.Tools.Init\Microsoft.DotNet.Tools.Init.xproj", "{BC765FBF-AD7A-4A99-9902-5540C5A74181}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -146,6 +148,38 @@ Global
{B559378C-FC03-45FA-893C-71784F28E0A2}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{B559378C-FC03-45FA-893C-71784F28E0A2}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{B559378C-FC03-45FA-893C-71784F28E0A2}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.Debug|x64.ActiveCfg = Debug|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.Debug|x64.Build.0 = Debug|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.MinSizeRel|Any CPU.ActiveCfg = Release|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.MinSizeRel|Any CPU.Build.0 = Release|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.MinSizeRel|x64.ActiveCfg = Release|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.MinSizeRel|x64.Build.0 = Release|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.Release|Any CPU.Build.0 = Release|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.Release|x64.ActiveCfg = Release|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.Release|x64.Build.0 = Release|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.Debug|Any CPU.Build.0 = Debug|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.Debug|x64.ActiveCfg = Debug|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.Debug|x64.Build.0 = Debug|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.MinSizeRel|x64.Build.0 = Debug|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.Release|Any CPU.ActiveCfg = Release|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.Release|Any CPU.Build.0 = Release|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.Release|x64.ActiveCfg = Release|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.Release|x64.Build.0 = Release|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
{585FC6F6-48E0-4EA5-8015-0264614E97C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{585FC6F6-48E0-4EA5-8015-0264614E97C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{585FC6F6-48E0-4EA5-8015-0264614E97C0}.Debug|x64.ActiveCfg = Debug|Any CPU
@ -178,22 +212,6 @@ Global
{303677D5-7312-4C3F-BAEE-BEB1A9BD9FE6}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{303677D5-7312-4C3F-BAEE-BEB1A9BD9FE6}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{303677D5-7312-4C3F-BAEE-BEB1A9BD9FE6}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.Debug|x64.ActiveCfg = Debug|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.Debug|x64.Build.0 = Debug|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.MinSizeRel|Any CPU.ActiveCfg = Release|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.MinSizeRel|Any CPU.Build.0 = Release|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.MinSizeRel|x64.ActiveCfg = Release|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.MinSizeRel|x64.Build.0 = Release|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.Release|Any CPU.Build.0 = Release|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.Release|x64.ActiveCfg = Release|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.Release|x64.Build.0 = Release|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
{8DF8403E-0DDC-4E6C-9930-4C1006E96B2F}.Debug|Any CPU.ActiveCfg = Debug|x64
{8DF8403E-0DDC-4E6C-9930-4C1006E96B2F}.Debug|x64.ActiveCfg = Debug|x64
{8DF8403E-0DDC-4E6C-9930-4C1006E96B2F}.Debug|x64.Build.0 = Debug|x64
@ -262,22 +280,22 @@ Global
{A16958E1-24C7-4F1E-B317-204AD91625DD}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{A16958E1-24C7-4F1E-B317-204AD91625DD}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{A16958E1-24C7-4F1E-B317-204AD91625DD}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.Debug|Any CPU.Build.0 = Debug|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.Debug|x64.ActiveCfg = Debug|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.Debug|x64.Build.0 = Debug|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.MinSizeRel|x64.Build.0 = Debug|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.Release|Any CPU.ActiveCfg = Release|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.Release|Any CPU.Build.0 = Release|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.Release|x64.ActiveCfg = Release|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.Release|x64.Build.0 = Release|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
{BC765FBF-AD7A-4A99-9902-5540C5A74181}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BC765FBF-AD7A-4A99-9902-5540C5A74181}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BC765FBF-AD7A-4A99-9902-5540C5A74181}.Debug|x64.ActiveCfg = Debug|Any CPU
{BC765FBF-AD7A-4A99-9902-5540C5A74181}.Debug|x64.Build.0 = Debug|Any CPU
{BC765FBF-AD7A-4A99-9902-5540C5A74181}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU
{BC765FBF-AD7A-4A99-9902-5540C5A74181}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU
{BC765FBF-AD7A-4A99-9902-5540C5A74181}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU
{BC765FBF-AD7A-4A99-9902-5540C5A74181}.MinSizeRel|x64.Build.0 = Debug|Any CPU
{BC765FBF-AD7A-4A99-9902-5540C5A74181}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BC765FBF-AD7A-4A99-9902-5540C5A74181}.Release|Any CPU.Build.0 = Release|Any CPU
{BC765FBF-AD7A-4A99-9902-5540C5A74181}.Release|x64.ActiveCfg = Release|Any CPU
{BC765FBF-AD7A-4A99-9902-5540C5A74181}.Release|x64.Build.0 = Release|Any CPU
{BC765FBF-AD7A-4A99-9902-5540C5A74181}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
{BC765FBF-AD7A-4A99-9902-5540C5A74181}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{BC765FBF-AD7A-4A99-9902-5540C5A74181}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{BC765FBF-AD7A-4A99-9902-5540C5A74181}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -289,15 +307,16 @@ Global
{391D6AD6-0FD5-4E1E-A4C8-6B5439D197B5} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
{07731125-77D7-4B83-B7B2-C865C6B8A6E8} = {13F8C30C-1011-459C-82B2-0ACDD73EDA18}
{B559378C-FC03-45FA-893C-71784F28E0A2} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
{717A4ED9-8897-492F-BD0C-230FCAEA9237} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
{585FC6F6-48E0-4EA5-8015-0264614E97C0} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
{303677D5-7312-4C3F-BAEE-BEB1A9BD9FE6} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
{C0CA389D-A35E-4082-BC05-598C9D6301BC} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
{8DF8403E-0DDC-4E6C-9930-4C1006E96B2F} = {C0CA389D-A35E-4082-BC05-598C9D6301BC}
{3673DD4B-F7D3-40A1-A756-F8354A5B74CD} = {C0CA389D-A35E-4082-BC05-598C9D6301BC}
{5D67FC6A-6392-4807-97BC-D13CA0FF5E6D} = {C0CA389D-A35E-4082-BC05-598C9D6301BC}
{1C16108C-C786-482D-BB0A-36BDAFE109ED} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
{A16958E1-24C7-4F1E-B317-204AD91625DD} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
{717A4ED9-8897-492F-BD0C-230FCAEA9237} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
{BC765FBF-AD7A-4A99-9902-5540C5A74181} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
EndGlobalSection
EndGlobal

View file

@ -18,7 +18,8 @@ $Projects = @(
"Microsoft.DotNet.Tools.Pack",
"Microsoft.DotNet.Tools.Publish",
"Microsoft.DotNet.Tools.Resgen",
"Microsoft.DotNet.Tools.Run"
"Microsoft.DotNet.Tools.Run",
"Microsoft.DotNet.Tools.Init"
)
$BinariesForCoreHost = @(

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>bc765fbf-ad7a-4a99-9902-5540c5a74181</ProjectGuid>
<RootNamespace>Microsoft.DotNet.Tools.Init</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

View file

@ -0,0 +1,98 @@
using Microsoft.Dnx.Runtime.Common.CommandLine;
using Microsoft.DotNet.Cli.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
namespace Microsoft.DotNet.Tools.Init
{
public class Program
{
private static string GetFileNameFromResourceName(string s)
{
// A.B.C.D.filename.extension
string[] parts = s.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
if (parts.Length < 2)
{
return null;
}
// filename.extension
return parts[parts.Length - 2] + "." + parts[parts.Length - 1];
}
public int CreateEmptyProject()
{
var thisAssembly = typeof(Program).GetTypeInfo().Assembly;
var resources = from resourceName in thisAssembly.GetManifestResourceNames()
where resourceName.ToLowerInvariant().EndsWith(".cs") || resourceName.ToLowerInvariant().EndsWith(".json")
select resourceName;
Dictionary<string, string> resourceNameToFileName = new Dictionary<string, string>();
bool hasFilesToOverride = false;
foreach (string resourceName in resources)
{
string fileName = GetFileNameFromResourceName(resourceName);
resourceNameToFileName.Add(resourceName, fileName);
if (File.Exists(fileName))
{
Console.WriteLine("Creating new project would override file {0}.", fileName);
hasFilesToOverride = true;
}
}
if (hasFilesToOverride)
{
Console.WriteLine("Creating new project failed.");
return 1;
}
foreach (var kv in resourceNameToFileName)
{
using (var fileStream = File.Create(kv.Value))
{
using (var resource = thisAssembly.GetManifestResourceStream(kv.Key))
{
resource.CopyTo(fileStream);
}
}
}
Console.WriteLine("Created new project in {0}.", Directory.GetCurrentDirectory());
return 0;
}
public static int Main(string[] args)
{
DebugHelper.HandleDebugSwitch(ref args);
var app = new CommandLineApplication();
app.Name = "dotnet init";
app.FullName = ".NET Initializer";
app.Description = "Initializes empty project for .NET Platform";
app.HelpOption("-h|--help");
var dotnetInit = new Program();
app.OnExecute((Func<int>)dotnetInit.CreateEmptyProject);
try
{
return app.Execute(args);
}
catch (Exception ex)
{
#if DEBUG
Console.Error.WriteLine(ex);
#else
Console.Error.WriteLine(ex.Message);
#endif
return 1;
}
}
}
}

View file

@ -0,0 +1,12 @@
using System;
namespace ConsoleApplication
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}

View file

@ -0,0 +1,18 @@
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.NETCore.Runtime": "1.0.1-beta-23428",
"System.IO": "4.0.11-beta-23428",
"System.Console": "4.0.0-beta-23428",
"System.Runtime": "4.0.21-beta-23428",
"System.Diagnostics.Process": "4.1.0-beta-23428"
},
"frameworks": {
"dnxcore50": { }
}
}

View file

@ -0,0 +1,32 @@
{
"name" : "dotnet-init",
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.NETCore.Runtime": "1.0.1-beta-23504",
"System.Console": "4.0.0-beta-23504",
"System.Collections": "4.0.11-beta-23504",
"System.Linq": "4.0.1-beta-23504",
"System.Diagnostics.Process": "4.1.0-beta-23504",
"System.IO.FileSystem": "4.0.1-beta-23504",
"System.AppContext": "4.0.1-beta-23504",
"Microsoft.DotNet.ProjectModel": "1.0.0-*",
"Microsoft.DotNet.Cli.Utils": {
"type": "build",
"version": "1.0.0-*"
},
"Microsoft.Extensions.CommandLineUtils.Sources": {
"type": "build",
"version": "1.0.0-*"
}
},
"compileExclude": [ "Template/**" ],
"resource": [ "Template/**" ],
"frameworks": {
"dnxcore50": { }
}
}