Example #1
0
        public static void OldMain(string[] args)
        {
            try {
                var pkgtemplate = GetTemplateFromPackage("DotnetSampleConsoleApp", "1.0.0", "microsoft.dotnet.console.rc2");
                if (pkgtemplate != null)
                {
                    string targetfolder = @"c:\temp\dn-waffle\frompkg";
                    if (!string.IsNullOrWhiteSpace(targetfolder) && Directory.Exists(targetfolder))
                    {
                        Directory.Delete(targetfolder, true);
                    }
                    var tcreator = new TemplateCreator();
                    tcreator.CreateProject(pkgtemplate, targetfolder, "MyNewConsoleProject", null);
                }

                var template = CreateTemplate();
                var result   = Newtonsoft.Json.JsonConvert.SerializeObject(template, Newtonsoft.Json.Formatting.Indented);
                Console.WriteLine(result);

                string destFolder = @"c:\temp\dn-waffle\webapi";
                if (!string.IsNullOrWhiteSpace(destFolder) && Directory.Exists(destFolder))
                {
                    Directory.Delete(destFolder, true);
                }
                var creator = new TemplateCreator();
                creator.CreateProject(template, destFolder, "MyNewProject", null);

                string giturl       = @"https://github.com/sayedihashimi/dotnet-waffle.git";
                string gitbranch    = "master";
                string templatename = "microsoft.dotnet.console.rc2";
                template   = GetTemplateFromGit(giturl, gitbranch, templatename);
                destFolder = @"C:\temp\dn-waffle\gitconsole";
                if (!string.IsNullOrWhiteSpace(destFolder) && Directory.Exists(destFolder))
                {
                    Directory.Delete(destFolder, true);
                }
                creator.CreateProject(template, destFolder, "MyNewConsoleProject", null);

                var settingsFile = @"C:\temp\dn-waffle\settings.json";
                var manager      = new TemplateSourceManager(settingsFile);
                var sourceFolder = @"C:\Data\mycode\dotnet-waffle\samples";
                manager.AddTemplateSource(TemplateSource.NewFolderSource(sourceFolder));

                destFolder = @"c:\temp\dn-waffle\console";
                if (!string.IsNullOrWhiteSpace(destFolder) && Directory.Exists(destFolder))
                {
                    Directory.Delete(destFolder, true);
                }
                template = Template.BuildFromFile(@"C:\Users\sayedha\Documents\Visual Studio 2015\Projects\SamplesForDotnetWaffle\src\SampleConsoleApp\waffle.json");
                creator.CreateProject(template, destFolder, "MyNewConsoleApp", null);
            }
            catch (Exception ex) {
                Console.WriteLine(ex.ToString());
            }

            Console.WriteLine("Press enter to exit");
            Console.ReadLine();
        }
 public TemplateManager(TemplateSourceManager sourceManager)
 {
     SourceManager = sourceManager;
 }