Represents a set of files with include and exclude filters
Inheritance: IFileSet
        public FluentFileSample()
        {
            var file = new FluentFs.Core.File(@"c:\temp\test.txt");

            file.Copy.To(@"c:\temp\test2.txt");
            file.Move.To(@"c:\NewDirectory");
            file.Move.ContinueOnError.To(@"c:\DirectoryThatMayNotExist");
            file.Rename.To("test41.txt");
            file.Delete(OnError.Continue);

            var directory = new FluentFs.Core.Directory(@"c:\temp\sample");

            directory.Delete(OnError.Continue).Create(OnError.Fail);
            directory.Files();                                    //returns all files in the folder
            directory.Files("*.txt");                             //returns all files ending in .txt
            var childFolder = directory.SubFolder("childFolder"); //creates a new Directory object with a path of c:\temp\sample\childFolder

            directory.ToString();                                 //returns the path of the folder
            directory.File("test.txt");                           // returns back a FluentFilesystem.File object with a path of c:\temp\sample\test.txt

            var fileset = new FluentFs.Core.FileSet();

            fileset.Include(@"c:\Project\GUI\*.cs").RecurseAllSubDirectories
            .Exclude("assemblyInfo.cs")
            .Include(@"c:\Project\globalconfig.xml");

            ReadOnlyCollection <string> files = fileset.Files;

            fileset.Copy.To(@"c:\temp");
        }
Exemple #2
0
        public void FilesetExamples()
        {
            var fs            = new Core.FileSet().Include(new Directory("c:\\origin\\")).Filter("*.dll").Exclude(new File("*.config")).RecurseAllSubDirectories;
            var filesMatching = fs.Files; //gets all dll files and excludes all config files

            fs.Copy.To(@"c:\temp");       //copies all files matching to the destination
        }
Exemple #3
0
 public void IncludeWithFilter()
 {
     var fs = new FileSet();
     var readOnlyCollection = fs.Include(new Directory(rootFolder)).Filter("*.cs").Files;
     Assert.That(readOnlyCollection[0], Is.EqualTo(Path.Combine(rootFolder, "file1.cs")));
     Assert.That(readOnlyCollection[1], Is.EqualTo(Path.Combine(rootFolder, "file2.cs")));
     Assert.That(readOnlyCollection[2], Is.EqualTo(Path.Combine(rootFolder, "file3.cs")));
 }
        private void CompileSources()
        {
            var sourceFiles = new FluentFs.Core.FileSet().Include(directory_base.SubFolder("src"))
                              .RecurseAllSubDirectories
                              .Filter("*.cs");

            FluentBuild.Task.Build.Csc.Target.Library(compiler => compiler.AddSources(sourceFiles).OutputFileTo(assembly_FluentBuild));
        }
        private void CompileSources()
        {
            var sourceFiles = new FluentFs.Core.FileSet().Include(directory_base.SubFolder("src"))
                                                         .RecurseAllSubDirectories
                                                         .Filter("*.cs");

            FluentBuild.Task.Build.Csc.Target.Library(compiler=>compiler.AddSources(sourceFiles).OutputFileTo(assembly_FluentBuild));
        }
Exemple #6
0
        private void CompileBuildFileConverterWithoutTests()
        {
            var sourceFiles = new FileSet();
            sourceFiles.Include(directory_src_converter).RecurseAllSubDirectories.Filter("*.cs")
                .Exclude(directory_src_converter).RecurseAllSubDirectories.Filter("*Tests.cs");
            ;

            Task.Build.Csc.Target.Executable(x => x.AddSources(sourceFiles).OutputFileTo(assembly_BuildFileConverter_WithTests));
        }
 public void Args_ShouldCreateProperArgs_With_Fileset_Resources()
 {
     string reference = "external.dll";
     string outputAssembly = "myapp.dll";
     string source = "myfile.cs";
     FileSet sources = new FileSet().Include(source);
     BuildTask build = new BuildTask("", "library").OutputFileTo(outputAssembly).AddResources(sources);
     build.BuildArgs();
     Assert.That(build._argumentBuilder.Build().Trim(), Is.EqualTo(String.Format("/out:\"{0}\" /resource:\"myfile.cs\" /target:{1}", outputAssembly, "library")));
 }
