Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/targets/nuget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ export const DEFAULT_NUGET_SERVER_URL = 'https://api.nuget.org/v3/index.json';
const DEFAULT_NUGET_REGEX = /^.*\d\.\d.*\.nupkg$/;
const SYMBOLS_NUGET_REGEX = /^.*\d\.\d.*\.snupkg$/;

/**
* Spawn options to run dotnet commands outside the repository folder to avoid global.json constraints
* (we don't need specific dotnet/workload versions just to upload to nuget)
*/
const DOTNET_SPAWN_OPTIONS = { cwd: '/' };

/** Nuget target configuration options */
export interface NugetTargetOptions {
/** Nuget API token */
Expand Down Expand Up @@ -75,10 +81,7 @@ export class NugetTarget extends BaseTarget {
'--source',
this.nugetConfig.serverUrl,
];
// Run outside the repository folder to avoid global.json constraints
// (we don't need specific dotnet/workload versions just to upload to nuget)
const spawnOptions = { cwd: '/' };
return spawnProcess(NUGET_DOTNET_BIN, args, spawnOptions);
return spawnProcess(NUGET_DOTNET_BIN, args, DOTNET_SPAWN_OPTIONS);
}

/**
Expand All @@ -104,12 +107,12 @@ export class NugetTarget extends BaseTarget {

// Emit the .NET version for informational purposes.
this.logger.info('.NET Version:');
await spawnProcess(NUGET_DOTNET_BIN, ['--version']);
await spawnProcess(NUGET_DOTNET_BIN, ['--version'], DOTNET_SPAWN_OPTIONS);

// Also emit the nuget version, which is informative and works around a bug.
// See https://github.com/NuGet/Home/issues/12159#issuecomment-1278360511
this.logger.info('Nuget Version:');
await spawnProcess(NUGET_DOTNET_BIN, ['nuget', '--version']);
await spawnProcess(NUGET_DOTNET_BIN, ['nuget', '--version'], DOTNET_SPAWN_OPTIONS);

await Promise.all(
packageFiles.map(async (file: RemoteArtifact) => {
Expand Down
Loading