Пример #1
0
        public virtual void Execute(IBuildContext buildContext)
        {
            var logger = buildContext.Logger;

            var sourceFile = this.OutputFile.ResolveBuildOutputPath(buildContext.BuildConfiguration.OutputFolder);
            var targetFile = this.OutputFile.ResolveDistributionPath(_componentBuilder.ResolveDistributionLocalPath(buildContext.BuildConfiguration.DistributionLocalPath));

            var fileSystemAdapter    = buildContext.FileSystemAdapter;
            var sourceControlAdapter = buildContext.SourceControlAdapter;


            if (fileSystemAdapter.FileExists(targetFile) &&
                !sourceControlAdapter.HasPendingChanges(targetFile))
            {
                fileSystemAdapter.DeleteFile(targetFile);
            }

            sourceControlAdapter.TryGetLatestVersion(targetFile);

            if (fileSystemAdapter.FileExists(targetFile))
            {
                logger.Info($"PendEdit: {targetFile}");
                sourceControlAdapter.CheckoutForEdit(targetFile);
                logger.Info($"Copy {sourceFile} to {targetFile}");
                fileSystemAdapter.CopyFile(sourceFile, targetFile);
            }
            else
            {
                logger.Info($"Copy {sourceFile} to {targetFile}");
                fileSystemAdapter.CopyFile(sourceFile, targetFile);
                logger.Info($"PendAdd: {targetFile}");
                sourceControlAdapter.PendAdd(targetFile);
            }
        }
Пример #2
0
        public void Execute(IBuildContext buildContext)
        {
            var componentDescriptionTxtFile = _componentBuilder
                                              .ResolveDistributionLocalPath(buildContext.BuildConfiguration.DistributionLocalPath)
                                              .Subpath("component_description.txt");

            buildContext.Logger.Info($"Create file {componentDescriptionTxtFile.AsString()}");
            if (buildContext.FileSystemAdapter.FileExists(componentDescriptionTxtFile))
            {
                buildContext.SourceControlAdapter.CheckoutForEdit(componentDescriptionTxtFile);

                buildContext.FileSystemAdapter.WriteAllText(componentDescriptionTxtFile,
                                                            _componentBuilder.GetComponentDescriptionTxtContent());
            }
            else
            {
                buildContext.FileSystemAdapter.WriteAllText(componentDescriptionTxtFile,
                                                            _componentBuilder.GetComponentDescriptionTxtContent());
                buildContext.SourceControlAdapter.PendAdd(componentDescriptionTxtFile);
            }
        }