I'm trying to produce a NuGet package from a C# project on Azure DevOps. I've set up a 'dotnet pack' task in a build pipeline for generating the package. The project is targeting netstandard20. The projectstyle is PackageReference. It has some dependencies, but only ones available on nuget.org.
The build task fails with error NU5019: File not found
Here's the output from the build task:
NU5019 means that the nuspec file "...contained files that do not exist": https://docs.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu5019
The extracted .nuspec file which is generated by the build task contains this <files> section:
<files>
<file src="C:\agent\_work\23\s\GenericDataAccess\bin\Production\netstandard2.0\Sparinvest.GenericDataAccess.dll" target="lib\netstandard2.0\Sparinvest.GenericDataAccess.dll" />
</files>
It seems to me, the build step builds the .dll and then immediately is unable to find it for packing. However, the .dll is produced.
When I execute the same commandline (seen in the build log) locally on my machine, there's no problem.
I notice, however, that .Net versions are not the same on my machine vs. the build server (see build log): My machine
Can anyone help me to figure out what the problem is with the build step and how I can make it work?
NOTE: I would prefer to use 'dotnet pack' rather than NuGet.exe, because dotnet is able to include dependencies in the pack (NuGet doesn't support PackageReference style).