public void SolutionOutputPathUsesGivenValueIfSet()
        {
            string slnOutputPath = @"C:\Projects\Solutions";
            options = new SlnGenerationOptions(@"C:\Projects") {SlnOutputPath = slnOutputPath};

            Assert.That(options.SlnOutputPath, Is.EqualTo(slnOutputPath));
        }
        public void RelativeProjectsRootDirIsRootedAtWorkingDir()
        {
            options = new SlnGenerationOptions(WorkingDirectory);
            options.ProjectsRootDirectory = Path.Combine("Proj", "Root");

            Assert.That(options.SlnOutputPath, Is.EqualTo (Path.Combine (WorkingDirectory, "Proj", "Root")));
        }
        public void RelativeProjectsRootDirIsRootedAtWorkingDir()
        {
            options = new SlnGenerationOptions(@"C:\WorkingDir");
            options.ProjectsRootDirectory = @"Proj\Root";

            Assert.That(options.SlnOutputPath, Is.EqualTo(@"C:\WorkingDir\Proj\Root"));
        }
        public void RelativeSlnOutputPathRootedAtProjectsRoot()
        {
            options = new SlnGenerationOptions(@"C:\Proj\Root");
            options.SlnOutputPath = "Solutions";

            Assert.That(options.SlnOutputPath, Is.EqualTo(@"C:\Proj\Root\Solutions"));
        }
        public void AdditionalSearchPathsRootedAtProjectRoot()
        {
            options = new SlnGenerationOptions(@"C:\Proj\Root");
            options.AddAdditionalSearchPaths(@"..\SearchPath", @"..\..\OtherPath\Pork");

            Assert.That(options.AdditionalSearchPaths, Is.EqualTo(new[] {@"C:\Proj\Root\..\SearchPath", @"C:\Proj\Root\..\..\OtherPath\Pork"}));
        }
Пример #6
0
        public void SpecifiedMultipleTargetProjects()
        {
            options = ArgsOptionsBuilder.BuildOptions(new[] { "--target", "MyProject", "--target", "YourProject" }, WorkingDirectory);

            Assert.That(options.TargetProjectNames, Is.EqualTo(new[] { "MyProject", "YourProject" }));
            Assert.That(options.SolutionName, Is.StringMatching("MyProject_YourProject"));
        }
        public void SolutionOutputPathUsesGivenValueIfSet()
        {
            string slnOutputPath = GetSamplePath("Projects", "Solutions");
            options = new SlnGenerationOptions(GetSamplePath("Projects")) {SlnOutputPath = slnOutputPath};

            Assert.That(options.SlnOutputPath, Is.EqualTo(slnOutputPath));
        }
Пример #8
0
        public string GenerateSolutionFile(SlnGenerationOptions options)
        {
            LogSummary(options);

            List<CsProj> projects = ProjectRepository.LookupCsProjsFromDirectory(options);
            Sln solution = SlnBuilder.GetSlnBuilder(projects).BuildSln(options);

            if (options.FixHintPaths)
            {
                new HintPathConverter().ConvertHintPaths(solution, options);
            }

            if (options.ConvertReferences)
            {
                new ReferenceConverter().ConvertToProjectReferences(solution);
            }
            else if (options.RestoreReferences)
            {
                new ReferenceConverter().RestoreAssemblyReferences(solution);
            }

            if (options.RestoreHintPaths)
            {
                new HintPathConverter().RestoreHintPaths(solution, options);
            }

            WarnOnMissingNuGetTargets(projects, options);

            return SlnWriter.WriteSlnFile(solution, options.SlnOutputPath).FullName;
        }
        public void RelativeSlnOutputPathRootedAtProjectsRoot()
        {
            var root = GetSamplePath ("Proj", "Root");
            options = new SlnGenerationOptions (root);
            options.SlnOutputPath = "Solutions";

            Assert.That(options.SlnOutputPath, Is.EqualTo(Path.Combine(root, "Solutions")));
        }
Пример #10
0
        public SlnGenerationOptions Build(string[] args, string workingDirectory)
        {
            options = new SlnGenerationOptions(workingDirectory);

            ProcessArguments(args);

            return options;
        }
Пример #11
0
 public void RestoreHintPaths(Sln solution, SlnGenerationOptions options)
 {
     var packagesDir = Path.Combine(options.SlnOutputPath, "packages");
     foreach (var project in solution.Projects)
     {
         ConvertProjectHintPaths(project, packagesDir, Mode.Restore);
     }
 }
        public void AdditionalSearchPathsRootedAtProjectRoot()
        {
            var root = GetSamplePath ("Proj", "Root");
            options = new SlnGenerationOptions(root);
            var path1 = Path.Combine("..", "SearchPath");
            var path2 = Path.Combine("..", "..", "OtherPath", "Pork");
            options.AddAdditionalSearchPaths (path1, path2);

            Assert.That(options.AdditionalSearchPaths, Is.EqualTo(new[] {Path.Combine(root, path1), Path.Combine(root, path2)}));
        }
