Beispiel #1
0
        private void createZipFile(AssemblyPackageInput input, string childFolderName, ZipFileService zipService, FileSet fileSearch)
        {
            var zipRequest = BuildZipRequest(input, fileSearch);

            if (zipRequest == null)
            {
                ConsoleWriter.Write("No content for " + childFolderName);

                return;
            }

            // Hackey, but it makes /data and data/*.* work
            if (fileSystem.DirectoryExists(input.RootFolder.AppendPath(childFolderName)) && zipRequest.FileSet.Include.StartsWith(childFolderName, StringComparison.InvariantCultureIgnoreCase))
            {
                zipRequest.FileSet       = FileSet.Deep("*.*");
                zipRequest.RootDirectory = zipRequest.RootDirectory.AppendPath(childFolderName);
            }

            var zipFileName = "pak-{0}.zip".ToFormat(childFolderName);

            // do not create a zip file if there's no files there.
            if (!fileSystem.FindFiles(input.RootFolder, zipRequest.FileSet).Any())
            {
                Console.WriteLine("No matching files for Bottle directory " + childFolderName);

                var projectFileName = input.FindCsProjFile();
                var csProjFile      = CsProjFile.LoadFrom(projectFileName);
                if (csProjFile.Find <EmbeddedResource>(zipFileName) != null)
                {
                    csProjFile.Remove <EmbeddedResource>(zipFileName);
                    csProjFile.Save();
                }

                var zipFilePath = input.RootFolder.AppendPath(zipFileName);
                if (fileSystem.FileExists(zipFilePath))
                {
                    Console.WriteLine("Removing obsolete file " + zipFilePath);
                    fileSystem.DeleteFile(zipFilePath);
                }


                return;
            }


            var contentFile = FileSystem.Combine(input.RootFolder, zipFileName);

            ConsoleWriter.Write("Creating zip file " + contentFile);
            fileSystem.DeleteFile(contentFile);


            zipService.CreateZipFile(contentFile, file => file.AddFiles(zipRequest));

            if (input.ProjFileFlag.IsEmpty())
            {
                return;
            }

            attachZipFileToProjectFile(input, zipFileName);
        }
