Home: dotnet add local package -> error: Value cannot be null. error: Parameter name: path1

Created on 3 Sep 2019  Â·  17Comments  Â·  Source: NuGet/Home

_From @gdillen on Tuesday, January 29, 2019 3:56:08 PM_

Steps to reproduce

I'm on macOS 10.14.2
dotnet version 2.2.103

  1. Create a C# class library project
  2. Add package metadata to the project file
  3. inside the existing tag,
    <PackageId>mylib</PackageId> <Version>1.0.0</Version> <Authors>MyName</Authors> <Company>MyCompany</Company>

  4. Run the pack command
    $ dotnet pack
    4 $ nuget add mylib.nupkg -source /Users/myname/nuget_repo
    5 $ dotnet nuget push mylib.1.0.0.nupkg -s my-nuget
    In my ConsoleApp project try to add my nuget package:
    6 $ dotnet add package mylib -s /Users/myname/nuget-repo

Expected behavior

Successfully adding my Nuget package.

Actual behavior

myname:MyConsoleApp myname$ dotnet add package mylib
Writing /var/folders/cr/4pk4646d1_x5tl_tbbbbvqkw0000gn/T/tmpyagAXi.tmp
info : Adding PackageReference for package 'mylib' into project '/Users/myname/Projects/MyConsoleApp/MyConsoleApp.csproj'.
log : Restoring packages for /Users/myname/Projects/MyConsoleApp/MyConsoleApp.csproj...
info : Package 'mylib' is compatible with all the specified frameworks in project '/Users/myname/Projects/MyConsoleApp/MyConsoleApp.csproj'.
error: Value cannot be null.
error: Parameter name: path1

_Copied from original issue: dotnet/cli#10668_

ErrorHandling Quality Week Backlog Xplat 2 Bug

Most helpful comment

I'm getting the same issue on a new console app trying to add MediatR package...

➜  mediatr dotnet add package MediatR --version 7.0.0
  Writing /var/folders/gy/qfwtdmyx1135_x_vrnw8xcz40000gn/T/tmpi2UHSn.tmp
info : Adding PackageReference for package 'MediatR' into project '/Users/mmihajlovic/Documents/git/dotnet.core3/mediatr/mediatr.csproj'.
info : Restoring packages for /Users/mmihajlovic/Documents/git/dotnet.core3/mediatr/mediatr.csproj...
error: Cycle detected. 
error:   mediatr -> MediatR (>= 7.0.0).
info : Package 'MediatR' is compatible with all the specified frameworks in project '/Users/mmihajlovic/Documents/git/dotnet.core3/mediatr/mediatr.csproj'.
error: Value cannot be null. (Parameter 'path1')

Could it be because my folder is called mediatr as well? (cycle detected?)

EDIT: I think I answered my own question from here: https://github.com/NuGet/Home/issues/6754 - can't use same folder name or project name as package name

All 17 comments

_From @livarcocc on Tuesday, January 29, 2019 5:41:28 PM_

@wli3 can you take a look?

_From @guydillen on Monday, February 11, 2019 9:03:11 AM_

Any progress?

Thanks.

_From @wli3 on Monday, February 11, 2019 7:23:43 PM_

sorry I don't have any update

_From @Rakiah on Thursday, March 21, 2019 11:40:24 AM_

I have the same problem but using a remote private NuGet server, any updates please ??

_From @wli3 on Thursday, March 21, 2019 3:26:26 PM_

@nkolev92 anything on the top of your head

_From @nkolev92 on Thursday, March 21, 2019 5:55:27 PM_

Where are you trying to install the package?

How did you generate the console app?

I've seen this goo get spewed when it detects a cycle.

Basically you are trying to install the package in the project that generated it.

_From @ransagy on Monday, September 2, 2019 8:52:59 AM_

I've come across this myself. Is there any way for us to nail it down further? some diagnostic/verbose output to understand which path is it tripping on?

I tried adding the --verbosity diag and --diagnostics flags, but the cli doesn't accept those in any way i could add them coupled with the add package command.

I would like to have a verbosity or diagnostics option as reported earlier in this thread. I cannot see the reason for this error message while adding a package:

dotnet add package MyClient -s https://myproget.info/nuget/NuGet-DEV

