Skip to content

Commit 287a96c

Browse files
authored
fix: [OSM-1797] Fixing bugs related to paths with spaces (#214)
* fix: fixing bugs related to paths with spaces * fix: dropping that pointless restore parsing logic
1 parent 556dde5 commit 287a96c

File tree

6 files changed

+2774
-30
lines changed

6 files changed

+2774
-30
lines changed

lib/nuget-parser/cli/dotnet.ts

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as debugModule from 'debug';
2-
import * as errors from '../../errors';
32
import { CliCommandError } from '../../errors';
43
import * as path from 'path';
54
import * as subprocess from './subprocess';
@@ -51,36 +50,18 @@ export async function validate(): Promise<string> {
5150
}
5251
}
5352

54-
export async function restore(projectPath: string): Promise<string> {
53+
export async function restore(projectPath: string): Promise<void> {
5554
const command = 'dotnet';
5655
const args = [
5756
'restore',
5857
// Get a larger amount of debugging information to stdout in case something fails.
5958
// Useful for customers to attempt self-debugging before raising support requests.
6059
'--verbosity',
6160
'normal',
62-
projectPath,
61+
`"${projectPath}"`,
6362
];
64-
const result = await handle('restore', command, args);
65-
66-
// A customer can define a <BaseOutPutPath> that redirects where `dotnet` saves the assets file. This will
67-
// get picked up by the dotnet tool and reported in the output logs.
68-
const regex = /Path:\s+(\S+project.assets.json)/g;
69-
const matches = result.stdout.matchAll(regex);
70-
71-
const manifestFiles: string[] = [];
72-
for (const match of matches) {
73-
manifestFiles.push(match[1]);
74-
}
75-
76-
if (manifestFiles.length === 0) {
77-
throw new errors.FileNotProcessableError(
78-
'found no information in stdout about the whereabouts of the assets file',
79-
);
80-
}
81-
82-
// Return the last element in the log, as it might be mentioning local asset files in reverse order.
83-
return manifestFiles[manifestFiles.length - 1];
63+
await handle('restore', command, args);
64+
return;
8465
}
8566

8667
export async function run(
@@ -128,7 +109,7 @@ export async function publish(
128109

129110
// The path that contains either some form of project file, or a .sln one.
130111
// See: https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-publish#arguments
131-
args.push(projectPath);
112+
args.push(`"${projectPath}"`);
132113

133114
await handle('publish', command, args);
134115

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
6+
</PropertyGroup>
7+
<ItemGroup>
8+
<PackageReference Include="NSubstitute" Version="4.3.0" />
9+
</ItemGroup>
10+
</Project>

0 commit comments

Comments
 (0)