Exemple #8
0
        public void GenerateFrom_ShouldPopulateFiles()
        {
            var fileset = new FileSet();
            fileset.Include(new File("c:\temp\nonexistant.txt"));

            Resgen subject = new Resgen().GenerateFrom(fileset);

            Assert.That(subject.Files, Is.Not.Null);
            Assert.That(subject, Is.Not.Null);
        }
Exemple #9
0
        public void ExecuteShouldRunExe()
        {
            var mock = MockRepository.GenerateStub<IActionExcecutor>();
            var fileset = new FileSet();
            fileset.Include(new File(@"c:\temp\nonexistant.txt"));

            Resgen subject = new Resgen(mock).GenerateFrom(fileset).OutputTo(@"c:\temp\");
            subject.Execute();
            mock.AssertWasCalled(x=>x.Execute(Arg<Func<Executable, object>>.Is.Anything));
        }
Exemple #10
0
        public void CompileCoreWithoutTests()
        {
            FileSet sourceFiles = new FileSet()
             .Include(directory_base.SubFolder("FluentFs"))
             .RecurseAllSubDirectories.Filter("*.cs")
             .Exclude(directory_base.SubFolder("FluentFs"))
             .RecurseAllSubDirectories.Filter("*Tests.cs");

            Task.Build(Using.Csc.Target.Library
                .AddSources(sourceFiles)
                .OutputFileTo(AssemblyFluentFsRelease));
        }
        private void CompileTests()
        {
            new FileSet()
                .Include(directory_tools).RecurseAllSubDirectories.Filter("nunit.framework.dll")
                .Include(directory_tools).RecurseAllSubDirectories.Filter("rhino.mocks.dll")
                .Copy.To(directory_compile);

               var sourceFiles = new FileSet().Include(directory_base.SubFolder("tests")).RecurseAllSubDirectories.Filter("*.cs");
               Task.Build.Csc.Target.Library(compiler => compiler.AddSources(sourceFiles)
                                               .AddRefences(thirdparty_rhino, thirdparty_nunit, assembly_FluentBuild)
                                               .OutputFileTo(assembly_FluentBuild_Tests));
        }
        public static string BuildAssemblyFromSources(string path, string baseDirectory)
        {
            if (!System.IO.Directory.Exists(path))
                throw new DirectoryNotFoundException("Could not find the directory to build of " + path);

            Defaults.Logger.WriteDebugMessage("Sources found in: " + path);
            var fileset = new FileSet();
            fileset = fileset.Include(new Directory(path)).RecurseAllSubDirectories.Filter("*.cs");

            string startPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase).Replace("file:\\", "");

            string fluentBuilddll = Path.Combine(startPath, "FluentBuild.dll");

            Defaults.Logger.WriteDebugMessage("Adding in reference to the FluentBuild DLL from: " + fluentBuilddll);

            string tempPath = Environment.GetEnvironmentVariable("TEMP") + "\\FluentBuild\\" + DateTime.Now.Ticks;
            //System.IO.Directory.Delete(Environment.GetEnvironmentVariable("TEMP") + "\\FluentBuild\\", true);
            System.IO.Directory.CreateDirectory(tempPath);
            string outputAssembly = Path.Combine(tempPath, "build.dll");

            Defaults.Logger.WriteDebugMessage("Output Assembly: " + outputAssembly);

            var references = new List<String>() { fluentBuilddll };

            /*
            var fluentFs = new FluentFs.Core.File(Path.Combine(startPath, "FluentFs.dll"));
            if (File.Exists(fluentFs.ToString()))
            {
                fluentFs.Copy.To(tempPath);
                references.Add(fluentFs.ToString());
            }
             */

            //add in third party references
            var projectParser = new ProjectParser(path, baseDirectory);
            if (projectParser.HasProjectFile())
            {
                var referencesFromProjectFile = projectParser.GetReferences();
                foreach (var referenceFromProjectFile in referencesFromProjectFile)
                {
                    Defaults.Logger.WriteDebugMessage("Adding in third party reference " + referenceFromProjectFile);
                }
                references.AddRange(referencesFromProjectFile);
            }

            Task.Build.Csc.Target.Library(x => x.AddSources(fileset).AddRefences(references.ToArray()).IncludeDebugSymbols.OutputFileTo(outputAssembly));
            return outputAssembly;
        }
