public AssemblyInfo(CodeFile codeFile, CsProjFile projFile)
 {
     _codeFile        = codeFile;
     _projFile        = projFile;
     this._fileSystem = new FileSystem();
     this.Initialize();
 }
        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);
            });
        }
示例#3
0
 public AssemblyInfo(CodeFile codeFile, CsProjFile projFile)
 {
     _codeFile = codeFile;
     _projFile = projFile;
     this._fileSystem = new FileSystem();
     this.Initialize();
 }
示例#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;
 }
 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;
 }
 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;
 }
示例#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;
 }
        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);
            }
        }
示例#9
0
        public void RemoveProject(CsProjFile project)
        {
            var existing = FindProject(project.ProjectName);

            if (existing == null)
            {
                return;
            }

            _projects.Remove(existing);
        }
示例#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);
        }
示例#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);
        }
        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());
        }
示例#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);
        }
示例#14
0
 /// <summary>
 /// Adds an existing project
 /// </summary>
 /// <param name="project"></param>
 public void AddProject(CsProjFile project)
 {
     AddProject(ParentDirectory, project);
 }
示例#15
0
 public void AddProject(CsProjFile project)
 {
     _projects.Fill(project);
 }
示例#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);
     }
 }
示例#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());
        }
示例#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);
        }
        public static SolutionProject CreateNewAt(string solutionDirectory, string projectName)
        {
            var csProjFile = CsProjFile.CreateAtSolutionDirectory(projectName, solutionDirectory);

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

            _projects.Remove(existing);
        }
示例#21
0
 /// <summary>
 /// Adds an existing project
 /// </summary>
 /// <param name="project"></param>
 public void AddProject(CsProjFile project)
 {
     AddProject(ParentDirectory, project);
 }
示例#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;
        }
示例#23
0
 public void AddProject(CsProjFile project)
 {
     _projects.Fill(project);
 }
        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());
        }