public Project(FilePath projectPath, CustomProjectParserResult projectParserResult) { ProjectPath = projectPath; ProjectParserResult = projectParserResult; ProjectRoot = ProjectPath.GetDirectory(); ProjectName = ProjectRoot.GetDirectoryName(); }
public static IEnumerable <string> EnumerateSourceFiles(this CustomProjectParserResult project, string folder = null) { folder ??= project.GetDirectory(); const string ObjFolder = "obj"; const string OutputFolder = "bin"; const string SearchPattern = "*.cs"; foreach (var file in System.IO.Directory.EnumerateFiles(folder, SearchPattern, System.IO.SearchOption.TopDirectoryOnly)) { yield return(file); } var ignoredSubFolders = new HashSet <string>() { ObjFolder, OutputFolder }; foreach (var subFolder in System.IO.Directory.EnumerateDirectories(folder)) { var subFolderName = new System.IO.DirectoryInfo(subFolder).Name; if (ignoredSubFolders.Contains(subFolderName)) { continue; } foreach (var file in System.IO.Directory.EnumerateFiles(subFolder, SearchPattern, System.IO.SearchOption.AllDirectories)) { yield return(file); } } }
public void GetAssemblyFilePath_ReturnsExpectedFilePath() { var result = GetSolutionParserResult().Projects.First(); var parserResult = new CustomProjectParserResult { AssemblyName = "a", OutputPath = "./b", OutputType = "library" }; result.GetAssemblyFilePath(parserResult).ToString().Should().Be("/b/a.dll"); }
internal ProjectReference(Cake.Core.IO.FilePath path, string workingDirectory, string targetFramework, string configuration, string platform = "AnyCPU") { if (path.IsRelative) { _environment.WorkingDirectory = workingDirectory; path = path.MakeAbsolute(_environment); } _project = _fileSystem.GetFile(path).ParseProjectFile(_configuration = configuration, _platform = platform); _folder = _project.ProjectFilePath.GetDirectory().FullPath; _target = targetFramework ?? _project.TargetFrameworkVersions.Single(); }
public Project(FilePath projectPath, CustomProjectParserResult projectParserResult) { ProjectPath = projectPath; ProjectParserResult = projectParserResult; }
public static string GetDirectory(this CustomProjectParserResult project) { return(project.ProjectFilePath.GetDirectory().FullPath); }
public static IEnumerable <(string folder, CustomProjectParserResult project)> EnumerateProjects(this CustomProjectParserResult mainProject) { var result = new Dictionary <string, CustomProjectParserResult>(); void AddReferences(string folderPath, CustomProjectParserResult project) { foreach (var referencedProject in project.ProjectReferences.Select(p => ParseProject(p.FilePath, folderPath, project.Configuration, project.Platform))) { var directory = referencedProject.GetDirectory(); if (result.TryAdd(directory, referencedProject)) { AddReferences(directory, referencedProject); } else if (!string.Equals(referencedProject.ProjectFilePath.FullPath, result[directory].ProjectFilePath.FullPath, StringComparison.OrdinalIgnoreCase)) { throw new Exception("Found two or more projects in the same directory."); } } } var mainDirectory = mainProject.GetDirectory(); result.Add(mainDirectory, mainProject); AddReferences(mainDirectory, mainProject); foreach (var pair in result) { yield return(pair.Key, pair.Value); } }
/// <summary> /// Gets the output assembly path for a SolutionProject /// </summary> /// <param name="solutionProject">The solutionproject</param> /// <param name="project">The parsed project</param> /// <returns>The SolutionProject output assembly path</returns> /// <example> /// Gets an absolute assembly path for a project /// <code> /// var projects = ParseSolution(new FilePath("test.sln")).GetProjects(); /// project[0].GetAssemblyFilePath(); /// </code> /// </example> public static FilePath GetAssemblyFilePath(this SolutionProject solutionProject, CustomProjectParserResult project) { solutionProject.ThrowIfNull(nameof(solutionProject)); project.ThrowIfNull(nameof(project)); var assemblyFilePath = project.GetAssemblyFilePath(); return(solutionProject.Path.GetDirectory().CombineWithFilePath(assemblyFilePath)); }