info : Adding PackageReference for package 'MyClient' into project 'c:\api\src\IntegrationTests\IntegrationTests.csproj'.
info : Restoring packages for c:\api\src\IntegrationTests\IntegrationTests.csproj...
info :   GET https://api.nuget.org/v3-flatcontainer/my.authorization.api.core/index.json
info :   CACHE https://myproget.info/nuget/NuGet-DEV/FindPackagesById()?id='MyPackage.Core'&semVerLevel=2.0.0
info :   CACHE https://myproget.info/nuget/NuGet-LIVE/FindPackagesById()?id='MyPackage.Core'&semVerLevel=2.0.0
info :   NotFound https://api.nuget.org/v3-flatcontainer/my.authorization.api.core/index.json 930ms
error: Value cannot be null. (Parameter 'path1')

I would like to have a verbosity or diagnostics option as reported earlier in this thread.

There's a tracking issue for that already, that maybe needs reprioritized, /cc @rrelyea
https://github.com/NuGet/Home/issues/6374

I'm getting the same issue on a new console app trying to add MediatR package...

➜  mediatr dotnet add package MediatR --version 7.0.0
  Writing /var/folders/gy/qfwtdmyx1135_x_vrnw8xcz40000gn/T/tmpi2UHSn.tmp
info : Adding PackageReference for package 'MediatR' into project '/Users/mmihajlovic/Documents/git/dotnet.core3/mediatr/mediatr.csproj'.
info : Restoring packages for /Users/mmihajlovic/Documents/git/dotnet.core3/mediatr/mediatr.csproj...
error: Cycle detected. 
error:   mediatr -> MediatR (>= 7.0.0).
info : Package 'MediatR' is compatible with all the specified frameworks in project '/Users/mmihajlovic/Documents/git/dotnet.core3/mediatr/mediatr.csproj'.
error: Value cannot be null. (Parameter 'path1')

Could it be because my folder is called mediatr as well? (cycle detected?)

EDIT: I think I answered my own question from here: https://github.com/NuGet/Home/issues/6754 - can't use same folder name or project name as package name

@ransagy - i'm not able to repro the main issue...

the following steps work fine with dotnet core sdk: 3.0.100:

dotnet new classlib -o classlib1
cd classlib1
dotnet pack
nuget add bin\debug\classlib1.1.0.0.nupkg -s c:\localfeed
cd ..
dotnet new console -o console1
cd console1
dotnet add package classlib1 -s c:\localfeed

so I think we should close this issue. Please confirm.

As i haven't come across this again, no problem by me. I'll comment again if and when it happens.

I was converting a project that I had as a project reference into a nuget package. When I ran the dotnet add package command, I got the message referenced above. Once I removed the project reference, the add package command worked as expected.

I'm having the Value cannot be null issue as well. I am using BOTH package and project references, which works in Visual Studio. That way when project references are not available (e.g. building single project in a container), the nuget reference is pulled. The Visual Studio 2019 Manage NuGet packages allows updating, but the command line does not work - failing with the aforementioned error.

My use case is this: Build dependent libraries of a project, push the package to the nuget server, and then update the references, all via the command line.

So it would be nice if there were a fix some time in the future -- the workaround is using Visual Studio.

Hey all,

I'm having a similar issue, but with dotnet nuget push, it prints the following error.

error: Value cannot be null. (Parameter 'path2')
Fatal error error="exit status 1"

It's happening with the mcr.microsoft.com/dotnet/core/sdk:3.1 image, but so far couldn't reproduce it locally on my Windows machine, not even in the same repo. Has there been anything discovered about what this can caused by?

What seems to go wring is if you specify the path to the nupkg file after flags like --source and --api-key, like dotnet nuget push --source <private repo url> --api-key <private repo api key> /path/to/file.nupkg. Switching to dotnet nuget push /path/to/file.nupkg --source <private repo url> --api-key <private repo api key> fixes the issue.

It would be nice if the nuget client either accept both orders or returns a useful message indicating the order has to be reversed.

Jorrit - thanks for answering -- your solution worked great. Who would have thought. Did you look at the source to find out? The alternative to dotnet nuget is using nuget, and that is quite unpleasant on Linux, because you first have to install mono, then nuget, then download a newer nuget and manually install it. Yes, let the issue be fixed, either by error message, or better, by accepting any parameter order.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

msaraf1 picture msaraf1  Â·  3Comments

rrelyea picture rrelyea  Â·  3Comments

dotMorten picture dotMorten  Â·  3Comments

infin8x picture infin8x  Â·  3Comments

LordMike picture LordMike  Â·  3Comments