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

NU1100: Unable to resolve 'XXX' for '.NETFramework,Version=v4.6.2'. #2838

Closed
jamescrowley opened this issue Oct 11, 2017 · 23 comments
Closed

Comments

@jamescrowley
Copy link

jamescrowley commented Oct 11, 2017

Description

We are getting

NU1100: Unable to resolve 'XXX' for '.NETFramework,Version=v4.6.2'.
followed by "Restore failed".

I am not yet sure if this is a NuGet/Build tools issue or a Paket issue. Doesn't happen if you have VS 2017 installed. Only appears to happen when you have "Build Tools for Visual Studio 2017" plus .NET Core 2.0 SDK installed (ie on our build server). We are running v15.4 of the build tools.

If anyone has any suggestions on how to diagnose further, it would be much appreciated.

Repro steps

Please provide the steps required to reproduce the problem

  1. We are running paket v5.114.0 via magic paket.exe (ie bootstrapper)

  2. We have CS project files in the new project format, targeting .NET 4.6.2

  3. We are running

    paket restore --group build

to pull down FAKE and a few others and then

 msbuild Project.sln /t:Restore;Build

Expected behavior

The project builds successfully, as it does on a machine with VS 2017 installed.

Actual behavior

As a result of paket restore --group build, paket does this:

Paket version 5.114.0
- C:\BuildAgent\work\9703509c24d73488\src\XX\obj\XX.csproj.net462.paket.resolved created
- C:\BuildAgent\work\9703509c24d73488\src\XX\obj\XX.csproj.paket.props created
<snip>
Performance:
- Disk IO: 11 seconds
- Runtime: 7 seconds
Paket version 5.114.0
Skipping resolver for group build since it is already up-to-date
Skipping resolver for group Main since it is already up-to-date
C:\BuildAgent\work\9703509c24d73488\paket.lock is already up-to-date
Installing into projects:
- Creating model and downloading packages.
- src/XX/paket.references -> src/XX/FundApps.XX.csproj
- src/YY/paket.references -> src/YY/FundApps.YY.csproj
<snip>
Performance:
- Disk IO: 29 seconds
- Average Download Time: 11 seconds
- Number of downloads: 2
- Runtime: 38 seconds

As a result of MSBuild:

Building project: ./src/XX.sln
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe ./src/XX.sln /t:Restore;Build /m /nodeReuse:False /tv:15.0 /v:m /p:RestorePackages="False" /p:Optimize="True" /p:DebugSymbols="True" /p:TreatWarningsAsErrors="True" /p:Configuration="Release" /logger:Fake.MsBuildLogger TeamCityLogger,"C:\BuildAgent\work\9703509c24d73488\packages\build\FAKE.x64\tools\FakeLib.dll" /logger:Fake.MsBuildLogger ErrorLogger,"C:\BuildAgent\work\9703509c24d73488\packages\build\FAKE.x64\tools\FakeLib.dll"
Microsoft (R) Build Engine version 15.4.8.50001 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Paket version 5.114.0
- C:\BuildAgent\work\9703509c24d73488\src\XX\obj\XX.csproj.net462.paket.resolved created
- C:\BuildAgent\work\9703509c24d73488\src\YY\obj\YY.csproj.net462.paket.resolved create
<snip>
C:\BuildAgent\work\9703509c24d73488\src\ZZ\ZZ.csproj : error NU1100: Unable to resolve 'NodaTime (>= 1.3.1)' for '.NETFramework,Version=v4.6.2'. [C:\BuildAgent\work\9703509c24d73488\src\XX.sln]

Generating MSBuild file C:\BuildAgent\work\9703509c24d73488\src\ZZ\obj\ZZ.csproj.nuget.g.props.
Generating MSBuild file C:\BuildAgent\work\9703509c24d73488\src\ZZ\obj\ZZ.csproj.nuget.g.targets.
Restore failed in 314.56 ms for C:\BuildAgent\work\9703509c24d73488\src\ZZ.csproj.

Known workarounds

None

@forki
Copy link
Member

forki commented Oct 12, 2017

do you have a zip for me to repro?

@jamescrowley
Copy link
Author

@forki working on it :)

@jamescrowley
Copy link
Author

jamescrowley commented Oct 13, 2017

@forki I have tried replacing with PackageReferences direct in the project files whilst removing the Paket target, and these work fine, so pretty confident this is a Paket issue.

PaketReproFromJC.zip

Attached is a sample. Locally, running VS 2017 15.4. Any time after running 'git clean -fdx', and 'build' the solution builds successfully. Run build a second time, and it fails as if it's not restoring the packages.

CS0246: NLogPropertyTarget.cs(3,11): The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)

