コード例 #1
0
        /// <summary>
        /// Zip folder Framework.Template/ before running dotnet pack.
        /// </summary>
        public static void CommandTemplateZip()
        {
            Console.WriteLine("Create Framework.Template.zip");

            var folderNameTemplate = new Uri(new Uri(UtilCli.FolderNameFrameworkSln !), "Framework.Template/").AbsolutePath;
            var fileNameList       = UtilCli.FileNameList(folderNameTemplate);

            // Filter folder node_modules, bin, obj, vs
            fileNameList = fileNameList.Where(item => !item.Contains("/node_modules/") && !item.Contains("/bin/") && !item.Contains("/obj/") && !item.Contains("/.vs/")).ToList();

            // Temp FolderName
            var folderNameTemp = Path.GetTempPath().Replace("\\", "/") + Guid.NewGuid() + "/" + "Framework.Template/";

            Directory.CreateDirectory(folderNameTemp);

            // Copy FileName
            foreach (var fileName in fileNameList)
            {
                Debug.Assert(fileName.StartsWith(folderNameTemplate));
                var fileNameDest = folderNameTemp + fileName.Substring(folderNameTemplate.Length);
                UtilCli.FileNameCopy(fileName, fileNameDest);
            }

            // Zip
            var fileNameZip = UtilCli.FolderNameFrameworkSln + "WorkplaceX.Cli/Framework.Template.zip";

            if (File.Exists(fileNameZip))
            {
                File.Delete(fileNameZip);
            }
            ZipFile.CreateFromDirectory(folderNameTemp, fileNameZip);
            Directory.Delete(folderNameTemp, recursive: true);
        }