I'm trying to build and pack a class library into a NuGet using .NET Core 3.1. It all build fine on my dev machine, but the Azure pipeline build fails during the DotNetCoreCLI pack command. I was able to get the build working on after installing .NET Core 3.1 on the build machine using the UseDotNet. Build and tests run fine, so I believe the 3.1 version is installed correctly.
When I add the pack command, the step always fails. Here is the command I'm using:
- task: DotNetCoreCLI@2
displayName: Package NuGet
inputs:
command: 'pack'
projects: '**/*.csproj'
arguments: '--configuration $(BuildConfiguration)'
outputDir: '$(Build.ArtifactStagingDirectory)/packages'
I get the following error during this step:
/opt/hostedtoolcache/dotnet/sdk/3.1.101/Sdks/NuGet.Build.Tasks.Pack/build/NuGet.Build.Tasks.Pack.targets(198,5): error NU5026: The file '/home/vsts/work/1/s/ClassLib31/bin/Debug/netcoreapp3.1/ClassLib31.dll' to be packed was not found on disk. [/home/vsts/work/1/s/ClassLib31/ClassLib31.csproj]
Notice the path above is looking bin Debug folder, but this is a Release build. All of the tasks are using the same BuildConfiguration variable, but in this task it appears to be looking for the dll in the Debug folder. Any ideas why?
Additional notes: - This build script works fine for .NET Core 3.0 projects. I tried switching the library to target 3.0 and removed the 3.1 installation step. Pack works as expected. - This build script works when I build the Debug version of the library (as you'd expect, since the task is looking in that bin folder).
.net core3.1
, but I test it with.net core 3.1
on the hosted agentubuntu-16.04
andubuntu-18.04
, it works fine. Not sure where the argumentdebug
comes from, how about specify the directly argument like: arguments:--configuration Release
? – Leo Liu-MSFT