I have ran into a strange problem and have been trying to fix for a couple of days. Locally, I can build my project just fine with the following nuspec file. The nuspec file is saved in the repo and copied local when built from the c# project and it is under a sub folder called "nugetcreation". Locally, I can run the nuspec file as is and it generates the nuget package.
Folder setup: project -project files -nugetcreation -readme and nuspec files
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>my.Utility.TraceWriter</id>
<version>1.0.0-beta</version>
<title>my.Utility.TraceWriter</title>
<authors>justme</authors>
<owners>justme</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>custom trace items</description>
<releaseNotes>initial release</releaseNotes>
</metadata>
<files>
<file src="Content\MyReadMes\My.Utility.TraceWriter.md" target="content\net461\MyReadMes\My.Utility.TraceWriter.md" />
<file src="..\My.Utility.TraceWriter.dll" target="lib\net461\My.Utility.TraceWriter.dll" />
<file src="..\My.Utility.TraceWriter.pdb" target="lib\net461\My.Utility.TraceWriter.pdb" />
</files>
</package>
The problem: When I am building an Azure Pipeline, I tell it to run the nuspec file and I am getting an error
##[error]The nuget command failed with exit code(1) and error(Error NU5019: File not found: '..\My.Utility.TraceWriter.dll'.
But it is absolutely being generated correctly from the vsbuild process
CopyFilesToOutputDirectory:
Copying file from "d:\a\1\s\My.Utility.TraceWriter\My.Utility.MethodTracer\obj\Release\My.Utility.TraceWriter.dll" to "d:\a\1\s\My.Utility.TraceWriter\My.Utility.MethodTracer\bin\Release\My.Utility.TraceWriter.dll"
The nuget creation step in the azure pipeline is pretty basic, nothing fancy. All of the fancy stuff I am keeping in the nuspec file. I am trying to get this to work on a basic project with the nuspec file because I have much more complicated nuget packaging coming later so this is my test version.
- task: NuGetCommand@2
displayName: 'Creating nuget package'
inputs:
command: 'pack'
packagesToPack: '**/*.nuspec'
versioningScheme: 'off'
arguments: '--configuration $(buildConfiguration)'
So far I have tried using:
- **\My.Utility.TraceWriter.dll (no error, but no dlls are in the lib folder. acts as if that line is just skipped)
- bin**\My.Utility.TraceWriter.dll
- .\My.Utility.TraceWriter.dll
- $configuration$\My.Utility.TraceWriter.dll
- **\$configuration$\My.Utility.TraceWriter.dll
...nothing works. Does anyone have any ideas about why the azure pipeline doesn't accept the correct (..\My.Utility.TraceWriter.dll) relative path entry on the nuspec file and how to fix it?
My forehead hurts from banging my keyboard against it...
--EDIT--
A little more info. It appears that 2 things are happening when the nuget pack command is ran. The entire output is below but it looks like after the nuget successfully builds it is trying to pack it again and this time can't find the files??
Added file '_rels/.rels'.
Added file 'My.Utility.TraceWriter.nuspec'.
Added file 'content/net461/MyReadMes/My.Utility.TraceWriter.md'.
Added file 'lib/net461/My.Utility.TraceWriter.dll'.
Added file 'lib/net461/My.Utility.TraceWriter.pdb'.
Added file 'package/services/metadata/core-properties/f2a4d059fea6458dac5889de57641f5b.psmdcp'.
Successfully created package 'D:\a\1\a\My.Utility.TraceWriter.1.0.0-beta.nupkg'.
WARNING: NU5128: Some target frameworks declared in the dependencies group of the nuspec and the lib/ref folder do not have exact matches in the other location. Consult the list of actions below:
- Add a dependency group for .NETFramework4.6.1 to the nuspec
Attempting to pack file: D:\a\1\s\My.Utility.TraceWriter\My.Utility.MethodTracer\nuget information\My.Utility.TraceWriter.nuspec
C:\hostedtoolcache\windows\NuGet\5.4.0\x64\nuget.exe pack "D:\a\1\s\My.Utility.TraceWriter\My.Utility.MethodTracer\nuget information\My.Utility.TraceWriter.nuspec" -NonInteractive -OutputDirectory D:\a\1\a -Properties Configuration=Release -Verbosity Detailed
Error NU5019: File not found: '..\My.Utility.TraceWriter.dll'.
NuGet Version: 5.4.0.6315
NuGet.Packaging.Core.PackagingException: File not found: '..\My.Utility.TraceWriter.dll'.