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 restore -- ignores packages.config projects silently #4401

Closed
jainaashish opened this issue Jan 25, 2017 · 10 comments
Closed

dotnet restore -- ignores packages.config projects silently #4401

jainaashish opened this issue Jan 25, 2017 · 10 comments

Comments

@jainaashish
Copy link

NuGet generates different assets file when running restore through dotnet and visual studio. With dotnet restore, it's missing runtimes section in the assets file.

Repro:

  1. create asp.net core (.net framework) web application
  2. create .net framework class library
  3. add project reference from web app to class library
  4. install a package as Package Reference in class library
  5. run dotnet restore on this solution through developer command prompt
  6. build solution in vs. it will show below error/ warning

Error encountered while loading the project. Some project features, such as full solution analysis for the failed project and projects that depend on it, have been disabled.

Generated assets files are shared at \\scratch2\scratch\asja\restore issue

@jainaashish jainaashish added this to the 4.0 RTM milestone Jan 25, 2017
@rrelyea rrelyea modified the milestones: Future-1, 4.0 RTM Jan 27, 2017
@rrelyea rrelyea changed the title Missing runtimes section error through dotnet restore on PackageReferences based project dotnet restore -- ignores packages.config projects and packagereferences (legacy csproj) projects silently Jan 27, 2017
@rrelyea
Copy link
Contributor

rrelyea commented Jan 27, 2017

consider warning?

@joechiu-msft
Copy link

joechiu-msft commented Feb 6, 2017

I am in similar situation - a solution mix with asp.net core and "legacy" non-.net core msbuild projects, both use nuget packages:

  1. an asp.net core project targeting full 4.6 fx - this one uses package ref inside csproj
  2. a sfproj (service fabric project) that creates deployment package around bits from UI: Action changes to updating previous version after installing #1 - this one uses packages.config.

Is there ways that I can restore nuget packages for both with a single command line?
When I tried using dotnet restore (1.0.0-rc3-004530), it appears to restore asp.net core project, but prints error about sfproj's target framework is unsupported.

When I tried using nuget.exe restore (3.3.0.212), it works for the sfproj, but did not restore package for asp.net core project, there is no error message (which I think is what this issue is about).

I assume OP (and myself) expects a single command to take care of both projects restore need. Is that possible or realistic? @rrelyea 's command about adding a warning seems to imply that it's not supposed to work?

@rrelyea
Copy link
Contributor

rrelyea commented Feb 6, 2017

NuGet.exe 4.0rc4 will be posted up to nuget.org/downloads very soon.

@joechiu-msft
Copy link

Looking at this: https://blogs.msdn.microsoft.com/dotnet/2017/01/30/announcing-net-core-net-native-and-nuget-updates-in-vs-2017-rc/

It says "NuGet – .NET Framework, UWP, .NET Core and other .NET projects can now use PackageReference instead of packages.config for NuGet dependencies." I am now confused on whether the scenario is supported or not.

So - is this true that this (PackageReference in legacy MSBuild projects) should work, but mixing RC3 .net core and non-.net core projects seem to have broken it?

@JuergenGutsch
Copy link

Currently it works using VS2017 13.3 preview, but not using dotnet restore. It seems VS handles packages.config separately.

I have a mixed solution where I need to build on a build server without VS installed.
dotnet restore runs without an error ('silently') but doesn't restore on packages.config based projects. If I use the an old msbuild based restore, it fails on the .NET Core projects.

So from my perspective it is basically an dotnet restore issue.
(BTW: dotnet build is working on mixed solutions)

@rrelyea
Copy link
Contributor

rrelyea commented Aug 7, 2017

dotnet restore should work fine with any non-packages.config NuGet mechanism: package reference (for both netcore sdk based projects and old style csproj) or project.json (uwp-style).

I don't recall why I retitled this bug to say it doesn't work packagereference (for old style csprojs).

Today, if you'd like to use a command line restore for a solution that includes packages.config based projects, here are your options:

  • run NuGet.exe (4.1 or later -- ideally the latest suggested version as of the moment you read this)
  • migrate from packages.config to projectreference (either style, depending on what will work well with that project type) -- and then use "msbuild /t:restore" or "dotnet restore" with VS 2017 or later.

@rrelyea rrelyea changed the title dotnet restore -- ignores packages.config projects and packagereferences (legacy csproj) projects silently dotnet restore -- ignores packages.config projects silently Aug 7, 2017
@rrelyea
Copy link
Contributor

rrelyea commented Aug 7, 2017

We'd love to hear more comments/feedback on this. However, right now we don't plan to change this behavior, so closing the issue.

@rrelyea rrelyea closed this as completed Aug 7, 2017
@mungojam
Copy link

@rrelyea Yeah, it's unfortunate for us this. Even once we have moved all our projects to PackageReference, we will still want our build script to be able to build older changesets so we will have to leave the nuget.exe restore step in rather than being able to switch to the nice msbuild /restore for everything.

@cliffAtOsaic
Copy link

How do you fix this? dotnet restore says there is nothing to download and dotnet build fails because the missing NuGet pacakges were not downloaded.

>dotnet build
  Determining projects to restore...
  Nothing to do. None of the projects specified contain packages to restore.
  SAI.EAL.Core -> C:\Users\cschomburg\git\SAI.API.EnterpriseApplicationLogging\SAI.EAL.Core\bin\Debug\SAI.EAL.Core.dll
C:\Program Files\dotnet\sdk\8.0.403\Microsoft.Common.CurrentVersion.targets(2412,5): warning MSB3245: Could not resolve
 this reference. Could not locate the assembly "NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c
, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your co
de, you may get compilation errors. [C:\Users\cschomburg\git\SAI.API.EnterpriseApplicationLogging\SAI.EAL\SAI.EAL.Busin
ess.csproj]
C:\Users\cschomburg\git\SAI.API.EnterpriseApplicationLogging\SAI.EAL\LogBusiness.cs(6,7): error CS0246: The type or nam
espace name 'NLog' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\cschombur
g\git\SAI.API.EnterpriseApplicationLogging\SAI.EAL\SAI.EAL.Business.csproj]
C:\Users\cschomburg\git\SAI.API.EnterpriseApplicationLogging\SAI.EAL\LogBusiness.cs(13,24): error CS0246: The type or n
amespace name 'Logger' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\cscho
mburg\git\SAI.API.EnterpriseApplicationLogging\SAI.EAL\SAI.EAL.Business.csproj]

Build FAILED.

@cliffAtOsaic
Copy link

Note that nuget restore restores the packages but dotnet restore says there are no packages to be restored... ??

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

No branches or pull requests

7 participants