Esempio n. 1
0
        protected internal override void Execute()
        {
            CommandBuild.ConfigServerPublish();

            ConfigCli configCli         = ConfigCli.Load();
            string    deployAzureGitUrl = UtilFramework.StringNull(configCli.EnvironmentGet().DeployAzureGitUrl); // For example: "https://*****:*****@my22.scm.azurewebsites.net:443/my22.git"

            if (deployAzureGitUrl == null)
            {
                UtilCli.ConsoleWriteLineColor(nameof(ConfigCliEnvironment.DeployAzureGitUrl) + " not set!", System.ConsoleColor.Green);
            }
            else
            {
                string folderName           = UtilFramework.FolderName + "Application.Server/";
                string folderNamePublish    = UtilFramework.FolderName + "Application.Server/bin/Debug/net5.0/publish/";
                string folderNamePublishGit = folderNamePublish + ".git";

                UtilCli.FolderDelete(folderNamePublishGit);                                            // Undo git init.
                UtilCli.Start(folderNamePublish, "git", "init -b master");                             // External system to push to.
                UtilCli.Start(folderNamePublish, "git", "config user.email \"[email protected]\""); // Prevent: Error "Please tell me who you are". See also: http://www.thecreativedev.com/solution-github-please-tell-me-who-you-are-error/
                UtilCli.Start(folderNamePublish, "git", "config user.name \"Deploy\"");
                UtilCli.Start(folderNamePublish, "git", "config core.autocrlf false");                 // Prevent "LF will be replaced by CRLF" error in stderr.
                UtilCli.Start(folderNamePublish, "git", "add .");                                      // Can throw "LF will be replaced by CRLF".
                UtilCli.Start(folderNamePublish, "git", "commit -m Deploy");
                UtilCli.Start(folderNamePublish, "git", "remote add azure " + deployAzureGitUrl);
                UtilCli.Start(folderNamePublish, "git", "push azure master -f", isRedirectStdErr: true); // Do not write to stderr. Can be tested with "dotnet run -- deploy [DeployAzureGitUrl] 2>Error.txt"
            }
        }
Esempio n. 2
0
        private void ExecuteDelete()
        {
            var args = UtilExternal.ExternalArgs();

            // Delete folder App/
            Console.WriteLine("Delete dest folder App/");
            UtilCli.FolderDelete(args.AppDestFolderName);

            // Copy folder Database/
            Console.WriteLine("Delete dest folder App/");
            UtilCli.FolderDelete(args.DatabaseDestFolderName);

            // Copy folder CliApp/
            Console.WriteLine("Delete dest folder CliApp/");
            UtilCli.FolderDelete(args.CliAppDestFolderName);


            // Copy folder CliDatabase/
            Console.WriteLine("Delete dest folder CliDatabase/");
            UtilCli.FolderDelete(args.CliDatabaseDestFolderName);


            // Copy folder CliDeployDb/
            Console.WriteLine("Delete dest folder CliDeployDb/");
            UtilCli.FolderDelete(args.CliDeployDbDestFolderName);

            // Copy folder Application.Website/
            Console.WriteLine("Delete dest folder Application.Website/");
            UtilCli.FolderDelete(args.WebsiteDestFolderName);
        }