Пример #13
0
 private void AddProjectsToSln(SlnGenerationOptions options)
 {
     if (options.Mode == SlnGenerationMode.PartialGraph)
     {
         AddPartialProjectGraphToSln(options);
     }
     else
     {
         AddAllProjectsToSln();
     }
 }
Пример #14
0
 public void BeforeEach()
 {
     options = new SlnGenerationOptions(WorkingDirectory);
     finder = MockRepository.GenerateStrictMock<ProjectFileFinder>();
     reader = MockRepository.GenerateStrictMock<CsProjReader>();
     repository = new CsProjRepository
     {
         Finder = finder,
         Reader = reader
     };
 }
Пример #15
0
 private void LogSummary(SlnGenerationOptions options)
 {
     Log.InfoFormat("SlimJim solution file generator.");
     Log.InfoFormat("");
     Log.InfoFormat("----------------------------------------");
     Log.InfoFormat("Target projects:             {0}", SummarizeTargetProjects(options));
     Log.InfoFormat("Destination:                 {0}", Path.Combine(options.SlnOutputPath, options.SolutionName + ".sln"));
     Log.InfoFormat("Visual Studio Version:       {0}", options.VisualStudioVersion);
     Log.InfoFormat("Dinosaur:                    {0}", GetDinosaur());
     Log.InfoFormat("----------------------------------------");
     Log.InfoFormat("");
 }
Пример #16
0
        public virtual Sln BuildSln(SlnGenerationOptions options)
        {
            this.options = options;
            builtSln     = new Sln(options.SolutionName)
            {
                Version = options.VisualStudioVersion,
                ProjectsRootDirectory = options.ProjectsRootDirectory
            };

            AddProjectsToSln(options);

            return(builtSln);
        }
Пример #17
0
        public virtual Sln BuildSln(SlnGenerationOptions options)
        {
            this.options = options;
            builtSln = new Sln(options.SolutionName)
                {
                    Version = options.VisualStudioVersion,
                    ProjectsRootDirectory = options.ProjectsRootDirectory
                };

            AddProjectsToSln(options);

            return builtSln;
        }
        public void UnspecifiedSolutionNameWithNoTargetProjectsUsesFolderName()
        {
            options = new SlnGenerationOptions(WorkingDirectory);
            Assert.That(options.SolutionName, Is.EqualTo("WorkingDir"));

            options = new SlnGenerationOptions(Path.Combine(WorkingDirectory, "SlumJim"));
            Assert.That(options.SolutionName, Is.EqualTo("SlumJim"));

            options = new SlnGenerationOptions(Path.Combine(WorkingDirectory, "SlumJim") + Path.DirectorySeparatorChar + Path.DirectorySeparatorChar);
            Assert.That(options.SolutionName, Is.EqualTo("SlumJim"));

            options = new SlnGenerationOptions(Path.DirectorySeparatorChar.ToString());
            Assert.That(options.SolutionName, Is.EqualTo("SlimJim"));
        }
Пример #19
0
        public void BeforeEach()
        {
            repo = MockRepository.GenerateStrictMock<CsProjRepository>();
            slnWriter = MockRepository.GenerateStrictMock<SlnFileWriter>();
            slnBuilder = MockRepository.GenerateStrictMock<SlnBuilder>(new List<CsProj>());

            gen = new SlnFileGenerator()
            {
                ProjectRepository = repo,
                SlnWriter = slnWriter
            };

            SlnBuilder.OverrideDefaultBuilder(slnBuilder);
            options = new SlnGenerationOptions(ProjectsDir);
        }
Пример #20
0
        private void AddPartialProjectGraphToSln(SlnGenerationOptions options)
        {
            Log.Info("Building partial graph solution for target projects: " + string.Join(", ", options.TargetProjectNames));

            foreach (string targetProjectName in options.TargetProjectNames)
            {
                CsProj rootProject = AddAssemblySubtree(targetProjectName);

                if (rootProject == null)
                {
                    Log.WarnFormat("Project {0} not found.", targetProjectName);
                }

                AddAfferentReferencesToProject(rootProject);
            }
        }
