How to use NuGet package in production

Lev Minkovsky 1 Reputation point
2022-03-20T17:09:58.947+00:00

Hello, my .NET Core 6 console application is run on a production server without Visual Studio on it. I cannot seem to find any information on how to prepare a production computer so that the application could find the NuGet packages it depends on. I manually copy all the assemblies from these dependencies to the application folder, but this approach is clearly both wrong and unsustainable. Thank you.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,398 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Karen Payne MVP 35,191 Reputation points
    2022-03-20T18:05:09.13+00:00

    Unsure why you think that copying a console application to a production server is both wrong and unsustainable.

    There are two choices, copy files for the application to the server or create a setup program to install the application.

    Not knowing your policies at your workplace, both options are viable outside of who installs or copies the application to the server but either way there is nothing wrong with copying the application to a server.

    NuGet packages typically reside in the application folder, see Adding packages to the feed externally and Setting Up A Private Nuget Server (for development)

    Note you can point to apps to custom locations

    # Set repositoryPath in the user-level config file  
    nuget config -set repositoryPath=c:\packages   
      
    # Set repositoryPath in project-level files  
    nuget config -set repositoryPath=c:\packages -configfile c:\my.Config  
    nuget config -set repositoryPath=c:\packages -configfile .\myApp\NuGet.Config  
      
    # Set repositoryPath in the computer-level file (requires elevation)  
    nuget config -set repositoryPath=c:\packages -configfile %ProgramFiles(x86)%\NuGet\Config\NuGet.Config  
    
    0 comments No comments