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

Commit fd7b5e5

Browse files
authored
Fix issue when project filenames contains whitespaces (#1093)
1 parent a87453e commit fd7b5e5

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

NuKeeper.Integration.Tests/NuGet/Process/DotNetUpdatePackageCommandTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,13 @@ public async Task ShouldUpdateDotnetClassicWithPackageReference()
109109
await ExecuteValidUpdateTest(_testDotNetClassicProject, PackageReferenceType.ProjectFileOldStyle);
110110
}
111111

112+
[Test]
113+
public async Task ShouldUpdateProjectFilenameWithSpaces()
114+
{
115+
await ExecuteValidUpdateTest(_testDotNetClassicProject, PackageReferenceType.ProjectFileOldStyle, "Project With Spaces.csproj");
116+
}
117+
118+
112119
private async Task ExecuteValidUpdateTest(
113120
string testProjectContents,
114121
PackageReferenceType packageReferenceType,

NuKeeper.Update/Process/DotNetUpdatePackageCommand.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,20 @@ public async Task Invoke(PackageInProject currentPackage,
3737
}
3838

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

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

4747
if (currentPackage.Path.PackageReferenceType == PackageReferenceType.ProjectFileOldStyle)
4848
{
49-
var removeCommand = $"remove {projectFileName} package {currentPackage.Id}";
49+
var removeCommand = $"remove {projectFileNameCommandLine} package {currentPackage.Id}";
5050
await _externalProcess.Run(projectPath, "dotnet", removeCommand, true);
5151
}
5252

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

0 commit comments

Comments
 (0)