Beispiel #2
0
        public void SetUp()
        {
            var context = TemplatePlan.CreateClean("assembly-info");

            context.Add(new CreateSolution("AssemblyInfoSolution"));

            var project = new ProjectPlan("MyProject");

            context.Add(project);

            var system = new FileSystem();

            system.CreateDirectory("assembly-info");
            system.CreateDirectory("assembly-info", "src");
            system.CreateDirectory("assembly-info", "src", "MyProject");
            system.CreateDirectory("assembly-info", "src", "MyProject", "Properties");


            var expectedPath = "assembly-info".AppendPath("src", "MyProject", "Properties", "AssemblyInfo.cs");

            system.WriteStringToFile(expectedPath, @"using System.Reflection;

[assembly: AssemblyTitle('MyProject')]
".Replace("'", "\""));

            var alteration = new AssemblyInfoAlteration("using System.Reflection;", "[assembly: AssemblyTitle(\"%ASSEMBLYNAME%\")]", "using FubuMVC.Core;", "[assembly: FubuModule]");

            project.Add(alteration);

            context.Execute();

            theProject  = CsProjFile.LoadFrom("assembly-info".AppendPath("src", "MyProject", "MyProject.csproj"));
            theContents =
                new FileSystem().ReadStringFromFile(expectedPath);
        }
Beispiel #3
0
        public void can_write_embedded_resources()
        {
            fileSystem.WriteStringToFile("myproj".AppendPath("foo.txt"), "using System.Web;");
            fileSystem.WriteStringToFile("myproj".AppendPath("bar.txt"), "using System.Web;");

            var project = CsProjFile.CreateAtSolutionDirectory("MyProj", "myproj");

            project.Add <EmbeddedResource>("foo.txt");
            project.Add <EmbeddedResource>("bar.txt");

            project.Save();

            var project2 = CsProjFile.LoadFrom(project.FileName);

            project2.All <EmbeddedResource>().Select(x => x.Include)
            .ShouldHaveTheSameElementsAs("bar.txt", "foo.txt");

            project2.Add <EmbeddedResource>("ten.txt");
            project2.Add <EmbeddedResource>("aaa.txt");

            project2.Save();

            var project3 = CsProjFile.LoadFrom(project2.FileName);

            project3.All <EmbeddedResource>().Select(x => x.Include)
            .ShouldHaveTheSameElementsAs("aaa.txt", "bar.txt", "foo.txt", "ten.txt");
        }
Beispiel #4
0
        public void add_code_files()
        {
            fileSystem.WriteStringToFile("myproj".AppendPath("foo.cs"), "using System.Web;");
            fileSystem.WriteStringToFile("myproj".AppendPath("bar.cs"), "using System.Web;");

            var project = CsProjFile.CreateAtSolutionDirectory("MyProj", "myproj");

            project.Add <CodeFile>("foo.cs");
            project.Add <CodeFile>("bar.cs");

            project.Save();

            var project2 = CsProjFile.LoadFrom(project.FileName);

            project2.All <CodeFile>().Select(x => x.Include)
            .ShouldHaveTheSameElementsAs("bar.cs", "foo.cs");

            project2.Add <CodeFile>("ten.cs");
            project2.Add <CodeFile>("aaa.cs");

            project2.Save();

            var project3 = CsProjFile.LoadFrom(project2.FileName);

            project3.All <CodeFile>().Select(x => x.Include)
            .ShouldHaveTheSameElementsAs("aaa.cs", "bar.cs", "foo.cs", "ten.cs");
        }
Beispiel #5
0
        public void CanWriteEvenWhenFileVersionNotSpecified()
        {
            _fileSystem.Copy("AssemblyInfoWithMissingFileVersionAttribute.cs.fake", @"AssemblyInfoTester\Properties\AssemblyInfo.cs", CopyBehavior.overwrite);
            _project = CsProjFile.LoadFrom(@"AssemblyInfoTester\SlickGridHarness.csproj");

            var assemblyInfo = _project.AssemblyInfo;

            assemblyInfo.AssemblyVersion       = new Version(2, 0, 0, 0);
            assemblyInfo.AssemblyTitle         = "New AssemblyTitle";
            assemblyInfo.AssemblyDescription   = "New AssemblyDescription";
            assemblyInfo.AssemblyConfiguration = "New AssemblyConfiguration";
            assemblyInfo.AssemblyCompany       = "New AssemblyCompany";
            assemblyInfo.AssemblyProduct       = "New AssemblyProduct";
            assemblyInfo.AssemblyCopyright     = "New AssemblyCopyright";

            _project.Save();

            _project     = CsProjFile.LoadFrom(@"AssemblyInfoTester\SlickGridHarness.csproj");
            assemblyInfo = _project.AssemblyInfo;

            Assert.That(assemblyInfo.AssemblyVersion, Is.EqualTo(new Version(2, 0, 0, 0)));
            Assert.That(assemblyInfo.AssemblyFileVersion, Is.Null);
            Assert.That(assemblyInfo.AssemblyTitle, Is.EqualTo("New AssemblyTitle"));
            Assert.That(assemblyInfo.AssemblyDescription, Is.EqualTo("New AssemblyDescription"));
            Assert.That(assemblyInfo.AssemblyConfiguration, Is.EqualTo("New AssemblyConfiguration"));
            Assert.That(assemblyInfo.AssemblyCompany, Is.EqualTo("New AssemblyCompany"));
            Assert.That(assemblyInfo.AssemblyProduct, Is.EqualTo("New AssemblyProduct"));
            Assert.That(assemblyInfo.AssemblyCopyright, Is.EqualTo("New AssemblyCopyright"));
        }
Beispiel #6
0
        public void read_project_type_as_a_class_library_if_no_explicit_project_type()
        {
            var project = CsProjFile.LoadFrom("FubuMVC.SlickGrid.Docs.csproj");

            project.ProjectTypes().Single()
            .ShouldEqual(Guid.Parse("FAE04EC0-301F-11D3-BF4B-00C04F79EFBC"));
        }
Beispiel #7
0
        public void remove_code_file_2()
        {
            var project = CsProjFile.CreateAtSolutionDirectory("MyProj", "myproj");

            project.Add <CodeFile>("foo.cs");
            project.Add <CodeFile>("bar.cs");

            project.Save();

            var project2 = CsProjFile.LoadFrom(project.FileName);

            project2.All <CodeFile>().Select(x => x.Include)
            .ShouldHaveTheSameElementsAs("bar.cs", "foo.cs");

            project2.Remove <CodeFile>(project2.Find <CodeFile>("bar.cs"));
            project2.All <CodeFile>().Select(x => x.Include)
            .ShouldHaveTheSameElementsAs("foo.cs");

            project2.Save();

            var project3 = CsProjFile.LoadFrom(project.FileName);

            project3.All <CodeFile>().Select(x => x.Include)
            .ShouldHaveTheSameElementsAs("foo.cs");
        }
Beispiel #8
0
        public void CanWriteAllAtrributes()
        {
            var assemblyInfo = _project.AssemblyInfo;

            assemblyInfo.AssemblyVersion       = new Version(2, 0, 0, 0);
            assemblyInfo.AssemblyFileVersion   = new Version(2, 0, 0, 120);
            assemblyInfo.AssemblyTitle         = "New AssemblyTitle";
            assemblyInfo.AssemblyDescription   = "New AssemblyDescription";
            assemblyInfo.AssemblyConfiguration = "New AssemblyConfiguration";
            assemblyInfo.AssemblyCompany       = "New AssemblyCompany";
            assemblyInfo.AssemblyProduct       = "New AssemblyProduct";
            assemblyInfo.AssemblyCopyright     = "New AssemblyCopyright";

            _project.Save();

            _project     = CsProjFile.LoadFrom(@"AssemblyInfoTester\SlickGridHarness.csproj");
            assemblyInfo = _project.AssemblyInfo;

            Assert.That(assemblyInfo.AssemblyVersion, Is.EqualTo(new Version(2, 0, 0, 0)));
            Assert.That(assemblyInfo.AssemblyFileVersion, Is.EqualTo(new Version(2, 0, 0, 120)));
            Assert.That(assemblyInfo.AssemblyTitle, Is.EqualTo("New AssemblyTitle"));
            Assert.That(assemblyInfo.AssemblyDescription, Is.EqualTo("New AssemblyDescription"));
            Assert.That(assemblyInfo.AssemblyConfiguration, Is.EqualTo("New AssemblyConfiguration"));
            Assert.That(assemblyInfo.AssemblyCompany, Is.EqualTo("New AssemblyCompany"));
            Assert.That(assemblyInfo.AssemblyProduct, Is.EqualTo("New AssemblyProduct"));
            Assert.That(assemblyInfo.AssemblyCopyright, Is.EqualTo("New AssemblyCopyright"));
        }
Beispiel #9
0
        public void can_read_then_save_maintains_orginal_node_order()
        {
            // Can be important to maintain orginal node order to minimize merge conflicts checking in
            // changes to a proj file
            var origProj = CsProjFile.LoadFrom("SlickGridHarness.csproj");

            origProj.BuildProject.Settings = MSBuildProjectSettings.MinimizeChanges;
            origProj.Save("MyProj.csproj");

            origProj = CsProjFile.LoadFrom("SlickGridHarness.csproj");
            var newProj = CsProjFile.LoadFrom("MyProj.csproj");

            for (int i = 0; i < origProj.BuildProject.ItemGroups.Count(); i++)
            {
                var origGroup = origProj.BuildProject.ItemGroups.ElementAt(i);
                var newGroup  = newProj.BuildProject.ItemGroups.ElementAt(i);

                for (int j = 0; j < origGroup.Items.Count(); j++)
                {
                    var origItem = origGroup.Items.ElementAt(j);
                    var newItem  = newGroup.Items.ElementAt(j);

                    origItem.Include.ShouldEqual(newItem.Include);
                }
            }
        }
Beispiel #10
0
        public static void GenerateProject(YamlSpecification specification)
        {
            var project           = CsProjFile.LoadFrom(_testProjectFolder + @"Nest.Tests.Integration.Yaml.csproj");
            var existingYamlTests = project.All <CodeFile>().Where(c => c.Link != null && c.Link.EndsWith(".yaml.cs"));

            foreach (var c in existingYamlTests)
            {
                project.Remove(c);
            }

            var definitions = specification.Definitions;

            using (var pbar = new ProgressBar(definitions.Count, "Generating Code and project for yaml tests", ConsoleColor.Blue))
                foreach (var kv in specification.Definitions)
                {
                    var folder = kv.Key;
                    foreach (var d in kv.Value)
                    {
                        var path = folder + @"\" + d.FileName + ".cs";
                        if (!Directory.Exists(_testProjectFolder + folder))
                        {
                            Directory.CreateDirectory(_testProjectFolder + folder);
                        }

                        GenerateTestFileFromView(_testProjectFolder + path, d);
                        project.Add <CodeFile>(path);
                    }
                    pbar.Tick();
                }
            project.Save();
        }
Beispiel #11
0
        public void can_write_and_read_project_references()
        {
            var include = @"..\OtherProject\OtherProject.csproj";


            var project    = CsProjFile.CreateAtSolutionDirectory("MyProj", "myproj");
            var reference1 = new ProjectReference(include)
            {
                ProjectName = "OtherProject",
                ProjectGuid = Guid.NewGuid()
            };

            project.Add(reference1);

            project.Save();

            var project2 = CsProjFile.LoadFrom(project.FileName);

            var reference2 = project2.Find <ProjectReference>(reference1.Include);

            var all = project2.All <ProjectReference>();

            reference2.ShouldNotBeNull();
            reference2.ProjectName.ShouldEqual(reference1.ProjectName);
            reference2.ProjectGuid.ShouldEqual(reference1.ProjectGuid);
        }
Beispiel #12
0
        public void can_read_reference_with_hint_path()
        {
            var project = CsProjFile.LoadFrom("FubuMVC.SlickGrid.Docs.csproj");

            var reference = project.Find <AssemblyReference>("Rhino.Mocks");

            reference.HintPath.ShouldEqual(@"..\packages\RhinoMocks\lib\net\Rhino.Mocks.dll");
        }
Beispiel #13
0
        public void can_write_platform()
        {
            var project = CsProjFile.LoadFrom("SlickGridHarness.csproj");

            project.Platform = "x86";
            project.Save();

            project = CsProjFile.LoadFrom("SlickGridHarness.csproj");
            project.Platform.ShouldEqual("x86");
        }
Beispiel #14
0
        public void add_an_existing_project_to_a_new_solution()
        {
            var solution = Solution.CreateNew(@"solutions\sillydir", "newsolution");

            File.Copy("FubuMVC.SlickGrid.Docs.csproj.fake", "FubuMVC.SlickGrid.Docs.csproj", true);

            solution.AddProject(CsProjFile.LoadFrom("FubuMVC.SlickGrid.Docs.csproj"));

            solution.FindProject("FubuMVC.SlickGrid.Docs").ShouldNotBeNull();
        }
Beispiel #15
0
        public void can_write_target_framework()
        {
            var project = CsProjFile.LoadFrom("SlickGridHarness.csproj");

            project.TargetFrameworkVersion = "v4.5";
            project.Save();

            project = CsProjFile.LoadFrom("SlickGridHarness.csproj");
            project.TargetFrameworkVersion.ToString().ShouldEqual("v4.5");
        }
Beispiel #16
0
        public void can_read_shallow_system_assemblies()
        {
            var project = CsProjFile.LoadFrom("FubuMVC.SlickGrid.Docs.csproj");

            var assemblies = project.All <AssemblyReference>().Select(x => x.Include).ToArray();

            assemblies.ShouldContain("System");
            assemblies.ShouldContain("System.Core");
            assemblies.ShouldContain("System.Data");
            assemblies.ShouldContain("Rhino.Mocks");
        }
Beispiel #17
0
        public CsProjFile csprojFor(string name)
        {
            var files = new FileSystem().FindFiles(Environment.CurrentDirectory, FileSet.Deep(name + ".csproj"));

            if (files.Count() == 0)
            {
                Assert.Fail("Project {0} could not be found".ToFormat(name));
            }

            return(CsProjFile.LoadFrom(files.Single()));
        }
Beispiel #18
0
        public void write_link_element_value()
        {
            File.Copy("FubuMVC.SlickGrid.Docs.csproj.fake", "FubuMVC.SlickGrid.Docs.csproj", true);
            var project = CsProjFile.LoadFrom("FubuMVC.SlickGrid.Docs.csproj");

            project.Find <Content>(@"..\..\..\Config\App.config").Link = "App.exe.config";
            project.Save();

            project = CsProjFile.LoadFrom("FubuMVC.SlickGrid.Docs.csproj");
            project.Find <Content>(@"..\..\..\Config\App.config").Link.ShouldEqual("App.exe.config");
        }
        public void create_from_file()
        {
            var project = MSBuildProject.CreateFromFile("MyBar", Path.Combine("..", "..", "Project.txt"));

            project.Save("MyBar.csproj");

            var file = CsProjFile.LoadFrom("MyBar.csproj");

            file.ProjectName.ShouldEqual("MyBar");
            file.Find <AssemblyReference>("System.Data")
            .ShouldNotBeNull();     // this is in the csproj template in the testing project, but not the embedded one
        }
Beispiel #20
0
        public void write_and_then_read_the_dot_net_version_from_csprojfile()
        {
            var project = CsProjFile.LoadFrom("FubuMVC.SlickGrid.Docs.csproj");

            project.DotNetVersion = DotNetVersion.V45;

            project.Save("45Version.xml");

            var copy = CsProjFile.LoadFrom("45Version.xml");

            copy.DotNetVersion.ShouldEqual(DotNetVersion.V45);
        }
Beispiel #21
0
        public void removing_last_item_from_item_group_also_removes_item_group_element_from_project()
        {
            var project         = CsProjFile.LoadFrom("SlickGridHarness.csproj");
            var lastItemInGroup = project.Find <Content>("ripple.dependencies.config");

            project.Remove(lastItemInGroup);
            project.Save();

            fileSystem.ReadStringFromFile("SlickGridHarness.csproj").ShouldNotContain(
                @"  <ItemGroup>
  </ItemGroup>");
        }
Beispiel #22
0
        private void attachZipFileToProjectFile(AssemblyPackageInput input, string zipFileName)
        {
            // TODO -- determine the csproj file name magically?
            var projectFileName = input.FindCsProjFile();

            var csProjFile = CsProjFile.LoadFrom(projectFileName);

            if (csProjFile.Find <EmbeddedResource>(zipFileName) == null)
            {
                csProjFile.Add <EmbeddedResource>(zipFileName);
                csProjFile.Save();
            }
        }
Beispiel #23
0
        public void create_a_project_from_a_csproj_file_template()
        {
            executePlan(x =>
            {
                x.AddTemplate("Simple");
                x.AddProjectRequest(new ProjectRequest("MyProject", "CustomProjFile"));
            });

            assertFileExists("src", "MyProject", "MyProject.csproj");

            var csProjFile = CsProjFile.LoadFrom("integrated".AppendPath("src", "MyProject", "MyProject.csproj"));

            csProjFile.Find <AssemblyReference>("System.Data").ShouldNotBeNull(); // this reference is NOT in the default
        }
Beispiel #24
0
        public void can_write_system_assemblies()
        {
            var project = CsProjFile.CreateAtSolutionDirectory("MyProj", "myproj");

            project.Add <AssemblyReference>("System.Configuration");
            project.Add <AssemblyReference>("System.Security");

            project.Save();

            var project2 = CsProjFile.LoadFrom(project.FileName);

            project2.Find <AssemblyReference>("System.Configuration").ShouldNotBeNull();
            project2.Find <AssemblyReference>("System.Security").ShouldNotBeNull();
        }
        public void can_add_a_file_with_build_action_none()
        {
            var project = CsProjFile.CreateAtSolutionDirectory("MyProj", "myproj");
            var content = new None("packages.config");

            project.Add(content);

            project.Save();

            var project2 = CsProjFile.LoadFrom(project.FileName);

            project2.Find <None>("packages.config")
            .CopyToOutputDirectory.ShouldEqual(ContentCopy.Never);
        }
Beispiel #26
0
        public void can_read_embedded_resources()
        {
            // SAMPLE: loading-existing-file
            var project = CsProjFile.LoadFrom("FubuMVC.SlickGrid.Docs.csproj");

            // Add new references, code items, etc.

            project.Save();
            // ENDSAMPLE

            project = CsProjFile.LoadFrom(project.FileName);

            project.All <EmbeddedResource>().Select(x => x.Include)
            .ShouldHaveTheSameElementsAs("pak-Config.zip", "pak-Data.zip", "pak-WebContent.zip");
        }
Beispiel #27
0
        public void can_read_then_change_and_save_a_content_item()
        {
            var project = CsProjFile.LoadFrom("SlickGridHarness.csproj");

            var contentFile = project.Find <Content>(@"content\scripts\json2.js");

            contentFile.CopyToOutputDirectory.ShouldEqual(ContentCopy.Never);

            // modify
            contentFile.CopyToOutputDirectory = ContentCopy.Always;
            project.Save("MyProj.csproj");

            project = CsProjFile.LoadFrom("MyProj.csproj");
            project.Find <Content>(@"content\scripts\json2.js").CopyToOutputDirectory.ShouldEqual(ContentCopy.Always);
        }
Beispiel #28
0
        public void can_read_then_change_and_save_a_code_file()
        {
            var project = CsProjFile.LoadFrom("SlickGridHarness.csproj");

            var codeFile = project.Find <CodeFile>(@"Simple\SimpleEndpoint.cs");

            codeFile.Link.ShouldBeNull();

            // modify
            codeFile.Link = "SimpleEndpoint.cs";
            project.Save("MyProj.csproj");

            project = CsProjFile.LoadFrom("MyProj.csproj");
            project.Find <CodeFile>(@"Simple\SimpleEndpoint.cs").Link.ShouldEqual(@"SimpleEndpoint.cs");
        }
Beispiel #29
0
        public void can_read_then_change_a_reference_and_retrieve_the_modified_item_again()
        {
            var project = CsProjFile.LoadFrom("FubuMVC.SlickGrid.Docs.csproj");

            var reference = project.Find <AssemblyReference>("Rhino.Mocks");

            reference.HintPath.ShouldEqual(@"..\packages\RhinoMocks\lib\net\Rhino.Mocks.dll");

            // modify
            reference.HintPath = @"..\Modified\RhinoMocks\lib\net\Rhino.Mocks.dll";

            // retrieve again
            reference = project.Find <AssemblyReference>("Rhino.Mocks");
            reference.HintPath.ShouldEqual(@"..\Modified\RhinoMocks\lib\net\Rhino.Mocks.dll");
        }
Beispiel #30
0
        public void can_read_then_save_a_change_to_the_include_attribute()
        {
            var project = CsProjFile.LoadFrom("SlickGridHarness.csproj");

            var contentFile = project.Find <Content>(@"content\scripts\json2.js");

            contentFile.CopyToOutputDirectory.ShouldEqual(ContentCopy.Never);

            // modify
            contentFile.Include = @"content\scripts\json3.js";
            project.Save("MyProj.csproj");

            project = CsProjFile.LoadFrom("MyProj.csproj");
            project.Find <Content>(@"content\scripts\json3.js").ShouldNotBeNull();
        }