I have created an application using dotnet core. I am building it as a self-contained package. I am attempting to publish it to an Azure artifact server using the pipeline UI. I have been able to successfully build the self-contained package, and have been able to successfully publish it to the drop. I have not been able to figure out how to get the NuGet pack command (and subsequent Nuget push) to pick up the self-contained package to place as a downloadable package on the artifact server.
Here is the YAML for my publish task:
steps:
- task: DotNetCoreCLI@2
displayName: 'dotnet publish'
inputs:
command: publish
publishWebProjects: false
projects: '**/TelemetryReceiver.csproj'
arguments: '-c release -r win-x64 --self-contained true'
Here is the YAML for the task that copies to build staging:
Your build pipeline references the ‘BuildConfiguration’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971
steps:
- task: CopyFiles@2
displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
inputs:
SourceFolder: '$(build.sourcesdirectory)'
Contents: '**\bin\$(BuildConfiguration)\**'
TargetFolder: '$(build.artifactstagingdirectory)'
Here is the YAML for publish:
steps:
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)\src\TelemetryReceiver\bin\Release\netcoreapp2.2\win-x64'
And here is the YAML for the NuGet pack:
steps:
- task: NuGetCommand@2
displayName: 'NuGet pack'
inputs:
command: pack
packagesToPack: src/telemetryreceiver/telemetryreceiver.csproj
versioningScheme: byPrereleaseNumber
On the copy step, the logs indicate the full self-contained package is indeed being copied to "\src\TelemetryReceiver\bin\Release\netcoreapp2.2\win-x64". But one the final package is downloaded from the artifact server, it is only picking up the contents of the "netcoreapp2.2" directory.
I am confused, of course, about how the "dotnet publish" and "NuGet pack" tasks are supposed to relate. It seems as if both independently evaluate the .csproj
file and that is it.
dotnet
commands: First use dotnet pack to create the .nupkg file, then use dotnet push command to push the nupkg to the nuget feed. – Rob Bos