Ejemplo n.º 1
0
 public AssemblyInfo(CodeFile codeFile, CsProjFile projFile)
 {
     _codeFile        = codeFile;
     _projFile        = projFile;
     this._fileSystem = new FileSystem();
     this.Initialize();
 }
Ejemplo n.º 2
0
        public SolutionProject(string text, string solutionDirectory)
        {
            var parts = text.ToDelimitedArray('=');

            _projectType = Guid.Parse(parts.First().TextBetweenSquiggles());
            _projectGuid = Guid.Parse(parts.Last().TextBetweenSquiggles());

            var secondParts = parts.Last().ToDelimitedArray();

            _projectName  = secondParts.First().TextBetweenQuotes();
            _relativePath = secondParts.ElementAt(1).TextBetweenQuotes().Replace("\\", "/"); // Windows is forgiving


            _project = new Lazy <CsProjFile>(() => {
                var filename = solutionDirectory.AppendPath(_relativePath);

                if (File.Exists(filename))
                {
                    var projFile = CsProjFile.LoadFrom(filename);
                    this.InitializeFromSolution(projFile, this.Solution);
                    return(projFile);
                }

                var project         = CsProjFile.CreateAtLocation(filename, _projectName);
                project.ProjectGuid = _projectGuid;

                return(project);
            });
        }
Ejemplo n.º 3
0
 public AssemblyInfo(CodeFile codeFile, CsProjFile projFile)
 {
     _codeFile = codeFile;
     _projFile = projFile;
     this._fileSystem = new FileSystem();
     this.Initialize();
 }
Ejemplo n.º 4
0
 public ProjectReference(CsProjFile targetProject, CsProjFile reference) : base("ProjectReference")
 {
     this.Include = Path.Combine(reference.ProjectDirectory.PathRelativeTo(targetProject.ProjectDirectory),
                                 Path.GetFileName(reference.FileName));
     this.ProjectGuid = reference.ProjectGuid;
     this.ProjectName = reference.ProjectName;
 }
Ejemplo n.º 5
0
 public SolutionProject(CsProjFile csProjFile, string solutionDirectory)
 {
     _project      = new Lazy <CsProjFile>(() => csProjFile);
     _projectName  = csProjFile.ProjectName;
     _relativePath = csProjFile.FileName.PathRelativeTo(solutionDirectory);
     _projectType  = csProjFile.ProjectTypes().LastOrDefault();
     _projectGuid  = csProjFile.ProjectGuid;
 }
Ejemplo n.º 6
0
 public ProjectReference(CsProjFile targetProject, CsProjFile reference)
     : base("ProjectReference")
 {
     this.Include = Path.Combine(reference.ProjectDirectory.PathRelativeTo(targetProject.ProjectDirectory),
         Path.GetFileName(reference.FileName));
     this.ProjectGuid = reference.ProjectGuid;
     this.ProjectName = reference.ProjectName;
 }
Ejemplo n.º 7
0
 public SolutionProject(CsProjFile csProjFile, string solutionDirectory)
 {
     _project = new Lazy<CsProjFile>(() => csProjFile);
     _projectName = csProjFile.ProjectName;
     _relativePath = csProjFile.FileName.PathRelativeTo(solutionDirectory);
     _projectType = csProjFile.ProjectTypes().LastOrDefault();
     _projectGuid = csProjFile.ProjectGuid;
 }
Ejemplo n.º 8
0
        private void InitializeFromSolution(CsProjFile projFile, Solution solution)
        {
            var tfsSourceControl = solution.Sections.FirstOrDefault(section => section.SectionName.Equals("TeamFoundationVersionControl"));

            if (tfsSourceControl != null)
            {
                this.InitializeTfsSourceControlSettings(projFile, solution, tfsSourceControl);
            }
        }
Ejemplo n.º 9
0
        public void RemoveProject(CsProjFile project)
        {
            var existing = FindProject(project.ProjectName);

            if (existing == null)
            {
                return;
            }

            _projects.Remove(existing);
        }
