Skip to content

Commit

Permalink
fix: [OSM-1797] Fixing bugs related to paths with spaces (#214)
Browse files Browse the repository at this point in the history
* fix: fixing bugs related to paths with spaces

* fix: dropping that pointless restore parsing logic
  • Loading branch information
dotkas authored Jun 28, 2024
1 parent 556dde5 commit 287a96c
Show file tree
Hide file tree
Showing 6 changed files with 2,774 additions and 30 deletions.
29 changes: 5 additions & 24 deletions lib/nuget-parser/cli/dotnet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as debugModule from 'debug';
import * as errors from '../../errors';
import { CliCommandError } from '../../errors';
import * as path from 'path';
import * as subprocess from './subprocess';
Expand Down Expand Up @@ -51,36 +50,18 @@ export async function validate(): Promise<string> {
}
}

export async function restore(projectPath: string): Promise<string> {
export async function restore(projectPath: string): Promise<void> {
const command = 'dotnet';
const args = [
'restore',
// Get a larger amount of debugging information to stdout in case something fails.
// Useful for customers to attempt self-debugging before raising support requests.
'--verbosity',
'normal',
projectPath,
`"${projectPath}"`,
];
const result = await handle('restore', command, args);

// A customer can define a <BaseOutPutPath> that redirects where `dotnet` saves the assets file. This will
// get picked up by the dotnet tool and reported in the output logs.
const regex = /Path:\s+(\S+project.assets.json)/g;
const matches = result.stdout.matchAll(regex);

const manifestFiles: string[] = [];
for (const match of matches) {
manifestFiles.push(match[1]);
}

if (manifestFiles.length === 0) {
throw new errors.FileNotProcessableError(
'found no information in stdout about the whereabouts of the assets file',
);
}

// Return the last element in the log, as it might be mentioning local asset files in reverse order.
return manifestFiles[manifestFiles.length - 1];
await handle('restore', command, args);
return;
}

export async function run(
Expand Down Expand Up @@ -128,7 +109,7 @@ export async function publish(

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

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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NSubstitute" Version="4.3.0" />
</ItemGroup>
</Project>
Loading

0 comments on commit 287a96c

Please sign in to comment.