Esempio n. 1
0
        public static void PublishProjects(this ICakeContext context, Configuration config, string rootFolder, string destination, string[] excludePatterns, string projectParentFolderName)
        {
            var globberSettings = new GlobberSettings();

            bool excludes(IFileSystemInfo fileSystemInfo) => !excludePatterns.Any(s => fileSystemInfo.Path.FullPath.Contains(s));

            globberSettings.FilePredicate = excludes;

            var projects = GlobbingAliases.GetFiles(context, $"{rootFolder}\\**\\{projectParentFolderName}\\*.csproj", globberSettings);

            context.Log.Information("Publishing " + rootFolder + " to " + destination);

            foreach (var project in projects)
            {
                context.MSBuild(project, cfg => InitializeMSBuildSettingsInternal(context, config, cfg)
                                .WithTarget(config.BuildTargets)
                                .WithProperty("DeployOnBuild", "true")
                                .WithProperty("DeployDefaultTarget", "WebPublish")
                                .WithProperty("WebPublishMethod", "FileSystem")
                                .WithProperty("DeleteExistingFiles", "false")
                                .WithProperty("publishUrl", destination)
                                .WithProperty("BuildProjectReferences", "false")
                                );
            }
        }
Esempio n. 2
0
        public IEnumerable <IFileSystemInfo> Walk(GlobNode node, GlobberSettings settings)
        {
            var context = new GlobVisitorContext(_fileSystem, _environment, settings.Predicate);

            node.Accept(this, context);
            return(context.Results);
        }
Esempio n. 3
0
        public GlobNode Parse(string pattern, GlobberSettings settings)
        {
            var buffer          = GlobTokenizer.Tokenize(pattern);
            var isCaseSensitive = settings.IsCaseSensitive ?? _environment.Platform.IsUnix();

            return(Parse(new GlobParserContext(buffer, isCaseSensitive)));
        }
Esempio n. 4
0
        private IEnumerable <FilePath> FindProjects(string folder)
        {
            var root            = new DirectoryPath(folder).MakeAbsolute(_environment);
            var globberSettings = new GlobberSettings {
                Comparer = new PathComparer(false), Root = root
            };

            return(_globber.Match(@"**/*.{c|f}sproj", globberSettings).OfType <FilePath>());
        }
Esempio n. 5
0
        public static FilePathCollection GetTransformFiles(this ICakeContext context, string rootFolder)
        {
            var globberSettings = new GlobberSettings();

            bool exclude_obj_bin_folder(IFileSystemInfo fileSystemInfo) => !fileSystemInfo.Path.FullPath.Contains("/obj/") && !fileSystemInfo.Path.FullPath.Contains("/bin/");

            globberSettings.FilePredicate = exclude_obj_bin_folder;

            var xdtFiles = context.GetFiles($"{rootFolder}\\**\\*.xdt", globberSettings);

            return(xdtFiles);
        }
Esempio n. 6
0
        public static FilePathCollection GetFilesByPatterns(ICakeContext context, string[] patterns, Func <IDirectory, bool> predicate)
        {
            var settings = new GlobberSettings();

            settings.Predicate       = predicate;
            settings.IsCaseSensitive = false;
            FilePathCollection res = context.GetFiles(patterns[0], settings);

            for (var i = 1; i < patterns.Length - 1; i++)
            {
                res += context.GetFiles(patterns[i], settings);
            }
            return(res);
        }
Esempio n. 7
0
    public override void Run(Context context)
    {
        var globberSettings = new GlobberSettings
        {
            Predicate = x => !x.Path.FullPath.Contains("/build/")
        };

        var directories = context.GetDirectories("./**/bin", globberSettings)
                          + context.GetDirectories("./**/obj", globberSettings)
                          + context.Artifacts;

        foreach (var directory in directories)
        {
            context.CleanDirectory(directory);
        }
    }
Esempio n. 8
0
        public GlobVisitorContext(
            IEnvironment environment,
            GlobberSettings settings)
        {
            if (environment is null)
            {
                throw new ArgumentNullException(nameof(environment));
            }

            _settings  = settings ?? throw new ArgumentNullException(nameof(settings));
            _pathParts = new List <string>();

            Results = new List <IFileSystemInfo>();

            Root = _settings.Root ?? environment.WorkingDirectory;
            Root = Root.MakeAbsolute(environment);

            Path = new DirectoryPath(string.Empty);
        }
Esempio n. 9
0
        public static FilePathCollection GetFiles(this ICakeContext context, string pattern, GlobberSettings settings)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            return(new FilePathCollection(context.Globber.Match(pattern, settings).OfType <FilePath>()));
        }
Esempio n. 10
0
        public static PathCollection GetPaths(this ICakeContext context, GlobPattern pattern, GlobberSettings settings)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            return(new PathCollection(context.Globber.Match(pattern, settings)));
        }
Esempio n. 11
0
        public static DirectoryPathCollection GetDirectories(this ICakeContext context, GlobPattern pattern, GlobberSettings settings)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            return(new DirectoryPathCollection(context.Globber.Match(pattern, settings).OfType <DirectoryPath>()));
        }
Esempio n. 12
0
 public IEnumerable <Path> Match(GlobPattern pattern, GlobberSettings settings)
 {
     return(new FilePath[] { new FilePath(pattern) });
 }
Esempio n. 13
0
        public static DirectoryPathCollection GetDirectories(this ICakeContext context, string pattern, GlobberSettings settings)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            return(new DirectoryPathCollection(
                       context.Globber.Match(pattern, settings).OfType <DirectoryPath>(),
                       new PathComparer(context.Environment.Platform.IsUnix())));
        }