First, list local NuGet package sources:
> dotnet nuget locals all --list
info : http-cache: C:\Users\bigfo\AppData\Local\NuGet\v3-cache
info : global-packages: C:\Users\bigfo\.nuget\packages\
info : temp: C:\Users\bigfo\AppData\Local\Temp\NuGetScratch
Then, use one of those sources during
dotnet restore --source C:\Users\bigfo\.nuget\packages\
dotnet build --no-restore
dotnet run --no-restore
The above works if we have the required NuGet package in our local cache. We will have such a cache if we have already run
dotnet restore on the project when we did have an Internet connection.
This is a relief when we are offline, would like to work on an existing software project, and are receiving these kinds of errors:
Unable to load the service index for source https://api.nuget.org/v3/index.json.
An error occurred while sending the request.
The server name or address could not be resolved.
It would be nice if the .NET Core team made working offline more intuitive, for instance, with a command such as
dotnet restore --local-only. For now we have the above as a workaround.