Пример #21
0
        public void UnspecifiedSolutionNameWithNoTargetProjectsUsesFolderName()
        {
            options = new SlnGenerationOptions(WorkingDirectory);
            Assert.That(options.SolutionName, Is.EqualTo("WorkingDir"));

            options = new SlnGenerationOptions(@"R:\Code\Projects\CSharp\SlumJim");
            Assert.That(options.SolutionName, Is.EqualTo("SlumJim"));

            options = new SlnGenerationOptions(@"R:\Code\Projects\CSharp\SlumJim\");
            Assert.That(options.SolutionName, Is.EqualTo("SlumJim"));

            options = new SlnGenerationOptions(@"R:\");
            Assert.That(options.SolutionName, Is.EqualTo("R"));

            options = new SlnGenerationOptions(@"\");
            Assert.That(options.SolutionName, Is.EqualTo("SlimJim"));
        }
Пример #22
0
        public void SpecifiedAdditionalSearchPaths()
        {
            options = ArgsOptionsBuilder.BuildOptions(new[] { "--search", @"C:\OtherProjects", "--search", @"C:\MoreProjects" }, WorkingDirectory);

            Assert.That(options.AdditionalSearchPaths, Is.EqualTo(new[] { @"C:\OtherProjects", @"C:\MoreProjects" }));
        }
Пример #23
0
        public void ShowHelpIsSetOnOptions()
        {
            options = ArgsOptionsBuilder.BuildOptions(new[] { "--help" }, WorkingDirectory);

            Assert.That(options.ShowHelp, Is.True, "ShowHelp");
        }
Пример #24
0
 public void ShowHelp()
 {
     options = ArgsOptionsBuilder.BuildOptions(new[] {"--help"}, WorkingDirectory);
     // check console output
 }
Пример #25
0
        public void InvalidVisualStudioVersionNumber()
        {
            options = ArgsOptionsBuilder.BuildOptions(new[] { "--version", "dumb" }, WorkingDirectory);

            Assert.That(options.VisualStudioVersion, Is.EqualTo(VisualStudioVersion.VS2010));
        }
Пример #26
0
        public void IncludeEfferentAssemblyReferences()
        {
            options = ArgsOptionsBuilder.BuildOptions(new[] { @"--all" }, WorkingDirectory);

            Assert.That(options.IncludeEfferentAssemblyReferences, Is.True, "IncludeEfferentAssemblyReferences");
        }
Пример #27
0
        public void SpecifiedSlnOuputPath()
        {
            options = ArgsOptionsBuilder.BuildOptions(new[] { "--out", @"C:\MyProjects\Sln" }, WorkingDirectory);

            Assert.That(options.SlnOutputPath, Is.EqualTo(@"C:\MyProjects\Sln"));
        }
Пример #28
0
 public void UnspecifiedSolutionNameWithMultipleTargetProjectsUsesFirstProjectNamePlusSuffix()
 {
     options = ArgsOptionsBuilder.BuildOptions(new[] { "--target", "MyProject", "--target", "YourProject" }, WorkingDirectory);
 }
Пример #29
0
        public void TestDefaults()
        {
            options = ArgsOptionsBuilder.BuildOptions(new string[0], WorkingDirectory);

            Assert.That(options.ProjectsRootDirectory, Is.EqualTo(WorkingDirectory), "ProjectsRootDirectory");
            Assert.That(options.TargetProjectNames, Is.Empty, "TargetProjectNames");
            Assert.That(options.Mode, Is.EqualTo(SlnGenerationMode.FullGraph), "Mode");
            Assert.That(options.AdditionalSearchPaths, Is.Empty, "AdditionalSearchPaths");
            Assert.That(options.IncludeEfferentAssemblyReferences, Is.False, "IncludeEfferentAssemblyReferences");
            Assert.That(options.ShowHelp, Is.False, "ShowHelp");
            Assert.That(options.OpenInVisualStudio, Is.False, "OpenInVisualStudio");
        }
Пример #30
0
        public void SpecifiedProjectsRootDirectory()
        {
            options = ArgsOptionsBuilder.BuildOptions(new[] { "--root", @"C:\MyProjects" }, WorkingDirectory);

            Assert.That(options.ProjectsRootDirectory, Is.EqualTo(@"C:\MyProjects"));
        }
Пример #31
0
 public void UnspecifiedSolutionNameWithSingleTargetProject()
 {
     options = ArgsOptionsBuilder.BuildOptions(new[] { "--target", "MyProject" }, WorkingDirectory);
 }
Пример #32
0
        public void SpecifiedSolutionName()
        {
            options = ArgsOptionsBuilder.BuildOptions(new[] { "--name", "MyProjects" }, WorkingDirectory);

            Assert.That(options.SolutionName, Is.EqualTo("MyProjects"));
        }
Пример #33
0
        public void IgnoresFolderNames()
        {
            options = ArgsOptionsBuilder.BuildOptions(new[] {"--ignore", "Folder1", "--ignore", "Folder2"}, WorkingDirectory);

            Assert.That(options.IgnoreDirectoryPatterns, Is.EqualTo(new[] {"Folder1", "Folder2"}));
        }