Restoring NuGet packages to the cache

t3chb0t

I have a .net-core application that works on my machine but when I deploy it on another one, it complains about missing packages and points me to the TheApp.deps.json.


My theory is that on my machine the app looks for packages in some NuGet cache where they were probably installed by the IDE during development because the app's output-dir contains only a couple of internal dlls so the other nuget.org dependecies are definitely missing.

I'm building the app with

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <RuntimeIdentifier>win10-x64</RuntimeIdentifier>
  </PropertyGroup>

and then xcopy it to the other machine.


Question

Is there a way to restore or install the missing packages to the cache on the target machine based on the *.deps.json file?

Jamie Taylor

dotnet build (and the F5/Build function in Visual Studio) simply build the code that you have provided via your source files (i.e cs, fs, vb, etc.).

Whereas dotnet publish (and the Build > Publish function in Visual Studio) does a full package restore, builds your source code, and resolves any external dependencies before moving the output to a specific directory ready for publishing to another machine.

The description on the dotnet publish command documentation states:

dotnet publish compiles the application, reads through its dependencies specified in the project file, and publishes the resulting set of files to a directory. The output includes the following assets:

  • Intermediate Language (IL) code in an assembly with a dll extension.
  • .deps.json file that includes all of the dependencies of the project.
  • .runtime.config.json file that specifies the shared runtime that the application expects, as well as other configuration options for the runtime (for example, garbage collection type).
  • The application's dependencies, which are copied from the NuGet cache into the output folder.

dotnet build is only really useful for building on your development machine, and when used in conjunction with dotnet run against a project file.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

NuGet error restoring packages

Restoring NuGet packages to the latest version

NuGet restoring packages but missing DLLs

How to remove the [warning]To connect to NuGet feeds when restoring NuGet packages

Visual Studio : Error occurred while restoring nuget packages : There are duplicate packages

Jenkins not restoring NuGet packages with new MSBuild restore target

TeamCity not restoring NuGet packages from particular package source

How do I disable restoring NuGet packages while starting the solution

Visual Studio 2019 for Mac: Error when restoring or adding Nuget packages

Problem with restoring nuget packages with asp.net core 2.2

Nuget cache vs global packages folder

Restoring nuget packages of project with the http version of nuget.org using the dotnet cli

Error occurred while restoring NuGet packages: "Invalid restore input. No target frameworks specified."

"Unable to find version" during TFS Build 2015 when restoring NuGet packages

TFS2012 build server not restoring NuGet packages from in-house repository

How to prevent UWP projects from restoring NuGet packages upon each Visual Studio session?

Restoring Nuget References?

Is it possible to create a cache of nuget packages for computers without internet?

Newer versions of NuGet.exe can't resolve framework match when restoring older packages (net40, netframework40)

Command to use restoring npm packages

Deleted all the Nuget packages in my local package cache, now I can't use VS at all

Restoring nuget packages of a solution in .net Rider IDE: Failed to download package `x` The HTTP request to GET `x` has timedout after 100000ms

Cannot modify NuGet packages

Testing nuget packages locally

Nuget Packages are there but missing References

Build Error with NuGet packages

NuGet Packages are missing

CPack NuGet Packages

nuget packages in local work