The error message is usually due to the fact that NuGet cannot open the NuGet package because it could not download it. I would check your NuGet cache to see if the NuGet.CommandLine.2.7.1.nupkg file is equal to zero bytes or less than expected. If so, delete the file or clear the cache and try again. Sometimes the download may fail and NuGet leaves an empty file in the cache , which causes problems when installing this NuGet package. You can also see an error if the NuGet package has not fully loaded, so the package will not be zero, but it will not be fully loaded, and NuGet will not be able to open it. Therefore, you should remove the NuGet package from the cache and try again.
The NuGet cache is located in the following directory:
%localappdata%\NuGet\Cache
You can also go to the NuGet cache from Visual Studio by opening the package manager settings, selecting General and clicking the Browse button.
Please note that with newer versions of NuGet 2.8 this problem should be fixed. NuGet in later versions will be downloaded to a temporary file location and renamed after the download is completed, so the partially downloaded NuGet package will not remain in the cache.
source share