Ejemplo n.º 10
0
        private static CsProjFile CreateCore(MSBuildProject project, string fileName)
        {
            var group = project.PropertyGroups.FirstOrDefault(x => x.Properties.Any(p => p.Name == PROJECTGUID)) ??
                        project.PropertyGroups.FirstOrDefault() ?? project.AddNewPropertyGroup(true);

            @group.SetPropertyValue(PROJECTGUID, Guid.NewGuid().ToString().ToUpper(), true);

            var file = new CsProjFile(fileName, project);

            file.AssemblyName = file.RootNamespace = file.ProjectName;
            return(file);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Adds an existing project to the given <paramref name="solutionDirectory"/>.
        /// </summary>
        /// <param name="solutionDirectory"></param>
        /// <param name="project"></param>
        public void AddProject(string solutionDirectory, CsProjFile project)
        {
            var existing = FindProject(project.ProjectName);

            if (existing != null)
            {
                return;
            }

            var reference = new SolutionProject(project, solutionDirectory);

            this._projects.Add(reference);
        }
Ejemplo n.º 12
0
        private void InitializeTfsSourceControlSettings(CsProjFile projFile, Solution solution, GlobalSection tfsSourceControl)
        {
            var projUnique = tfsSourceControl.Properties.FirstOrDefault(item => item.EndsWith(Path.GetFileName(projFile.FileName)));

            if (projUnique == null)
            {
                return;
            }

            int index =
                Convert.ToInt32(projUnique.Substring("SccProjectUniqueName".Length,
                                                     projUnique.IndexOf('=') - "SccProjectUniqueName".Length).Trim());

            projFile.SourceControlInformation = new SourceControlInformation(
                tfsSourceControl.Properties.First(item => item.StartsWith("SccProjectUniqueName" + index)).Split('=')[1].Trim(),
                tfsSourceControl.Properties.First(item => item.StartsWith("SccProjectName" + index)).Split('=')[1].Trim(),
                tfsSourceControl.Properties.First(item => item.StartsWith("SccLocalPath" + index)).Split('=')[1].Trim());
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Adds a new project based on the supplied template file
        /// </summary>
        /// <param name="projectName"></param>
        /// <param name="templateFile"></param>
        public SolutionProject AddProjectFromTemplate(string projectName, string templateFile)
        {
            var existing = FindProject(projectName);

            if (existing != null)
            {
                ThrowExceptions.ArgumentOutOfRangeException(Exc.GetStackTrace(), type, Exc.CallingMethod(), "projectName", "Project with this name ({0}) already exists in the solution".ToFormat(projectName));
            }


            var project    = MSBuildProject.CreateFromFile(projectName, templateFile);
            var csProjFile = new CsProjFile(ParentDirectory.AppendPath(projectName, projectName + ".csproj"), project);

            csProjFile.ProjectGuid = Guid.NewGuid();

            var reference = new SolutionProject(csProjFile, ParentDirectory);

            _projects.Add(reference);

            return(reference);
        }
Ejemplo n.º 14
0
 /// <summary>
 /// Adds an existing project
 /// </summary>
 /// <param name="project"></param>
 public void AddProject(CsProjFile project)
 {
     AddProject(ParentDirectory, project);
 }
Ejemplo n.º 15
0
 public void AddProject(CsProjFile project)
 {
     _projects.Fill(project);
 }
Ejemplo n.º 16
0
 private void InitializeFromSolution(CsProjFile projFile, Solution solution)
 {
     var tfsSourceControl = solution.Sections.FirstOrDefault(section => section.SectionName.Equals("TeamFoundationVersionControl"));
     if (tfsSourceControl != null)
     {
         this.InitializeTfsSourceControlSettings(projFile, solution, tfsSourceControl);
     }
 }
Ejemplo n.º 17
0
        private void InitializeTfsSourceControlSettings(CsProjFile projFile, Solution solution, GlobalSection tfsSourceControl)
        {
            var projUnique = tfsSourceControl.Properties.FirstOrDefault(item => item.EndsWith(Path.GetFileName(projFile.FileName)));
            if (projUnique == null)
            {
                return;
            }

            int index =
                Convert.ToInt32(projUnique.Substring("SccProjectUniqueName".Length,
                    projUnique.IndexOf('=') - "SccProjectUniqueName".Length).Trim());

            projFile.SourceControlInformation = new SourceControlInformation(
                tfsSourceControl.Properties.First(item => item.StartsWith("SccProjectUniqueName" + index)).Split('=')[1].Trim(),
                tfsSourceControl.Properties.First(item => item.StartsWith("SccProjectName" + index)).Split('=')[1].Trim(),
                tfsSourceControl.Properties.First(item => item.StartsWith("SccLocalPath" + index)).Split('=')[1].Trim());
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Adds an existing project
        /// </summary>
        /// <param name="project"></param>
        public void AddProject(CsProjFile project)
        {
            var existing = FindProject(project.ProjectName);
            if (existing != null)
            {
                return;
            }

            var reference = new SolutionProject(project, this.ParentDirectory);
            this._projects.Add(reference);
        }
Ejemplo n.º 19
0
        public static SolutionProject CreateNewAt(string solutionDirectory, string projectName)
        {
            var csProjFile = CsProjFile.CreateAtSolutionDirectory(projectName, solutionDirectory);

            return(new SolutionProject(csProjFile, solutionDirectory));
        }
Ejemplo n.º 20
0
        public void RemoveProject(CsProjFile project)
        {
            var existing = FindProject(project.ProjectName);
            if (existing == null)
            {
                return;
            }

            _projects.Remove(existing);
        }
Ejemplo n.º 21
0
 /// <summary>
 /// Adds an existing project
 /// </summary>
 /// <param name="project"></param>
 public void AddProject(CsProjFile project)
 {
     AddProject(ParentDirectory, project);
 }
Ejemplo n.º 22
0
        /// <summary>
        /// Adds a new project based on the supplied template file
        /// </summary>
        /// <param name="projectName"></param>
        /// <param name="templateFile"></param>
        /// <returns></returns>
        public SolutionProject AddProjectFromTemplate(string projectName, string templateFile)
        {
            var existing = FindProject(projectName);
            if (existing != null)
            {
                throw new ArgumentOutOfRangeException("projectName", "Project with this name ({0}) already exists in the solution".ToFormat(projectName));
            }

            var project = MSBuildProject.CreateFromFile(projectName, templateFile);
            var csProjFile = new CsProjFile(ParentDirectory.AppendPath(projectName, projectName + ".csproj"), project);
            csProjFile.ProjectGuid = Guid.NewGuid();

            var reference = new SolutionProject(csProjFile, ParentDirectory);
            _projects.Add(reference);

            return reference;
        }
Ejemplo n.º 23
0
 public void AddProject(CsProjFile project)
 {
     _projects.Fill(project);
 }
Ejemplo n.º 24
0
        public void build_project_with_assembly_info_fubu_test(SolutionBuilderContext context, ISolutionContext solutionContext, FubuCsProjFile.CsProjFile project)
        {
            "Given I have a solution builder context"
            ._(() => context = ServiceLocator.Resolve <SolutionBuilderContext>());

            "When I call build with a solution, a project and an assembly info"
            ._(() => solutionContext = context.CreateBuilder()
                                       .WithSolution(item => item.Path = Path.Combine(context.RootDirectory, "Sally.sln"))
                                       .WithProject(item => item.Name  = "FrodoFx")
                                       .WithFile <AssemblyInfo>(item =>
            {
                item.Title                = "FrodoFx";
                item.Description          = "Middle earth web server";
                item.FileVersion          = new Version(0, 0, 1, 2049);
                item.Version              = new Version(0, 0, 1);
                item.InformationalVersion = "release";
            })
                                       .Build());

            "It should return the build project with an assembly info"
            ._(() =>
            {
                project = new CsProjFile(solutionContext.Solution.Projects.FirstOrDefault().Path);
                project.Should().NotBeNull("the project should not be null");

                project.AssemblyInfo.Should().NotBeNull("the assembly info should not be null");
            });

            "And the assembly info title should be set"
            ._(() => project.AssemblyInfo.AssemblyTitle.Should().Be("FrodoFx"))
            .Teardown(() => context.TearDown());
        }