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);
        }