Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Commit

Permalink
Fix issue when project filenames contains whitespaces (#1093)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwlin authored Sep 20, 2021
1 parent a87453e commit fd7b5e5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ public async Task ShouldUpdateDotnetClassicWithPackageReference()
await ExecuteValidUpdateTest(_testDotNetClassicProject, PackageReferenceType.ProjectFileOldStyle);
}

[Test]
public async Task ShouldUpdateProjectFilenameWithSpaces()
{
await ExecuteValidUpdateTest(_testDotNetClassicProject, PackageReferenceType.ProjectFileOldStyle, "Project With Spaces.csproj");
}


private async Task ExecuteValidUpdateTest(
string testProjectContents,
PackageReferenceType packageReferenceType,
Expand Down
8 changes: 4 additions & 4 deletions NuKeeper.Update/Process/DotNetUpdatePackageCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@ public async Task Invoke(PackageInProject currentPackage,
}

var projectPath = currentPackage.Path.Info.DirectoryName;
var projectFileName = currentPackage.Path.Info.Name;
var projectFileNameCommandLine = ArgumentEscaper.EscapeAndConcatenate(new string[] { currentPackage.Path.Info.Name });
var sourceUrl = UriEscapedForArgument(packageSource.SourceUri);
var sources = allSources.CommandLine("-s");

var restoreCommand = $"restore {projectFileName} {sources}";
var restoreCommand = $"restore {projectFileNameCommandLine} {sources}";
await _externalProcess.Run(projectPath, "dotnet", restoreCommand, true);

if (currentPackage.Path.PackageReferenceType == PackageReferenceType.ProjectFileOldStyle)
{
var removeCommand = $"remove {projectFileName} package {currentPackage.Id}";
var removeCommand = $"remove {projectFileNameCommandLine} package {currentPackage.Id}";
await _externalProcess.Run(projectPath, "dotnet", removeCommand, true);
}

var addCommand = $"add {projectFileName} package {currentPackage.Id} -v {newVersion} -s {sourceUrl}";
var addCommand = $"add {projectFileNameCommandLine} package {currentPackage.Id} -v {newVersion} -s {sourceUrl}";
await _externalProcess.Run(projectPath, "dotnet", addCommand, true);
}

Expand Down

0 comments on commit fd7b5e5

Please sign in to comment.