PORTABLE NUGET PACKAGE

MOON 40 Reputation points
2025-06-08T09:13:28.3633333+00:00

I download a Nuget package for a .NET Core project in Visual Studio, then the same package is needed by another project, so the same process is repeated. I do not want to connect remote computer every time. I want to download the package one time and install it into all dependent projects.

Developer technologies | Visual Studio | Extensions
0 comments No comments
{count} votes

Accepted answer
  1. Saideep Anchuri 9,425 Reputation points Microsoft External Staff Moderator
    2025-06-12T00:21:59.5266667+00:00

    Hi MOON

    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to accept the answer.

    Ask: PORTABLE NUGET PACKAGE

    Solution: The issue is resolved. Following instructions are the exact solution for this thread. Target operating system is Windows x64. None of the steps explicitly includes any CLI application; all of them is carried out via GUI applications.


    1. Go to the NuGet web site, download necessary packages and place them to a local empty folder. Pay attention to package dependencies and versions. API versions must support project SDK.
    2. Start Visual Studio and go to "Options/NuGet Package Manager/Package Sources". At this page, click plus button to create a new NuGet package source and refer it to the directory in which downloaded NUPKG files exist. Also uncheck box of the source named "Nuget.org" because Visual Studio`s default behavior tends to use this online service.
    3. Open any .NET project whose SDK version is supported by downloaded packages, then go to "Project/Manage NuGet Packages" menu section of Visual Studio. At this page, choose newly created NuGet source from dropdown list and find and install the target package into the project.
    4. At this point, Visual Studio makes packages ready to use. Their directory is "%userprofile%/.nuget\packages". This is not acceptable due to the fact that if current user is removed from operating system, the directory is erased, so copy the NuGet package folders.
    5. During Visual Studio installation, Visual Studio Installer installs default NuGet packages into the directory "%programfiles(x86)%\Microsoft SDKs\NuGetPackages". Visual Studio`s package manager has an entry named "Microsoft Visual Studio Offline Packages" for this directory as NuGet package source. That is why, copied files need to be pasted into the directory.
    6. Go to the page mentioned at step 2 and delete the entry created at step 2. At same page, make sure checkbox of "Microsoft Visual Studio Offline Packages" is signed. After now all projects and users could install the downloaded packages at that computer without network connection.
    7. The local folder mentioned in step 1 can be deleted since NUPKG files of that folder have already been distributed towards related locations, so they are no needed any more.

    If I missed anything please let me know and I'd be happy to add it to my answer, or feel free to comment below with any additional information.

    If you have any other questions, please let me know. Thank you again for your time and patience throughout this issue.

     

    Please don’t forget to Accept Answer and Yes for "was this answer helpful" wherever the information provided helps you, this can be beneficial to other community members.

     Thank You.

    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Marcin Policht 49,640 Reputation points MVP Volunteer Moderator
    2025-06-08T11:54:16.0833333+00:00

    Follow https://stackoverflow.com/questions/8120289/is-there-a-way-to-download-packages-from-nuget-org-then-do-an-offline-installati

    1. First, download the .nupkg file:
    2. Secondly, install the .nupkg file into your project

    If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

    hth

    Marcin

    1 person found this answer helpful.

  2. MOON 40 Reputation points
    2025-06-11T20:24:44.4566667+00:00

    Following instructions are the exact solution for this thread. Target operating system is Windows x64. None of the steps explicitly includes any CLI application; all of them is carried out via GUI applications.


    1. Go to the NuGet web site, download necessary packages and place them to a local empty folder. Pay attention to package dependencies and versions. API versions must support project SDK.
    2. Start Visual Studio and go to "Options/NuGet Package Manager/Package Sources". At this page, click plus button to create a new NuGet package source and refer it to the directory in which downloaded NUPKG files exist. Also uncheck box of the source named "Nuget.org" because Visual Studio`s default behavior tends to use this online service.
    3. Open any .NET project whose SDK version is supported by downloaded packages, then go to "Project/Manage NuGet Packages" menu section of Visual Studio. At this page, choose newly created NuGet source from dropdown list and find and install the target package into the project.
    4. At this point, Visual Studio makes packages ready to use. Their directory is "%userprofile%\.nuget\packages". This is not acceptable due to the fact that if current user is removed from operating system, the directory is erased, so copy the NuGet package folders.
    5. During Visual Studio installation, Visual Studio Installer installs default NuGet packages into the directory "%programfiles(x86)%\Microsoft SDKs\NuGetPackages". Visual Studio`s package manager has an entry named "Microsoft Visual Studio Offline Packages" for this directory as NuGet package source. That is why, copied files need to be pasted into the directory.
    6. Go to the page mentioned at step 2 and delete the entry created at step 2. At same page, make sure checkbox of "Microsoft Visual Studio Offline Packages" is signed. After now all projects and users could install the downloaded packages at that computer without network connection.
    7. The local folder mentioned in step 1 can be deleted since NUPKG files of that folder have already been distributed towards related locations, so they are no needed any more.
    0 comments No comments

  3. Michael Taylor 60,161 Reputation points
    2025-06-11T20:47:37.0266667+00:00

    Just to be clear here, NuGet already does this. It will only download a package once per user per version. By default it then caches the package into a folder in the user's directory (e.g. c:\users\<user>\appdata\.nuget\packages or something like that). Once a package version has been downloaded NuGet always retrieve the package from there rather than downloading it again. This has been true for pretty much the life of NuGet. You don't need to create your own custom package source or anything like that. You're just replicating the caching that is already done.One of the few benefits of having a custom package source is when you need to restore packages across multiple users or your user's package cache gets cleared. In that case NuGet will not find the package locally and it'll down it again. You can literally copy that package directory and put it anywhere you want, which is the same as a custom package source. All you need to do to have NuGet use the new cache directory is update your nuget config file for your user.

    In fact that is the recommended approach when using Dev Drive. You create a VHD where all your source code goes. You then move all package management tool caches (such as npm and NuGet) to the VHD and adjust each tools configuration. You then have a centralized directory that you can literally copy to anybody's machine and they would never have to download again.

    Of course, irrelevant of your custom package source or caching approach, checking for updated packages and updating packages in projects will trigger an Internet call to retrieve the updated package. There is nothing you can do about that. However if the machine doesn't have a package then you can download it from a machine that does and then copy the package directory from the cache to another machine's cache. This is one reason why Dev Drive is nice. I can literally copy the VHD to another machine and be back to work without having to redownload projects, package dependencies, etc.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.