From 87f841f2db713590cb58e42eab8570109cb33209 Mon Sep 17 00:00:00 2001 From: Christoph Perger Date: Thu, 14 May 2020 15:25:28 +0200 Subject: [PATCH] Added Xamarin Forms Shell template --- README.md | 3 ++- docs/icon.png | Bin 0 -> 2481 bytes src/FocusInit/DotnetCliHelper.cs | 20 ++++++++++++++ src/FocusInit/FocusInit.csproj | 45 +++++++++++++++++-------------- src/FocusInit/Program.cs | 37 +++++++++++++++---------- 5 files changed, 70 insertions(+), 35 deletions(-) create mode 100644 docs/icon.png diff --git a/README.md b/README.md index 84b2db5..02f12fe 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,11 @@ # Spatial Focus initialize project wizard +[![Nuget](https://img.shields.io/nuget/v/SpatialFocus.FocusInit)](https://www.nuget.org/packages/SpatialFocus.FocusInit/) ## Install the dotnet tool ``` -dotnet tool install --global SpatialFocus.FocusInit --version 0.1.1 +dotnet tool install --global SpatialFocus.FocusInit --version 0.2.0 ``` Install the tool globally. You can invoke the tool using the following command: `focus-init` diff --git a/docs/icon.png b/docs/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..b46c2805635504aed3dda7b93facad8e429fd5b2 GIT binary patch literal 2481 zcmV;i2~PHjP)003M>0c&c2$N&HU8FWQhbW?9;ba!ELWdLwtX>N2bZe?^J zG%heMGBNQWX_Wu~2`))QK~#8N-CGM#RM#2CG;LFrUBE^(K9Z(09W&`;I_=b^nMv9- zohHp>I#ZJvYfN7z)<)%Ckobsp>m<=OQKOA9A)?&7D~n=%6(3kZ0vHp(2M-NscvN(? zC;?PJVA(zW|C@g&m%V52-rc>sfZxnF3+(;R`M>|1d;asEdx;y0m?&=lnpKovu!>T? zMUb1}^AhkF{JeZrntd!?cI&}9H#^ZHNK37P)B*uuJX%D#!;&J+Ad_1INuo3Xgs+AX zzRnY^p&)tV1$h>k4_}N<&6)zjH-n&Fu23CvgAeOsNM)k5OfQw0PC;5o-47m;<~t_BXs-d@;5r#aLZ7a<`Rl(* zuEZ9jQ{?+#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j+)jWIaf7wSX<@!#pG8IH=**7oLV`-A~4|@c5hl3CRZ(^GL+ayj#f`3O0KF z<~vET772os;=35PxLEr?$f@Ll5o>ro)CEbeW^RQ138nIKlB-2>ntc>ZldE{(as0nm z6=!f;JU9D`lN=+&Lr*=_w_Ky2_=su%MCk;{+4>xx08Gs0GthP71ZcffVdcb)X+i}d}IeXbcyZ^kh@4~V7NV= z_2df|@V)XN!od&_^eM4Q4T;A$qbC{ZZ;WaK_B^JD)3nz z9%kwxngIa5PBQi3c6(&<$5h~qiDfygCM;l#ffP8M-#h=)a&*o&8DzC;Y+f$)bg_z!cx^|yZHv8MC z8N~q9LDe_g?Dq#p!2NTQ(^=RwJph7SW)-uhMeUV2Ts^rRhe?wH;I)cUKJaJcW)$&s z?w26S^&BU{VnhMJXBmQ&V@;L6Pu|4_uo%waIur)O2>{%N-7p9n@qrGx6l2)3?f?fa z`#Tm6LkR!`z70NKAGKgpGI=t10B08Y9E*fT0syJ(B24v#L+bwm5*KAy!LbgWs8FaE z0N8$?-Coh~r#M^gSE$>e1z2@g@kE6}UI0LNx!diY20upo?eEAia$(juSPQuC78s>3 z0Qe3O2tNeEAED-l2dtv~U7j$boV3IV)wX9_Z?8ADsmv@Sq;0($kCu4i^!RxylisnW z*}w65OT!omqVznh2bxFgJc95xxNTm&<^BoUBHEt?aRIXeq|FPkV@n-UsmyHPlNJcV vQV?4LDY6+p8{qcXn~)+sKQvQWT-^Twdp3xf3ORyP00000NkvXXu0mjfoNb~Y literal 0 HcmV?d00001 diff --git a/src/FocusInit/DotnetCliHelper.cs b/src/FocusInit/DotnetCliHelper.cs index 3d5e7ec..82ed80a 100644 --- a/src/FocusInit/DotnetCliHelper.cs +++ b/src/FocusInit/DotnetCliHelper.cs @@ -36,6 +36,18 @@ public void AddReferenceToProject(string projectPath, string referenceProjectPat process.WaitForExit(3000); } + public string CreateMultiProject(string type) + { + string srcFolder = !string.IsNullOrEmpty(WorkDir) ? WorkDir + "/src" : "src"; + + string createProjectCmd = $"new {type} -n {SolutionName} -o {srcFolder}"; + Process process = Process.Start("dotnet", createProjectCmd); + + process.WaitForExit(3000); + + return $"{srcFolder}/{SolutionName}"; + } + public string CreateProject(string type, string projectSuffix) { string srcFolder = !string.IsNullOrEmpty(WorkDir) ? WorkDir + "/src" : "src"; @@ -47,5 +59,13 @@ public string CreateProject(string type, string projectSuffix) return $"{srcFolder}/{SolutionName}.{projectSuffix}"; } + + public void InstallCustomProjectTemplate(string type) + { + string installTemplateCmd = $"new -i {type}"; + Process process = Process.Start("dotnet", installTemplateCmd); + + process.WaitForExit(3000); + } } } \ No newline at end of file diff --git a/src/FocusInit/FocusInit.csproj b/src/FocusInit/FocusInit.csproj index 37e02d8..59fca21 100644 --- a/src/FocusInit/FocusInit.csproj +++ b/src/FocusInit/FocusInit.csproj @@ -1,36 +1,41 @@  - - Exe - netcoreapp3.1 + + Exe + netcoreapp3.1 - true - focus-init - ./nupkg + true + focus-init + ./nupkg - 0.1.1 + 0.2.0 SpatialFocus.FocusInit Spatial Focus initialize project wizard DotNet Tool for initializing an empty folder, create a solution with stylecop, ReSharper and license settings, and optionally add projects. tool, scaffolding, code-style, code-quality - https://github.com/SpatialFocus/SpatialFocus.FocusInit - MIT + https://github.com/SpatialFocus/FocusInit + icon.png + MIT git - https://github.com/SpatialFocus/SpatialFocus.FocusInit.git + https://github.com/SpatialFocus/FocusInit.git pergerch,Dresel SpatialFocus True - + - - - - - + + + + + - - - - + + + + + + + + diff --git a/src/FocusInit/Program.cs b/src/FocusInit/Program.cs index 1970ba2..91c88dc 100644 --- a/src/FocusInit/Program.cs +++ b/src/FocusInit/Program.cs @@ -64,49 +64,58 @@ private static void CreateProjects(string solutionName) Console.WriteLine(" 2) Empty web"); Console.WriteLine(" 3) Web API"); Console.WriteLine(" 4) Web MVC"); - Console.WriteLine(" 5) Xamarin Forms Shell (coming soon)"); + Console.WriteLine(" 5) Xamarin Forms Shell"); Console.WriteLine(" 6) Blazor Server"); Console.WriteLine(" 7) Blazor Wasm"); i = Prompt.GetInt("Select project type", null, ConsoleColor.DarkCyan); } while (i <= 0 || i > 7); - List createdProjects = new List(); + List projectsToReference = new List(); switch (i) { case 1: string consoleProject = cliHelper.CreateProject("console", "Console"); cliHelper.AddProjectToSolution(consoleProject); - createdProjects.Add(consoleProject); + projectsToReference.Add(consoleProject); break; case 2: string emptyWebProject = cliHelper.CreateProject("web", "Web"); cliHelper.AddProjectToSolution(emptyWebProject); - createdProjects.Add(emptyWebProject); + projectsToReference.Add(emptyWebProject); break; case 3: string webApiProject = cliHelper.CreateProject("webapi", "Web"); cliHelper.AddProjectToSolution(webApiProject); - createdProjects.Add(webApiProject); + projectsToReference.Add(webApiProject); break; case 4: string mvcProject = cliHelper.CreateProject("mvc", "Web"); cliHelper.AddProjectToSolution(mvcProject); - createdProjects.Add(mvcProject); + projectsToReference.Add(mvcProject); break; case 5: - // TODO - return; + // Make sure the Xamarin Forms Shell template is installed + cliHelper.InstallCustomProjectTemplate("SpatialFocus.DotNetNew.XamarinFormsShell::0.1.2"); + + string xfShellProject = cliHelper.CreateMultiProject("focus-xfshell"); + + cliHelper.AddProjectToSolution(xfShellProject); + cliHelper.AddProjectToSolution($"{xfShellProject}.Android"); + cliHelper.AddProjectToSolution($"{xfShellProject}.iOS"); + + projectsToReference.Add(xfShellProject); + break; case 6: string blazorProject = cliHelper.CreateProject("blazorserver", "Blazor"); cliHelper.AddProjectToSolution(blazorProject); - createdProjects.Add(blazorProject); + projectsToReference.Add(blazorProject); break; case 7: string wasmProject = cliHelper.CreateProject("blazorwasm", "Blazor"); cliHelper.AddProjectToSolution(wasmProject); - createdProjects.Add(wasmProject); + projectsToReference.Add(wasmProject); break; } @@ -116,12 +125,12 @@ private static void CreateProjects(string solutionName) cliHelper.AddProjectToSolution(businessProject); - foreach (string project in createdProjects) + foreach (string project in projectsToReference) { cliHelper.AddReferenceToProject(project, businessProject); } - createdProjects.Add(businessProject); + projectsToReference.Add(businessProject); } if (Prompt.GetYesNo("Create shared project?", false, ConsoleColor.DarkCyan)) @@ -130,7 +139,7 @@ private static void CreateProjects(string solutionName) cliHelper.AddProjectToSolution(sharedProject); - foreach (string project in createdProjects) + foreach (string project in projectsToReference) { cliHelper.AddReferenceToProject(project, sharedProject); } @@ -142,7 +151,7 @@ private static void CreateProjects(string solutionName) cliHelper.AddProjectToSolution(testProject); - foreach (string project in createdProjects) + foreach (string project in projectsToReference) { cliHelper.AddReferenceToProject(testProject, project); }