Ejemplo n.º 1
0
        private void CreateEmptyDirectory(DeployWorkConfig deployWorkConfig)
        {
            var targetFolderName = deployWorkConfig.GetTargetFolderName();

            deployWorkConfig.Projects
            //取得被選取的專案
            .Where(r => r.Selected)
            .Select(p => new ProjectConfigModel(deployWorkConfig, p))
            //取得所有資料夾
            .ToProjectDirectoryDatas()
            //依IgnoreRule設定排除檔案
            .FilterByIgnoreRule()
            //依建立日期和最後修改日期排除檔案
            .FilterByLastWriteTime()
            .CreateDirectory(targetFolderName);
        }
Ejemplo n.º 2
0
        public void ExecuteDeploy(DeployWorkConfig deployWorkConfig)
        {
            var targetFolderName = deployWorkConfig.GetTargetFolderName();

            //編譯
            if (deployWorkConfig.IsBuild)
            {
                CodeBuild(deployWorkConfig);
            }

            var fileCopyMappingModels = deployWorkConfig.Projects
                                        //取得被選取的專案
                                        .Where(r => r.Selected)
                                        .Select(p => new ProjectConfigModel(deployWorkConfig, p))
                                        //取得所有資料夾
                                        .ToProjectDirectoryDatas()
                                        //取得所有檔案
                                        .ToProjectFileDatas().ToList()
                                        //依IgnoreRule設定排除檔案
                                        .FilterByIgnoreRule()
                                        //依最後修改日期排除檔案
                                        .FilterByLastWriteTime()
                                        .ToFileCopyMappingModels(targetFolderName)
                                        .Distinct()
                                        .ToList();

            //預先建立空資料夾
            if (deployWorkConfig.IsKeepEmptyDir)
            {
                CreateEmptyDirectory(deployWorkConfig);
            }

            //複製檔案
            fileCopyMappingModels.DoCopy();

            //無檔案不進行後續動作
            if (!fileCopyMappingModels.Any())
            {
                throw new CustomException(@"無檔案!");
            }


            //壓縮
            if (deployWorkConfig.IsCompression)
            {
                Compression(deployWorkConfig);
            }

            //利用FTP發佈
            if (deployWorkConfig.IsPublishToFtp)
            {
                PublishToFtp(deployWorkConfig);
            }

            //利用磁碟機發佈
            if (deployWorkConfig.IsPublishToDisk)
            {
                PublishToDisk(deployWorkConfig);
            }

            //寫FileList Txt
            WriteFileList(deployWorkConfig, fileCopyMappingModels.Select(r => r.TargetPath).ToList());
        }