Run on the build server (running .NET Core 2.0.0 SDK, .NET 4.6.2 SDK and VS Build Tools for 15.4 only), I get

NU1100: C:\BuildAgent\work\9703509c24d73488\src\FundApps.Common.Logging\FundApps.Common.Logging.csproj(0,0): Unable to resolve 'Newtonsoft.Json (>= 10.0.3)' for '.NETFramework,Version=v4.6.2'.
NU1100: C:\BuildAgent\work\9703509c24d73488\src\FundApps.Common.Logging\FundApps.Common.Logging.csproj(0,0): Unable to resolve 'NLog (>= 4.1.2)' for '.NETFramework,Version=v4.6.2'.

every time.

@forki
Copy link
Member

forki commented Oct 13, 2017

ok how to reproduce?

I'm using 15.5 but that should matter that much. I open solution. build, clean, build again and everything still works!?

@jamescrowley
Copy link
Author

jamescrowley commented Oct 13, 2017

@forki even when running from build.cmd rather than within VS?

My steps to repro the local issue just now were:

  • Extract ZIP to fresh dir
  • Run build.cmd (pass)
  • Run build.cmd (fail)

With regards the build server issue, the build server has a consistent environment as it's scripted. Can give you the powershell to run to install the dependencies (ie .net core sdk etc) if that's helpful.

@forki
Copy link
Member

forki commented Oct 13, 2017 via email

@jamescrowley
Copy link
Author

@forki with the same error I'm reporting, or something else?

@forki
Copy link
Member

forki commented Oct 13, 2017

I can now repro from developer command promt. Any reason why you don't use "dotnet build"?

@forki
Copy link
Member

forki commented Oct 13, 2017

ok I found something: your MSBuild command doesn't call paket at all.
The very first success is because of paket.cmd restore --group build call. That one restored sdk projects. But that's actually a bug that I just fixed. So right now even the first call crashes. :P
Which is expected sind MSBuild is not calling paket at all.

Trying to find out why..

@jamescrowley
Copy link
Author

jamescrowley commented Oct 13, 2017

@forki MsBuild - just a bit of a learning process here to figure out the least painful way to slowly migrate a .NET 4.6.2 150 project solution, running MVC 5 over time without breaking the rest of the engineering team's workflow 😁

I can confirm that I don't get either issue locally or on the build server switching to using 'dotnet build' instead.

Was gonna ask about that weird behaviour for the build group restore, so thanks for fixing it 😁

@forki
Copy link
Member

forki commented Oct 13, 2017

lol. now everything works as expected.

@forki forki closed this as completed Oct 13, 2017
@forki
Copy link
Member

forki commented Oct 13, 2017

just upgrade to 5.114.4

@forki
Copy link
Member

forki commented Oct 13, 2017

no need to use dotnet build

@jamescrowley
Copy link
Author

thanks @forki appreciate it :)

@forki
Copy link
Member

forki commented Oct 13, 2017

crazy bug....

@jamescrowley
Copy link
Author

@forki there's still a bug lurking here. I still get the build server issue ("NU1100: Unable to resolve 'XXX' for '.NETFramework,Version=v4.6.2'.") when running msbuild (but not dotnet build).

@forki
Copy link
Member

forki commented Oct 13, 2017

but that doesn't repro locally?

@forki
Copy link
Member

forki commented Oct 13, 2017

so what's the difference on the CI? different msbuild or dotnet version?

@jamescrowley
Copy link
Author

Yeah, can't repro locally.

On the CI we only have the VS 2017 Build tools as opposed to the full VS installation.

There was previously (unrelated?) NuGet weirdness-es with VS 2017 compared to just having the build tools which I experienced and were fixed in 15.4 (NuGet/Home#4821).

Since then I've been able to build successfully using msbuild on the build server, but only if I switch to using PackageReference instead of paket.

@forki
Copy link
Member

forki commented Oct 13, 2017

On the CI we only have the VS 2017 Build tools as opposed to the full VS installation.

What I think you should do is to move over to dotnet build. I mean you probably need to have dotnet sdk 2.0.0 installed anyway

@jamescrowley
Copy link
Author

Yeah, we have the dotnet SDK installed too, so I am switching to dotnet build 👍

@forki
Copy link
Member

forki commented Oct 13, 2017

nice side effect " VS 2017 Build tools" no longer needed

@tarekahf
Copy link

I am using VSCode to build a C# Project with Selenium. I following the steps here however when I reach the step to add the Selenium package, I get this error:

C:\Projects\Selenium\demoProject\FirstTest\FirstTest.csproj : error NU1100: Unable to resolve 'Selenium.WebDriver (>= 4.1.0)' for 'net6.0

which is pretty close to the error reported in this issue. I also posted a question for this issue here.

I appreciate your help.
Tarek

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants