コード例 #1
0
        public static void CopyWithManifest(string sourcePath, string destinationPath, IDeploymentManifestReader previousManifest, bool skipOldFiles = true)
        {
            sourcePath      = Path.GetFullPath(sourcePath);
            destinationPath = Path.GetFullPath(destinationPath);

            using (var progressWriter = new ProgressWriter())
            {
                progressWriter.Start();

                if (previousManifest != null)
                {
                    var previousFiles = new HashSet <string>(previousManifest.GetPaths(), StringComparer.OrdinalIgnoreCase);

                    SmartCopy(sourcePath, destinationPath, previousFiles.Contains, new DirectoryInfoWrapper(new DirectoryInfo(sourcePath)), new DirectoryInfoWrapper(new DirectoryInfo(destinationPath)), path => new DirectoryInfoWrapper(new DirectoryInfo(path)));
                }
                else
                {
                    // On first deployment, delete the contents of the destination path before copying
                    FileSystemHelpers.DeleteDirectoryContentsSafe(destinationPath);

                    // If there's no manifest then there's nothing to copy
                    FileSystemHelpers.Copy(sourcePath, destinationPath);
                }
            }
        }
コード例 #2
0
        private static string CopyToTemp(IEnumerable <string> files, string rootPath)
        {
            var tmp = Path.Combine(Path.GetTempPath(), Path.GetTempFileName().Replace(".", string.Empty));

            FileSystemHelpers.EnsureDirectory(tmp);

            foreach (var file in files)
            {
                var relativeFileName = file.Replace(rootPath, string.Empty).Trim(Path.DirectorySeparatorChar);
                var relativeDirName  = Path.GetDirectoryName(relativeFileName);

                FileSystemHelpers.EnsureDirectory(Path.Combine(tmp, relativeDirName));
                FileSystemHelpers.Copy(file, Path.Combine(tmp, relativeFileName));
            }
            return(tmp);
        }
コード例 #3
0
ファイル: GitExeServer.cs プロジェクト: ashbrener/kudu
        public ChangeSet Initialize(RepositoryConfiguration configuration, string path)
        {
            if (Exists && !_initLock.IsHeld)
            {
                // Repository already exists and there's nothing happening then do nothing
                return(null);
            }

            ChangeSet changeSet = null;

            _initLock.LockOrWait(() =>
            {
                InitializeRepository(configuration);

                ITracer tracer = _traceFactory.GetTracer();
                using (tracer.Step("GitExeServer.Initialize(path)"))
                {
                    tracer.Trace("Initializing repository from path", new Dictionary <string, string>
                    {
                        { "path", path }
                    });

                    using (tracer.Step("Copying files into repository"))
                    {
                        // Copy all of the files into the repository
                        FileSystemHelpers.Copy(path, _gitExe.WorkingDirectory);
                    }

                    // Make the initial commit
                    changeSet = _repository.Commit("Initial commit");
                }
            },
                                 _initTimeout);

            return(changeSet);
        }
コード例 #4
0
        public void AddTasks()
        {
            var buildTask = this.Task("Build")
                            .Does <BuildData>((context, buildData) =>
            {
                context.DotNetCoreBuild(buildData.GetProjectSourcePath(ProjectSourceDir));
            });

            var publishTask = this.Task("Publish")
                              .Does <BuildData>((context, buildData) =>
            {
                var publishPath = buildData.ApplicationsPublishPath.Combine("GameApi");

                if (Directory.Exists(publishPath.FullPath))
                {
                    Directory.Delete(publishPath.FullPath, true);
                }

                context.DotNetCorePublish(buildData.GetProjectSourcePath(ProjectSourceDir), new DotNetCorePublishSettings
                {
                    OutputDirectory = publishPath,
                });

                var allPublishedFiles = Directory.GetFiles(publishPath.FullPath, "*.*",
                                                           SearchOption.AllDirectories);

                File.WriteAllText(Path.Combine(publishPath.FullPath, "publish_files.txt"),
                                  string.Join("\r\n", allPublishedFiles.Select(fp => Path.GetRelativePath(publishPath.FullPath, fp))));
            });

            var deployTask = this.Task("Deploy")
                             .IsDependentOn(publishTask)
                             .Does <BuildData>((context, buildData) =>
            {
                var deployPath = context.Argument <string>("GameApi.DeployPath");
                context.Log.Information($"DeployPath={deployPath}");

                context.Log.Information("Creating app_offline.htm to stop the app...");
                var appOfflinePath = Path.Combine(deployPath, "app_offline.htm");
                File.WriteAllText(appOfflinePath, "Maintenance...");

                context.Log.Information("Waiting 3000ms to make sure the app is stopped.");
                Thread.Sleep(3000);

                var publishedFilesPath = Path.Combine(deployPath, "publish_files.txt");
                if (File.Exists(publishedFilesPath))
                {
                    context.Log.Information("Deleting existing published files...");

                    var publishedFilesList = File.ReadAllText(publishedFilesPath).Split("\r\n");
                    foreach (var filePath in publishedFilesList)
                    {
                        File.Delete(Path.Combine(deployPath, filePath));
                    }
                }

                context.Log.Information("Copying application files...");
                FileSystemHelpers.Copy(buildData.ApplicationsPublishPath.FullPath, deployPath);

                context.Log.Information("Deleting app_offline.htm to make the app online ...");
                File.Delete(appOfflinePath);
            });
        }