Skip to content

Commit

Permalink
Wrap csproj path in quotes.
Browse files Browse the repository at this point in the history
  • Loading branch information
timcassell committed Feb 23, 2024
1 parent 8f345fb commit 30c675c
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/BenchmarkDotNet/Toolchains/DotNetCli/DotNetCliCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ internal static IEnumerable<string> GetAddPackagesCommands(BuildPartition buildP

internal static string GetRestoreCommand(ArtifactsPaths artifactsPaths, BuildPartition buildPartition, string csProjPath, string? extraArguments = null, string? binLogSuffix = null, bool excludeOutput = false)
=> new StringBuilder()
.AppendArgument($"restore {csProjPath}")
.AppendArgument("restore")
.AppendArgument(string.IsNullOrEmpty(csProjPath) ? string.Empty : $"\"{csProjPath}\"")
.AppendArgument(string.IsNullOrEmpty(artifactsPaths.PackagesDirectoryName) ? string.Empty : $"--packages \"{artifactsPaths.PackagesDirectoryName}\"")
.AppendArgument(GetCustomMsBuildArguments(buildPartition.RepresentativeBenchmarkCase, buildPartition.Resolver))
.AppendArgument(extraArguments)
Expand All @@ -170,7 +171,9 @@ internal static string GetRestoreCommand(ArtifactsPaths artifactsPaths, BuildPar

internal static string GetBuildCommand(ArtifactsPaths artifactsPaths, BuildPartition buildPartition, string csProjPath, string? extraArguments = null, string? binLogSuffix = null, bool excludeOutput = false)
=> new StringBuilder()
.AppendArgument($"build {csProjPath} -c {buildPartition.BuildConfiguration}") // we don't need to specify TFM, our auto-generated project contains always single one
.AppendArgument("build")
.AppendArgument(string.IsNullOrEmpty(csProjPath) ? string.Empty : $"\"{csProjPath}\"")
.AppendArgument($"-c {buildPartition.BuildConfiguration}") // we don't need to specify TFM, our auto-generated project contains always single one
.AppendArgument(GetCustomMsBuildArguments(buildPartition.RepresentativeBenchmarkCase, buildPartition.Resolver))
.AppendArgument(extraArguments)
.AppendArgument(GetMandatoryMsBuildSettings(buildPartition.BuildConfiguration))
Expand All @@ -181,7 +184,9 @@ internal static string GetBuildCommand(ArtifactsPaths artifactsPaths, BuildParti

internal static string GetPublishCommand(ArtifactsPaths artifactsPaths, BuildPartition buildPartition, string csProjPath, string? extraArguments = null, string? binLogSuffix = null)
=> new StringBuilder()
.AppendArgument($"publish {csProjPath} -c {buildPartition.BuildConfiguration}") // we don't need to specify TFM, our auto-generated project contains always single one
.AppendArgument("publish")
.AppendArgument(string.IsNullOrEmpty(csProjPath) ? string.Empty : $"\"{csProjPath}\"")
.AppendArgument($"-c {buildPartition.BuildConfiguration}") // we don't need to specify TFM, our auto-generated project contains always single one
.AppendArgument(GetCustomMsBuildArguments(buildPartition.RepresentativeBenchmarkCase, buildPartition.Resolver))
.AppendArgument(extraArguments)
.AppendArgument(GetMandatoryMsBuildSettings(buildPartition.BuildConfiguration))
Expand Down Expand Up @@ -235,9 +240,11 @@ private static string GetMandatoryMsBuildSettings(string buildConfiguration)

private static string BuildAddPackageCommand(NuGetReference reference, string csProjPath)
{
var commandBuilder = new StringBuilder();
commandBuilder.AppendArgument($"add {csProjPath} package");
commandBuilder.AppendArgument(reference.PackageName);
var commandBuilder = new StringBuilder()
.AppendArgument("add")
.AppendArgument(string.IsNullOrEmpty(csProjPath) ? string.Empty : $"\"{csProjPath}\"")
.AppendArgument("package")
.AppendArgument(reference.PackageName);
if (!string.IsNullOrWhiteSpace(reference.PackageVersion))
{
commandBuilder.AppendArgument("-v");
Expand Down

0 comments on commit 30c675c

Please sign in to comment.