diff --git a/NuKeeper.Update/Process/DotNetUpdatePackageCommand.cs b/NuKeeper.Update/Process/DotNetUpdatePackageCommand.cs index c96f89a54..c8fff8b84 100644 --- a/NuKeeper.Update/Process/DotNetUpdatePackageCommand.cs +++ b/NuKeeper.Update/Process/DotNetUpdatePackageCommand.cs @@ -1,4 +1,6 @@ +using System; using System.Threading.Tasks; +using McMaster.Extensions.CommandLineUtils; using NuGet.Configuration; using NuGet.Versioning; using NuKeeper.Abstractions.NuGet; @@ -21,7 +23,7 @@ public async Task Invoke(PackageInProject currentPackage, { var projectPath = currentPackage.Path.Info.DirectoryName; var projectFileName = currentPackage.Path.Info.Name; - var sourceUrl = packageSource.SourceUri.ToString(); + var sourceUrl = UriEscapedForArgument(packageSource.SourceUri); var sources = allSources.CommandLine("-s"); var restoreCommand = $"restore {projectFileName} {sources}"; @@ -36,5 +38,15 @@ public async Task Invoke(PackageInProject currentPackage, var addCommand = $"add {projectFileName} package {currentPackage.Id} -v {newVersion} -s {sourceUrl}"; await _externalProcess.Run(projectPath, "dotnet", addCommand, true); } + + private static string UriEscapedForArgument(Uri uri) + { + if (uri == null) + { + return string.Empty; + } + + return ArgumentEscaper.EscapeAndConcatenate(new string[] { uri.ToString() }); + } } }