diff --git a/src/targets/nuget.ts b/src/targets/nuget.ts index 0a35a04f..0bd48d35 100644 --- a/src/targets/nuget.ts +++ b/src/targets/nuget.ts @@ -14,7 +14,8 @@ export const NUGET_DOTNET_BIN = process.env.NUGET_DOTNET_BIN || 'dotnet'; export const DEFAULT_NUGET_SERVER_URL = 'https://api.nuget.org/v3/index.json'; /** A regular expression used to find the package tarball */ -const DEFAULT_NUGET_REGEX = /^.*\d\.\d.*\.s?nupkg$/; +const DEFAULT_NUGET_REGEX = /^.*\d\.\d.*\.nupkg$/; +const SYMBOLS_NUGET_REGEX = /^.*\d\.\d.*\.snupkg$/; /** Nuget target configuration options */ export interface NugetTargetOptions { @@ -87,6 +88,9 @@ export class NugetTarget extends BaseTarget { const packageFiles = await this.getArtifactsForRevision(revision, { includeNames: DEFAULT_NUGET_REGEX, }); + const symbolFiles = await this.getArtifactsForRevision(revision, { + includeNames: SYMBOLS_NUGET_REGEX, + }); if (!packageFiles.length) { reportError( @@ -106,8 +110,24 @@ export class NugetTarget extends BaseTarget { await Promise.all( packageFiles.map(async (file: RemoteArtifact) => { const path = await this.artifactProvider.downloadArtifact(file); + + // If an artifact containing a .snupkg file exists with the same base + // name as the .nupkg file, then download it to the same location. + // It will be picked up automatically when pushing the .nupkg. + + // Note, this approach is required vs sending them separately, because + // we need to send the .nupkg *first*, and it must succeed before the + // .snupkg is sent. + + const symbolFileName = file.filename.replace('.nupkg', '.snupkg'); + const symbolFile = symbolFiles.find(f => f.filename === symbolFileName); + if (symbolFile) { + await this.artifactProvider.downloadArtifact(symbolFile); + } + this.logger.info( - `Uploading file "${file.filename}" via "dotnet nuget"` + `Uploading file "${file.filename}" via "dotnet nuget"` + + (symbolFile ? `, including symbol file "${symbolFile.filename}"` : '') ); return this.uploadAsset(path); })