Exemple #13
0
        public FileSet Execute()
        {
            string resGenExecutable = GetPathToResGenExecutable();

            var outputFiles = new FileSet();
            foreach (string resourceFileName in Files.Files)
            {
                string outputFileName = Prefix + Path.GetFileNameWithoutExtension(resourceFileName) + ".resources";
                outputFileName = Path.Combine(OutputFolder, outputFileName);
                outputFiles.Include(outputFileName);
                var builder = new ArgumentBuilder();
                builder.StartOfEntireArgumentString = "\"" + resourceFileName + "\" \"" + outputFileName + "\"";
                _actionExcecutor.Execute<Executable>(x=>x.ExecutablePath(resGenExecutable).UseArgumentBuilder(builder));
            }
            return outputFiles;
        }
Exemple #14
0
        private void CompileCoreWithOutTests()
        {
            FileSet sourceFiles = new FileSet()
                .Include(directory_base.SubFolder("src").SubFolder("FluentBuild"))
                .RecurseAllSubDirectories.Filter("*.cs")
                .Exclude(directory_base.SubFolder("src").SubFolder("FluentBuild"))
                .RecurseAllSubDirectories.Filter("*Tests.cs")
                .Exclude(directory_base.SubFolder("src").SubFolder("FluentBuild").File("TestBase.cs").ToString());

            Task.Build.Csc.Target.Library(x => x.AddSources(sourceFiles)
                                                   .AddRefences(thirdparty_sharpzip, thirdparty_fluentFs)
                                                   .OutputFileTo(AssemblyFluentBuildRelease_Partial));

            Task.Run.ILMerge(x => x.ExecutableLocatedAt(@"tools\ilmerge\ilmerge.exe")
                                      .AddSource(AssemblyFluentBuildRelease_Partial)
                                      .AddSource(thirdparty_sharpzip)
                                      .AddSource(thirdparty_fluentFs)
                                      .OutputTo(AssemblyFluentBuildRelease_Merged));

            //now that it is merged delete the partial file
            AssemblyFluentBuildRelease_Partial.Delete();
        }
Exemple #15
0
 public Resgen GenerateFrom(FileSet fileset)
 {
     Files = fileset;
     return this;
 }
        public FluentFileSample()
        {
            var file = new FluentFs.Core.File(@"c:\temp\test.txt");
            file.Copy.To(@"c:\temp\test2.txt");
            file.Move.To(@"c:\NewDirectory");
            file.Move.ContinueOnError.To(@"c:\DirectoryThatMayNotExist");
            file.Rename.To("test41.txt");
            file.Delete(OnError.Continue);

            var directory = new FluentFs.Core.Directory(@"c:\temp\sample");
            directory.Delete(OnError.Continue).Create(OnError.Fail);
            directory.Files(); //returns all files in the folder
            directory.Files("*.txt"); //returns all files ending in .txt
            var childFolder = directory.SubFolder("childFolder"); //creates a new Directory object with a path of c:\temp\sample\childFolder
            directory.ToString(); //returns the path of the folder
            directory.File("test.txt"); // returns back a FluentFilesystem.File object with a path of c:\temp\sample\test.txt

            var fileset = new FluentFs.Core.FileSet();
            fileset.Include(@"c:\Project\GUI\*.cs").RecurseAllSubDirectories
              .Exclude("assemblyInfo.cs")
              .Include(@"c:\Project\globalconfig.xml");

            ReadOnlyCollection<string> files = fileset.Files;

            fileset.Copy.To(@"c:\temp");
        }
