/// <summary> /// Provides any project file paths referenced by the input project file, and any project file paths referenced by those project file paths, and so on recursively, until all project file paths are accumulated. /// </summary> public static ProjectFilePath[] GetProjectReferencedProjectFilePathsRecursive(ProjectFilePath projectFilePath, ILogger logger) { var uniqueProjects = new HashSet <ProjectFilePath>(); var queue = new Queue <ProjectFilePath>(); queue.Enqueue(projectFilePath); // Do not include the initial project file path in the output list of referenced project file paths. while (queue.Count > 0) { var currentProjectFilePath = queue.Dequeue(); logger.LogDebug($"Getting project-references for: {currentProjectFilePath}"); var currentProjectReferencedProjects = DotnetCommandServicesProvider.GetProjectReferencedProjectFilePaths(currentProjectFilePath); foreach (var referencedProject in currentProjectReferencedProjects) { if (!uniqueProjects.Contains(referencedProject)) { uniqueProjects.Add(referencedProject); queue.Enqueue(referencedProject); } } } var projectFilePaths = new List <ProjectFilePath>(uniqueProjects); projectFilePaths.Sort(); return(projectFilePaths.ToArray()); }
public static NupkgFilePath Pack(FilePath dotnetExecutableFilePath, ProjectFilePath projectFilePath, DirectoryPath outputDirectoryPath, ILogger logger) { // Determine the package ID. var packageID = NugetUtilities.GetDefaultPackageID(projectFilePath); var packageFilePath = DotnetCommandServicesProvider.Pack(dotnetExecutableFilePath, projectFilePath, outputDirectoryPath, packageID, Enumerable.Empty <string>(), logger); return(packageFilePath); }
public static void Pack(FilePath dotnetExecutableFilePath, ProjectFilePath projectFilePath, NupkgFilePath nupkgFilePath, ILogger logger) { var packageDirectoryPath = PathUtilities.GetDirectoryPath(nupkgFilePath); // Use the pack command to get the package file-path created by dotnet. var defaultPackageFilePath = DotnetCommandServicesProvider.Pack(dotnetExecutableFilePath, projectFilePath, packageDirectoryPath, logger); // If the package file-path created by dotnet is not the same as the specified package file-path, copy the file to the new path. if (nupkgFilePath.Value != defaultPackageFilePath.Value) { File.Copy(defaultPackageFilePath.Value, nupkgFilePath.Value, true); File.Delete(defaultPackageFilePath.Value); } }
/// <summary> /// Creates a solution file at the specified file-path. /// </summary> /// <remarks> /// This method feeds the solution directory-path and solution-name value required to have the dotnet new command create a solution-file at the specified path. /// </remarks> public static void CreateSolutionFile(SolutionFilePath solutionFilePath, DotnetNewConventions conventions, ILogger logger) { var solutionDirectoryPath = PathUtilities.GetDirectoryPath(solutionFilePath).AsSolutionDirectoryPath(); var solutionFileName = PathUtilities.GetFileName(solutionFilePath).AsSolutionFileName(); var solutionFileNameWithoutExtension = PathUtilities.GetFileNameWithoutExtension(solutionFileName); var solutionName = conventions.SolutionNameFromSolutionFileNameWithoutExtension(solutionFileNameWithoutExtension); var createdSolutionFilePath = DotnetCommandServicesProvider.CreateSolutionFile(solutionDirectoryPath, solutionName, logger); // Throw an exception if the solution file-path created by dotnet new is not the one we were expecting. if (createdSolutionFilePath.Value != solutionFilePath.Value) { throw new Exception($"Solution creation file path mismatch.\nExpected: {solutionFilePath}\nCreated: {createdSolutionFilePath}"); } }
public static void CreateProjectFile(DotnetNewProjectType projectType, ProjectFilePath projectFilePath, DotnetNewConventions conventions, ILogger logger) { var projectDirectoryPath = PathUtilities.GetDirectoryPath(projectFilePath).AsProjectDirectoryPath(); var projectFileName = PathUtilities.GetFileName(projectFilePath).AsProjectFileName(); var projectFileNameWithoutExtension = PathUtilities.GetFileNameWithoutExtension(projectFileName); var projectName = conventions.ProjectNameFromProjectFileNameWithoutExtension(projectFileNameWithoutExtension); var createdProjectFilePath = DotnetCommandServicesProvider.CreateProjectFile(projectType, projectName, projectDirectoryPath, logger); // Throw an exception if the solution file-path created by dotnet new is not the one we were expecting. if (createdProjectFilePath.Value != projectFilePath.Value) { throw new Exception($"Project creation file path mismatch.\nExpected: {projectFilePath}\nCreated: {createdProjectFilePath}"); } }
public static ProjectFilePath[] GetProjectReferencedProjectFilePaths(ProjectFilePath projectFilePath) { // Get all project file paths that are referenced by the solution file path. var arguments = $@"list ""{projectFilePath}"" reference"; var projectFilePaths = new List <ProjectFilePath>(); var runOptions = new ProcessRunOptions { Command = DotnetCommand.Value, Arguments = arguments, ReceiveOutputData = (sender, e) => DotnetCommandServicesProvider.ProcessListProjectProjectReferencesOutput(sender, e, projectFilePath, projectFilePaths), }; ProcessRunner.Run(runOptions); return(projectFilePaths.ToArray()); }
public static ProjectFilePath[] GetProjectReferencedProjectFilePathsRecursive(ProjectFilePath projectFilePath) { var projectFilePaths = DotnetCommandServicesProvider.GetProjectReferencedProjectFilePathsRecursive(projectFilePath, DummyLogger.Instance); return(projectFilePaths); }
/// <summary> /// Uses the <see cref="DotnetNewConventions.Instance"/>. /// </summary> public static void CreateSolutionFile(SolutionFilePath solutionFilePath, ILogger logger) { DotnetCommandServicesProvider.CreateSolutionFile(solutionFilePath, DotnetNewConventions.Instance, logger); }
public void RemoveProject(SolutionFilePath solutionFilePath, ProjectFilePath projectFilePath) { DotnetCommandServicesProvider.RemoveProjectFileFromSolutionFile(solutionFilePath, projectFilePath, this.Logger); }
public ProjectFilePath[] GetProjectReferencedFilePathsRecursive(ProjectFilePath projectFilePath) { var projectFilePaths = DotnetCommandServicesProvider.GetProjectReferencedProjectFilePathsRecursive(projectFilePath); return(projectFilePaths); }
public static NupkgFilePath Pack(this DotnetCommand command, ProjectFilePath projectFilePath, DirectoryPath outputDirectoryPath, PackageID packageID, IEnumerable <string> sources) { var packageFilePath = DotnetCommandServicesProvider.Pack(command.DotnetExecutableFilePath, projectFilePath, outputDirectoryPath, packageID, sources, command.Logger); return(packageFilePath); }
public static NupkgFilePath Pack(this DotnetCommand command, ProjectFilePath projectFilePath, DirectoryPath outputDirectoryPath) { var packageFilePath = DotnetCommandServicesProvider.Pack(command.DotnetExecutableFilePath, projectFilePath, outputDirectoryPath, command.Logger); return(packageFilePath); }
public void CreateProjectFile(DotnetNewProjectType projectType, ProjectFilePath projectFilePath) { DotnetCommandServicesProvider.CreateProjectFile(projectType, projectFilePath, this.Logger); }
public void AddProjectReference(ProjectFilePath projectFilePath, ProjectFilePath referenceProjectFilePath) { DotnetCommandServicesProvider.AddProjectFileProjectReference(projectFilePath, referenceProjectFilePath, this.Logger); }
public void AddPackageReference(ProjectFilePath projectFilePath, PackageSpecification package) { DotnetCommandServicesProvider.AddPackageToProject(projectFilePath, package, this.Logger); }
public void CreateSolutionFile(SolutionFilePath solutionFilePath) { DotnetCommandServicesProvider.CreateSolutionFile(solutionFilePath, this.Logger); }
public PackageSpecification[] GetPackageReferences(ProjectFilePath projectFilePath) { var packageSpecifications = DotnetCommandServicesProvider.GetPackageReferences(projectFilePath); return(packageSpecifications); }
public static void CreateProjectFile(DotnetNewProjectType projectType, ProjectFilePath projectFilePath) { DotnetCommandServicesProvider.CreateProjectFile(projectType, projectFilePath, DummyLogger.Instance); }
/// <summary> /// Uses the <see cref="DotnetNewConventions.Instance"/>. /// </summary> public static void CreateProjectFile(DotnetNewProjectType projectType, ProjectFilePath projectFilePath, ILogger logger) { DotnetCommandServicesProvider.CreateProjectFile(projectType, projectFilePath, DotnetNewConventions.Instance, logger); }
public void AddProject(SolutionFilePath solutionFilePath, ProjectFilePath projectFilePath) { DotnetCommandServicesProvider.AddProjectFileToSolutionFile(solutionFilePath, projectFilePath, this.Logger); }