1. Downloading packages to a build server
Motivation:
You have a .NET solution that uses NuGet package manager.
You have many files in the packages folder and want them to be downloaded to your build server.
Solution:
- Download Windows x86 Commandline.
- Copy nuget.exe to an folder and add the folder path to Windows PATH.
- Open Command Prompt and execute the commands below.
cd D:\Build\Source nuget restore YourSolutionFileName.sln
2. Downloading (Restoring) packages using MSBuild
- Execute the commands below.
"C:\Program Files\Microsoft Visual Studio\2022\Professional\Msbuild\Current\Bin\MSBuild.exe" "../YourSolution.sln" -restore -p:RestorePackagesConfig=true
3. Updating packages for a solution using VS Studio Package Manager Console
- Open Tools > NuGet Package Manager > Package Manager Console.
- Execute the commands below.
Update-Package
4. Reinstalling packages for a solution using VS Studio Package Manager Console
- Open Tools > NuGet Package Manager > Package Manager Console.
- Execute the commands below.
Update-Package –reinstall
5. Configuring package restore when building a project using VS Studio :
- Open Tools > NuGet Package Manager > Package Manager Settings.
6. Reverting PackageReference project to packages.config:
- Copy and overwrite project file from backup created by Visual Studio or from source control system.
- Delete all obj and bin files.
7. Fixing “Could not load file or assembly…” issue:
- Example issue:
Could not load file or assembly 'Microsoft.IdentityModel.Tokens.Saml, Version=8.0.2.0
- Open Visual Studio > Solution > Project > References > Microsoft.IdentityModel.Tokens.Saml > Properties and identify file or assembly version, e.g. 8.1.2.0.
- Open Visual Studio > Solution > Project > web.config, search for Microsoft.IdentityModel.Tokens.Saml and modify the version for the file or assembly. Example:
<bindingRedirect oldVersion="0.0.0.0-8.1.2.0" newVersion="8.1.2.0" />
- Repeat the process for all the files or assemblies.