I wanted to establish a link between two projects via my local file system by using packages instead of a direct reference. I added an item to my project like so (which is where my .nupkg files are output to):
And this works when building from VS but not from the command line. The reason appears to be because the $(SolutionDir) default at the top of the default NuGet.targets page gives a relative address and if you have a @(PackageSource) which isn't a web url but
is relative to the solution you get a relative path. This causes an error in nuget.exe.
The easiest solution I could come up with was to change the flattening of @(PackageSource) to $(PackageSources) from this:
<PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>
<PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource->'%(FullPath)')</PackageSources>
For uri's the FullPath metadata returns the same result, for local files the paths are resolved to fullpaths, which nuget.exe can work with. This works.