Esempio n. 3
0
        /// <summary>
        /// Build all layout Websites. For example: "Application.Website/LayoutDefault"
        /// </summary>
        private void BuildWebsite()
        {
            var configCli = ConfigCli.Load();

            // Ensure FolderNameNpmBuild is defined once only in ConfigCli.json.
            ConfigCliWebsite configCliWebsite = configCli.WebsiteList.GroupBy(item => item.FolderNameNpmBuild.ToLower()).Where(group => group.Count() > 1).FirstOrDefault()?.FirstOrDefault();

            UtilFramework.Assert(configCliWebsite == null, string.Format("ConfigCli.json Website defined more than once. Use DomainNameList instead! (FolderNameNpmBuild={0})", configCliWebsite?.FolderNameNpmBuild));

            // Delete folder Application.Server/Framework/Application.Website/
            string folderNameApplicationWebsite = UtilFramework.FolderName + "Application.Server/Framework/Application.Website/";

            UtilCli.FolderDelete(folderNameApplicationWebsite);

            foreach (var website in configCli.WebsiteList)
            {
                Console.WriteLine(string.Format("### Build Website (Begin) - {0}", website.DomainNameListToString()));

                // Delete dist folder
                string folderNameDist = UtilFramework.FolderNameParse(website.FolderNameDist);
                UtilFramework.Assert(folderNameDist != null);
                UtilCli.FolderDelete(folderNameDist);

                // npm run build
                BuildWebsiteNpm(website);
                string folderNameServer = UtilFramework.FolderNameParse("Application.Server/Framework/" + website.FolderNameDist);
                UtilFramework.Assert(folderNameServer != null, "FolderNameServer can not be null!");
                UtilFramework.Assert(folderNameServer.StartsWith("Application.Server/Framework/Application.Website/"), "FolderNameServer has to start with 'Application.Server/Framework/Application.Website/'!");

                // Copy dist folder
                string folderNameSource = UtilFramework.FolderName + folderNameDist;
                string folderNameDest   = UtilFramework.FolderName + folderNameServer;
                if (!UtilCli.FolderNameExist(folderNameSource))
                {
                    throw new Exception(string.Format("Folder does not exist! ({0})", folderNameDest));
                }

                // Layout file main.js and Angular file main.js
                // Prevent for example two main.js. Angular js can not be overridden by layout Website
                // Application.Website/LayoutDefault/dist/main.js
                // Application.Server/Framework/Framework.Angular/browser/main.js
                var fileNameList = new string[] { "runtime.js", "polyfills.js", "main.js" };
                foreach (var fileName in fileNameList)
                {
                    var fileNameFull = folderNameSource + fileName;
                    if (File.Exists(fileNameFull))
                    {
                        throw new Exception(string.Format("File conflicts with Angular! See also: https://webpack.js.org/configuration/output/ ({0})", fileNameFull));
                    }
                }

                UtilCli.FolderDelete(folderNameDest);
                UtilFramework.Assert(!UtilCli.FolderNameExist(folderNameDest));
                UtilCli.FolderCopy(folderNameSource, folderNameDest, "*.*", true);
                UtilFramework.Assert(UtilCli.FolderNameExist(folderNameDest));

                Console.WriteLine(string.Format("### Build Website (End) - {0}", website.DomainNameListToString()));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Build all layout Websites. For example: "Application.Website/LayoutDefault"
        /// </summary>
        private void BuildWebsite()
        {
            var configCli = ConfigCli.Load();

            // Ensure FolderNameNpmBuild is defined once only in ConfigCli.json.
            ConfigCliWebsite configCliWebsite = configCli.WebsiteList.GroupBy(item => item.FolderNameNpmBuild.ToLower()).Where(group => group.Count() > 1).FirstOrDefault()?.FirstOrDefault();

            UtilFramework.Assert(configCliWebsite == null, string.Format("ConfigCli.json Website defined more than once. Use DomainNameList instead! (FolderNameNpmBuild={0})", configCliWebsite?.FolderNameNpmBuild));

            // Delete folder Application.Server/Framework/Application.Website/
            string folderNameApplicationWebsite = UtilFramework.FolderName + "Application.Server/Framework/Application.Website/";

            UtilCli.FolderDelete(folderNameApplicationWebsite);

            foreach (var website in configCli.WebsiteList)
            {
                Console.WriteLine(string.Format("### Build Website (Begin) - {0}", website.DomainNameListToString()));

                // Delete dist folder
                string folderNameDist = UtilFramework.FolderNameParse(website.FolderNameDist);
                UtilFramework.Assert(folderNameDist != null);
                UtilCli.FolderDelete(folderNameDist);

                // npm run build
                BuildWebsiteNpm(website);
                string folderNameServer = UtilFramework.FolderNameParse(website.FolderNameServerGet(configCli));
                UtilFramework.Assert(folderNameServer != null, "FolderNameServer can not be null!");
                UtilFramework.Assert(folderNameServer.StartsWith("Application.Server/Framework/Application.Website/"), "FolderNameServer has to start with 'Application.Server/Framework/Application.Website/'!");

                // Copy dist folder
                string folderNameSource = UtilFramework.FolderName + folderNameDist;
                string folderNameDest   = UtilFramework.FolderName + folderNameServer;
                if (!UtilCli.FolderNameExist(folderNameSource))
                {
                    throw new Exception(string.Format("Folder does not exist! ({0})", folderNameDest));
                }
                UtilCli.FolderDelete(folderNameDest);
                UtilFramework.Assert(!UtilCli.FolderNameExist(folderNameDest));
                UtilCli.FolderCopy(folderNameSource, folderNameDest, "*.*", true);
                UtilFramework.Assert(UtilCli.FolderNameExist(folderNameDest));

                Console.WriteLine(string.Format("### Build Website (End) - {0}", website.DomainNameListToString()));
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Copy folder Application.Website/Shared/CustomComponent/
        /// </summary>
        private static void BuildAngularInit()
        {
            // Delete folder Application.Website/
            string folderNameApplicationWebSite = UtilFramework.FolderName + "Framework/Framework.Angular/application/src/Application.Website/";

            UtilCli.FolderDelete(folderNameApplicationWebSite);

            // Copy folder CustomComponent/
            string folderNameSource = UtilFramework.FolderName + "Application.Website/Shared/CustomComponent/";
            string folderNameDest   = UtilFramework.FolderName + "Framework/Framework.Angular/application/src/Application.Website/Shared/CustomComponent/";

            UtilCli.FolderCopy(folderNameSource, folderNameDest, "*.*", true);

            // Copy empty index.html file
            UtilCli.FileCopy(UtilFramework.FolderName + "Framework/Framework.Angular/application/src/index.html", UtilFramework.FolderName + "Framework/Framework.Angular/application/src/Application.Website/dist/index.html");

            // Ensure folder exists now
            UtilFramework.Assert(Directory.Exists(folderNameApplicationWebSite));
        }
Esempio n. 6
0
        /// <summary>
        /// Build Framework/Framework.Angular/application/.
        /// </summary>
        private static void BuildAngular()
        {
            // Build SSR
            {
                string folderName = UtilFramework.FolderName + "Framework/Framework.Angular/application/";
                UtilCli.Npm(folderName, "install --loglevel error");              // Angular install. --loglevel error prevent writing to STDERR "npm WARN optional SKIPPING OPTIONAL DEPENDENCY"
                UtilCli.Npm(folderName, "run build:ssr", isRedirectStdErr: true); // Build Server-side Rendering (SSR) to folder Framework/Framework.Angular/application/server/dist/ // TODO Bug report Angular build writes to stderr. Repo steps: Delete node_modules and run npm install and then run build:ssr.
            }

            // Copy output dist folder
            {
                string folderNameSource = UtilFramework.FolderName + "Framework/Framework.Angular/application/dist/application/";
                string folderNameDest   = UtilFramework.FolderName + "Application.Server/Framework/Framework.Angular/";

                // Copy folder
                UtilCli.FolderDelete(folderNameDest);
                UtilFramework.Assert(!Directory.Exists(folderNameDest));
                UtilCli.FolderCopy(folderNameSource, folderNameDest, "*.*", true);
                UtilFramework.Assert(Directory.Exists(folderNameDest));
            }
        }