Ejemplo n.º 1
0
        public static FilePath GetFilePathForEnvironment()
        {
            var defaultFileName = AppSettings.GetFileNameForEnvironment();

            var defaultFilePath = PathUtilitiesExtra.RelativeToCurrentDirectory(defaultFileName);

            return(defaultFilePath);
        }
Ejemplo n.º 2
0
        public static PackageDirectoryPath GetPackageDirectoryPath(LocalDirectoryNugetRepository repository, PackageID packageID)
        {
            var packageDirectoryName = NuGetIoUtilities.GetPackageDirectoryName(packageID);

            var packageDirectoryPath = PathUtilitiesExtra.Combine(repository.DirectoryPath, packageDirectoryName).Value.AsPackageDirectoryPath();

            return(packageDirectoryPath);
        }
Ejemplo n.º 3
0
        public static void ListAllPackageVersions(LocalDirectoryNugetRepository repository, PackageID packageID, TextWriter writer)
        {
            var packageDirectoryName = NuGetIoUtilities.GetPackageDirectoryName(packageID);

            var packageDirectoryPath = PathUtilitiesExtra.Combine(repository.DirectoryPath, packageDirectoryName).Value.AsPackageDirectoryPath();

            LocalDirectoryNugetRepository.ListAllPackageVersions(packageDirectoryPath, writer);
        }
Ejemplo n.º 4
0
        public static VersionDirectoryPath GetPackageVersionDirectoryPath(LocalDirectoryNugetRepository repository, PackageID packageID, Version packageVersion)
        {
            var packageDirectoryPath = LocalDirectoryNugetRepository.GetPackageDirectoryPath(repository, packageID);

            var versionDirectoryName = NuGetIoUtilities.GetVersionDirectoryName(packageVersion);

            var packageVersionDirectoryPath = PathUtilitiesExtra.Combine(packageDirectoryPath, versionDirectoryName).Value.AsVersionDirectoryPath();

            return(packageVersionDirectoryPath);
        }
        private static void ProcessListSolutionProjectReferencesOutput(object sender, DataReceivedEventArgs e, SolutionFilePath solutionFilePath, List <ProjectFilePath> projectFilePaths)
        {
            var dataString = e.Data ?? String.Empty;

            using (var reader = new StringReader(dataString))
            {
                while (!reader.ReadLineIsEnd(out string line))
                {
                    if (String.IsNullOrWhiteSpace(line) || line == "Project(s)" || line == "----------")
                    {
                        continue;
                    }

                    var projectFileRelativePath = new FileRelativePath(line);
                    var projectFilePath         = PathUtilitiesExtra.GetFilePath(solutionFilePath, projectFileRelativePath).AsProjectFilePath();

                    projectFilePaths.Add(projectFilePath);
                }
            }
        }
        public static NupkgFilePath Pack(FilePath dotnetExecutableFilePath, ProjectFilePath projectFilePath, DirectoryPath outputDirectoryPath, PackageID packageID, IEnumerable <string> sources, ILogger logger)
        {
            // Determine the project version.
            var projectVersion = VsUtilities.GetVersion(projectFilePath);

            var packageFileName = NugetIoUtilities.GetNupkgFileName(packageID, projectVersion);

            // Determine the .nupkg file-name and file-path (using output directory-path, project ID, project version, and .nupkg file-extension).
            var packageFilePath = PathUtilitiesExtra.GetFilePath(outputDirectoryPath, packageFileName).AsNupkgFilePath();

            logger.LogDebug($"{projectFilePath} - Packing project to:\n{packageFilePath}");

            var arguments = $@"pack ""{projectFilePath}"" --output ""{outputDirectoryPath}"" -p:PackageID={packageID}";

            if (sources.Count() > 0)
            {
                foreach (var source in sources)
                {
                    arguments = arguments.Append($@" --source ""{source}""");
                }
            }

            var outputCollector = ProcessRunner.Run(dotnetExecutableFilePath.Value, arguments);

            // Test for success.
            var lastLine = outputCollector.GetOutputLines().Last().Trim();

            var expectedLastLine = $"Successfully created package '{packageFilePath}'.";

            if (expectedLastLine != lastLine)
            {
                throw new Exception($"dotnet automation error. Command:\n{ ProcessRunner.GetCommandLineIncantation(dotnetExecutableFilePath.Value, arguments) }\n\nOutput:\n{ outputCollector.GetOutputText()}\n\nError:\n{ outputCollector.GetErrorText()}\n");
            }

            logger.LogInformation($"{projectFilePath} - Packed project to:\n{packageFilePath}");

            return(packageFilePath);
        }
        private static void ProcessListProjectProjectReferencesOutput(object sender, DataReceivedEventArgs e, ProjectFilePath projectFilePath, List <ProjectFilePath> projectFilePaths)
        {
            var projectDirectoryPath = PathUtilities.GetDirectoryPath(projectFilePath);

            var dataString = e.Data ?? String.Empty;

            using (var reader = new StringReader(dataString))
            {
                while (!reader.ReadLineIsEnd(out string line))
                {
                    if (String.IsNullOrWhiteSpace(line) || line == "Project reference(s)" || line == "--------------------" || line.BeginsWith("There are no Project to Project references in project"))
                    {
                        continue;
                    }

                    var referencedProjectFileRelativePath = new FileRelativePath(line);
                    // Project file relative paths are relative to the project directory path.
                    var referenedProjectFilePath = PathUtilitiesExtra.GetFilePath(projectDirectoryPath, referencedProjectFileRelativePath).AsProjectFilePath();

                    projectFilePaths.Add(referenedProjectFilePath);
                }
            }
        }
Ejemplo n.º 8
0
        public static SolutionFilePath GetSolutionFilePath(SolutionDirectoryPath solutionDirectoryPath, SolutionFileName solutionFileName)
        {
            var solutionFilePath = PathUtilitiesExtra.GetFilePath(solutionDirectoryPath, solutionFileName).AsSolutionFilePath();

            return(solutionFilePath);
        }
Ejemplo n.º 9
0
        public static ProjectFilePath GetProjectFilePath(ProjectDirectoryPath projectDirectoryPath, ProjectFileName projectFileName)
        {
            var projectFilePath = PathUtilitiesExtra.GetFilePath(projectDirectoryPath, projectFileName).AsProjectFilePath();

            return(projectFilePath);
        }