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

nuget.exe fails to restore packages for .build.csproj #7

Closed
abhinav2004 opened this issue Oct 3, 2017 · 14 comments
Closed

nuget.exe fails to restore packages for .build.csproj #7

abhinav2004 opened this issue Oct 3, 2017 · 14 comments

Comments

@abhinav2004
Copy link

After running the powershell script nuget fails restore the packages for .build.csproj. I have setup nuke for .Net FW and legacy project structure.

Checking for updates from https://www.nuget.org/api/v2/.
Currently running NuGet.exe 4.3.0.
NuGet.exe is up to date.
MSBuild auto-detection: using msbuild version '15.3.409.57025' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\bin'.
Cannot determine the packages folder to restore NuGet packages. Please specify either -PackagesDirectory or -SolutionDirectory.
The following call failed with exit code 1. ' & $NuGetFile restore $BuildProjectFile '
At <redacted>\build.ps1:31 char:32
+ ... de -ne 0) { throw "The following call failed with exit code $LastExit ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (The following c...ldProjectFile ':String) [], RuntimeException
    + FullyQualifiedErrorId : The following call failed with exit code 1. ' & $NuGetFile restore $BuildProjectFile '

Am I missing something?

@matkoch
Copy link
Member

matkoch commented Oct 3, 2017

@abhinav2004 I assume you have your solution file (sln) and the build.ps1 in different locations? That would be indeed a situation I didn't think of, when I recently cleaned up some parts of the bootstrapping.

What you're probably missing is the -SolutionDirectory flag for nuget.exe:

7001502#diff-17bf411711a25aa07727e1ee506981afL16
7001502#diff-17bf411711a25aa07727e1ee506981afL40

I can revert this change, but could you first check if this fixes the situation for you?

@abhinav2004
Copy link
Author

@matkoch actually they are at the same location:

<redacted>@<redacted> MINGW64 ~/Workspace/<redacted> (<redacted>)
$ ls -al *.sln *.ps1
-rw-r--r-- 1 <redacted> 197121 7703 Oct  3 17:04 <redacted>.sln
-rw-r--r-- 1 <redacted> 197121 1922 Oct  3 17:04 build.ps1

I'll check if the fix given by you works and get back to you.

@matkoch
Copy link
Member

matkoch commented Oct 3, 2017

Are you executing from a different working directory? As far as I know nuget.exe tries to find the solution file by walking up the current directory.

@abhinav2004
Copy link
Author

I am executing it from where both the sln and ps1 files are.

@matkoch
Copy link
Member

matkoch commented Oct 3, 2017

Maybe it finds more than one solution file? Anyway, I'm sure specifying that parameter will fix it.

@abhinav2004
Copy link
Author

abhinav2004 commented Oct 3, 2017

Actually there are submodules in the project which have their own solution files but they are down in the sub paths. The immediate solution is just outside the build folder.

And yes the change did fix it somewhat but now I have dependency issues :(
I found out by manually restoring nuget packages.

Update-Package : Unable to resolve dependencies. 'Newtonsoft.Json 10.0.1' is not compatible with 'Nuke.Common 0.1.340 constraint: Newtonsoft.Json (>= 10.0.3)', 'Refit 4.0.1 constraint: 
Newtonsoft.Json (>= 10.0.3)'.

@matkoch
Copy link
Member

matkoch commented Oct 3, 2017

I really don't like supporting the legacy format. But I will still try :) It's much more fragile than using the sdk-based project files.

In that case you could simply replace the version 10.0.1 with 10.0.3 in both - project file and packages.config.

@abhinav2004
Copy link
Author

Yeah legacy can be a pain at times. I'll try that and see if it works.

@matkoch
Copy link
Member

matkoch commented Oct 3, 2017

No chance you can install msbuild 15 or use netcore ?

@abhinav2004
Copy link
Author

abhinav2004 commented Oct 3, 2017

I am on msbuild 15. But need to use old .Net FW

@matkoch
Copy link
Member

matkoch commented Oct 3, 2017

Then you should be able to use .NET Framework + SDK-based project file.

@abhinav2004
Copy link
Author

abhinav2004 commented Oct 3, 2017

Ok now I feel like an idiot. Thanks! The SDK based one worked without a hiccup.

@matkoch
Copy link
Member

matkoch commented Oct 3, 2017

That sounds great :D Everything alright, much appreciated that you actually found 2 bugs :)

@matkoch matkoch closed this as completed Oct 3, 2017
matkoch pushed a commit that referenced this issue Nov 9, 2019
@lock
Copy link

lock bot commented Nov 20, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Nov 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants