Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wli3 opened this issue Sep 3, 2019 · 18 comments
Labels
Area:ErrorHandling warnings and errors/log messages & related error codes. Category:Quality Week Issues that should be considered for quality week Platform:Xplat Priority:2 Issues for the current backlog. Type:Bug
Milestone

Comments

@wli3
Copy link

wli3 commented Sep 3, 2019

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
  • inside the existing tag,
    <PackageId>mylib</PackageId> <Version>1.0.0</Version> <Authors>MyName</Authors> <Company>MyCompany</Company>
  1. 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

@wli3
Copy link
Author

wli3 commented Sep 3, 2019

From @livarcocc on Tuesday, January 29, 2019 5:41:28 PM

@wli3 can you take a look?

@wli3
Copy link
Author

wli3 commented Sep 3, 2019

From @guydillen on Monday, February 11, 2019 9:03:11 AM

Any progress?

Thanks.

@wli3
Copy link
Author

wli3 commented Sep 3, 2019

From @wli3 on Monday, February 11, 2019 7:23:43 PM

sorry I don't have any update

@wli3
Copy link
Author

wli3 commented Sep 3, 2019

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 ??

@wli3
Copy link
Author

wli3 commented Sep 3, 2019

From @wli3 on Thursday, March 21, 2019 3:26:26 PM

@nkolev92 anything on the top of your head

@wli3
Copy link
Author

wli3 commented Sep 3, 2019

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.

@wli3
Copy link
Author

wli3 commented Sep 3, 2019

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.

@juniormayhe
Copy link

juniormayhe commented Sep 9, 2019

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')

@heng-liu heng-liu added Area:ErrorHandling warnings and errors/log messages & related error codes. Platform:Xplat Type:Bug labels Sep 9, 2019
@heng-liu heng-liu added this to the 5.4 milestone Sep 9, 2019
@nkolev92
Copy link
Member

nkolev92 commented Sep 9, 2019

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
#6374

@mika76
Copy link

mika76 commented Oct 2, 2019

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: #6754 - can't use same folder name or project name as package name

@rrelyea
Copy link
Contributor

rrelyea commented Oct 31, 2019

@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.

@rrelyea rrelyea modified the milestones: 5.4, Backlog Oct 31, 2019
@ransagy
Copy link

ransagy commented Oct 31, 2019

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

@CraigKennedy
Copy link

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.

@friedrich-brunzema
Copy link

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.

@markvincze
Copy link

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?

@JorritSalverda
Copy link

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.

@friedrich-brunzema
Copy link

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.

@ransagy
Copy link

ransagy commented Feb 24, 2022

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

And here we go, a few years later :]

I'm trying to convert a project reference to a nuget reference in a project. I first removed it with dotnet remove my.csproj reference nuget.csproj which went fine, then dotnet add my.csproj package my.PackageName which failed with the original message. I didn't see any other error in the log.

It was not stated anywhere in the thread, so i'll add in my case - its an older netframework 4.7.2 old-style csproj. Could be that its not explicitly supported though or even explicitly UNSUPPORTED, not sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:ErrorHandling warnings and errors/log messages & related error codes. Category:Quality Week Issues that should be considered for quality week Platform:Xplat Priority:2 Issues for the current backlog. Type:Bug
Projects
None yet
Development

No branches or pull requests