DevOps issue when building NUGET package with .NET application

When working with .NET and Azure DevOps, we encountered an interesting issue. The pipeline failed, and the log does not show any meaningful information. The only issue in the log was this one:

"D:\a\1\s\src\YOURPROJECT.Api.csproj" (pack target) (1:7) ->
       (GenerateNuspec target) -> 
         C:\hostedtoolcache\windows\dotnet\sdk\8.0.300\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(221,5): error NU5026: The file 'D:\a\1\s\src\YOURPROJECT\bin\release\net8.0\YOURPROJECT.dll' to be packed was not found on disk. 

The reson is that we activated inside the .csproj file autogeneration of the package:

<GeneratePackageOnBuild>True</GeneratePackageOnBuild>

This is not supported within the Azure DevOps pipeline. When discussing unsupported features, you should also be aware of the following. If your project file performs any file copy operation, that might be an issue for the pipeline.

<Target Name="CopyPackage" AfterTargets="Pack">
	<Copy SourceFiles="$(OutputPath)..\$(PackageId).$(PackageVersion).nupkg" DestinationFolder="$(SolutionDir)..\nuget" />
</Target>

Hope this helps.


comments powered by Disqus