Exemple #17
0
        private void CompileBuildFileConverter()
        {
            var sourceFiles = new FileSet();
            sourceFiles.Include(directory_src_converter).RecurseAllSubDirectories.Filter("*.cs");

            Task.Build.Csc.Target.Executable(x => x
                        .AddSources(sourceFiles)
                        .IncludeDebugSymbols
                        .AddRefences(thirdparty_rhino, thirdparty_nunit)
                        .OutputFileTo(assembly_BuildFileConverter_WithTests)
                        );
        }
Exemple #18
0
 private void CompileFunctionalTests()
 {
     var sourceFiles = new FileSet().Include(directory_base.SubFolder("tests")).RecurseAllSubDirectories.Filter("*.cs");
     Task.Build.Csc.Target.Library(x=>x
                    .AddSources(sourceFiles)
                    .AddRefences(thirdparty_rhino, thirdparty_nunit, assembly_FluentBuild_WithTests_Merged, assembly_FluentBuild_Runner)
                    .OutputFileTo(assembly_Functional_Tests));
 }
        public CompilationTaskSamples()
        {
            //Task.Build.Csc.Target.Executable(); //a command line exe
            //Task.Build.Csc.Target.Library(); //a dll
            //Task.Build.Csc.Target.Module(); //a module
            //Task.Build.Csc.Target.WindowsExecutable(); //a windows EXE

            var baseDir = new FluentFs.Core.Directory(Environment.CurrentDirectory);
            var compileDir = baseDir.SubFolder("compile");
            compileDir.Delete(OnError.Continue).Create();
            var sampleOutput = compileDir.File("sample.dll");

            var sourceFiles = new FileSet().Include(@"c:\Sample\*.cs").RecurseAllSubDirectories;
            Task.Build.Csc.Target.Library(compiler => compiler.AddSources(sourceFiles)
                                                              .OutputFileTo(sampleOutput));

            Task.Build.MsBuild(compiler => compiler.ProjectOrSolutionFilePath(@"c:\Sample\MyProject.csproj").OutputDirectory(compileDir));

            var outputAssemblyInfoFile = compileDir.File("assemblyInfo.cs");

            Task.CreateAssemblyInfo.Language.CSharp(build=>build.OutputPath(outputAssemblyInfoFile)
                    .ClsCompliant(true)
                    .ComVisible(true)
                    .Company("My Company")
                    .Copyright("Copyright " + DateTime.Now.Year)
                    .Culture("EN-US")
                    .DelaySign(false)
                    .Description("Sample Project")
                    .FileVersion("1.2.0.0")
                    .InformationalVersion("1.2.0.0")
                    .KeyFile(@"c:\mykey.snk")
                    .KeyName("KeyName")
                    .Product("Product Name")
                    .Title("Title")
                    .Trademark("TM")
                    .Version("1.2.0.0")
                    .AddCustomAttribute("namespace.for.attribute", "AttributeName", true, "attributeValue"));

            var returnCode = Task.Run.Executable(exe => exe.ExecutablePath(@"c:\temp\myapp.exe").InWorkingDirectory(@"c:\temp\").AddArgument("c", "action1").AddArgument("s"));
            Task.Run.Executable(exe => exe.ExecutablePath(@"c:\temp\myapp.exe").ContinueOnError.SetTimeout(200));

            Task.Run.Zip.Compress(x=>x.SourceFile("temp.txt")
                .UsingCompressionLevel.Eight
                .UsingPassword("secretPassword")
                .To("output.zip"));

            Task.Run.Zip.Decompress(x=>x.Path("output.zip")
                .To(@"c:\temp\")
                .UsingPassword("secretPassword"));

            Defaults.Logger.WriteDebugMessage("Debug message");
            Defaults.Logger.WriteWarning("MyTask", "Warning");
            Defaults.Logger.WriteError("MyTask", "Error");

            Defaults.Logger.Verbosity = VerbosityLevel.None;
            Defaults.Logger.Verbosity = VerbosityLevel.Full;
            Defaults.Logger.Verbosity = VerbosityLevel.TaskDetails;
            Defaults.Logger.Verbosity = VerbosityLevel.TaskNamesOnly;

            Task.Run.Executable(exe => exe.ExecutablePath(@"c:\temp.exe"));
            using(Defaults.Logger.ShowDebugMessages)
            {
                Task.Run.Executable(exe => exe.ExecutablePath(@"c:\TempProcess.exe"));
            }

            Task.Run.Debugger();

            Properties.CommandLineProperties.GetProperty("ServerUsername");

            Task.Publish.Ftp(ftp => ftp.Server("ftp.myserver.com")
                .UserName("username")
                .Password("password")
                .LocalFilePath(@"c:\temp\project.zip")
                .RemoteFilePath(@"\release\project.zip")
                );

            Task.Publish.ToGoogleCode(google => google.UserName("user")
                .Password("pass")
                .LocalFileName(@"c:\temp\project.zip")
                .TargetFileName("project-1.0.0.0.zip")
                .ProjectName("projectName")
                .Summary("Summary for upload")
                );
        }
Exemple #20
0
 public static FileSet as_file_set(this File[] files)
 {
     var result = new FileSet();
     foreach (var item in files)
     {
         result.Include(item);
     }
     return result;
 }
Exemple #21
0
 public void OutputFileTo_ShouldWorkWithBuildArtifact()
 {
     string reference = "external.dll";
     var outputAssembly = new File("myapp.dll");
     string source = "myfile.cs";
     FileSet sources = new FileSet().Include(source);
     BuildTask build = new BuildTask("", "library").OutputFileTo(outputAssembly).AddRefences(reference).AddSources(sources).IncludeDebugSymbols;
     build.BuildArgs();
     Assert.That(build._argumentBuilder.Build().Trim(), Is.EqualTo(String.Format("/out:\"{0}\" /target:{1} /reference:\"{2}\" /debug \"{3}\"", outputAssembly, "library", reference, source)));
 }
Exemple #22
0
        public void Args_ShouldCreateProperReferences()
        {
            var references = new List<File>();
            references.Add(new File("ref1.dll"));
            references.Add(new File("ref2.dll"));

            string outputAssembly = "myapp.dll";
            string source = "myfile.cs";
            FileSet sources = new FileSet().Include(source);
            BuildTask build = new BuildTask("", "library").OutputFileTo(outputAssembly).AddRefences(references.ToArray()).AddSources(sources);
            build.BuildArgs();
            Assert.That(build._argumentBuilder.Build().Trim(), Is.EqualTo(String.Format("/out:\"{0}\" /target:{1} /reference:\"{2}\" /reference:\"{3}\" \"{4}\"", outputAssembly, "library", references[0], references[1], source)));
        }
Exemple #23
0
        private void CompileRunnerSources()
        {
            FileSet sourceFiles = new FileSet()
                .Include(directory_src_runner)
                .RecurseAllSubDirectories.Filter("*.cs");

             Task.Build.Csc.Target.Executable(x=>x.AddSources(sourceFiles)
                .AddRefences(assembly_FluentBuild_WithTests_Merged)
                .OutputFileTo(assembly_FluentBuild_Runner));
        }
Exemple #24
0
        /*
        private void PublishToNuGet()
        {
            //create a lib\net40\ folder
            Directory nuGetBaseFolder = directory_compile.SubFolder("nuget");
            Directory nuGetFolder = nuGetBaseFolder.Create().SubFolder("lib").Create().SubFolder("net40").Create();

            //copy the assemblies to it
            AssemblyFluentBuildRunnerRelease.Copy.To(nuGetFolder);
            //assembly_FluentBuild_UI.Copy.To(nuGetFolder);
            AssemblyFluentBuildRelease_Merged.Copy.To(nuGetFolder);

            //create the manifest file
            var sb = new StringBuilder();
            sb.AppendLine("<?xml version=\"1.0\"?>");
            sb.AppendLine("<package xmlns=\"http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd\">");
            sb.AppendLine("<metadata>");
            sb.AppendLine("<id>FluentBuild</id>");
            sb.AppendLine("<version>" + this._version + "</version>");
            sb.AppendLine("<authors>GotWoods</authors>");
            sb.AppendLine("<owners>GotWoods</owners>");
            sb.AppendLine("<projectUrl>http://code.google.com/p/fluent-build</projectUrl>");
            //sb.AppendLine("<iconUrl>http://ICON_URL_HERE_OR_DELETE_THIS_LINE</iconUrl>");
            sb.AppendLine("<requireLicenseAcceptance>false</requireLicenseAcceptance>");
            sb.AppendLine("<description>A build tool that allows you to write build scripts in a .NET language</description>");
            sb.AppendLine("<tags>build </tags>");
            sb.AppendLine("</metadata>");
            sb.AppendLine("</package>");

            using (var fs = new StreamWriter(nuGetBaseFolder.File("fluentBuild.nuspec").ToString()))
            {
                fs.Write(sb.ToString());
            }

            var pathToNuget = directory_tools.SubFolder("NuGet").File("NuGet.exe");

            //ensure latest version of nuget
            Task.Run.Executable(x => x.ExecutablePath(pathToNuget).WithArguments("Update -self"));

            //configure the API key
            Task.Run.Executable(x => x.ExecutablePath(pathToNuget).WithArguments("setApiKey " + Properties.CommandLineProperties.GetProperty("NuGetApiKey")));

            //package it
            Task.Run.Executable(x => x.ExecutablePath(pathToNuget).WithArguments("Pack fluentBuild.nuspec").InWorkingDirectory(nuGetBaseFolder));

            //NuGet Push YourPackage.nupkg
            Task.Run.Executable(x => x.ExecutablePath(pathToNuget).WithArguments("Push fluentBuild." + _version + ".nupkg").InWorkingDirectory(nuGetBaseFolder));
        }
         */
        private void CompileRunner()
        {
            FileSet sourceFiles = new FileSet()
                .Include(directory_base.SubFolder("src").SubFolder("FluentBuild.BuildExe"))
                .RecurseAllSubDirectories.Filter("*.cs");
            Task.Build.Csc.Target.Executable(x => x.AddSources(sourceFiles)
                                                      .AddRefences(AssemblyFluentBuildRelease_Merged)
                                                      .OutputFileTo(AssemblyFluentBuildRunnerRelease));
        }
Exemple #25
0
        private void CompileCoreSources()
        {
            var sourceFiles = new FileSet();
            sourceFiles.Include(directory_src_core).RecurseAllSubDirectories.Filter("*.cs");

            Task.Build.Csc.Target.Library(x => x
                .AddSources(sourceFiles)
                .IncludeDebugSymbols
                .AddRefences(thirdparty_rhino, thirdparty_nunit, thirdparty_sharpzip, thirdparty_fluentFs)
                .OutputFileTo(assembly_FluentBuild_WithTests_Partial)
                );

            Task.Run.ILMerge(x => x.ExecutableLocatedAt(@"tools\ilmerge\ilmerge.exe")
              .AddSource(assembly_FluentBuild_WithTests_Partial)
              .AddSource(thirdparty_sharpzip)
              .AddSource(thirdparty_fluentFs)
              .OutputTo(assembly_FluentBuild_WithTests_Merged));

            assembly_FluentBuild_WithTests_Partial.Delete();
        }
Exemple #26
0
 public void FilesetExamples()
 {
     var fs = new Core.FileSet().Include(new Directory("c:\\origin\\")).Filter("*.dll").Exclude(new File("*.config")).RecurseAllSubDirectories;
     var filesMatching = fs.Files; //gets all dll files and excludes all config files
     fs.Copy.To(@"c:\temp"); //copies all files matching to the destination
 }