Skip to content
This repository was archived by the owner on Dec 18, 2017. It is now read-only.
This repository was archived by the owner on Dec 18, 2017. It is now read-only.

"dnu restore" should check whether an installed package is corrupted #1243

Closed
@MattGal

Description

@MattGal

If the users deletes the package cache folder in most cases, a simple KPM restore will fix this back up. This seems to be a fairly common scenario when using * versioning to ensure a new version is picked up.

I routinely delete this folder while VS is still running. When I do that, any DLL that was loaded at the time won't be delete-able due to the file handles open to it. That means I end up with package directories that ONLY contain something like this:

C:\Users\mattgal\.k\packages\Microsoft.Framework.Logging\1.0.0-beta4-10858\lib\aspnet50\Microsoft.Framework.Logging.dll  (because I was running something using this DLL at the time...)

Now, I've put my machine into a state that kpm command line tools don't know how to handle and which do not get a helpful error message:

System.IO.FileNotFoundException: Could not find file 'C:\Users\mattgal\.k\packages\Microsoft.Framework.Logging\1.0.0-beta4-10858\Microsoft.Framework.Logging.nuspec'.
File name: 'C:\Users\mattgal\.k\packages\Microsoft.Framework.Logging\1.0.0-beta4-10858\Microsoft.Framework.Logging.nuspec'
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES se
cAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at NuGet.PhysicalFileSystem.OpenFile(String path)
   at NuGet.UnzippedPackage.EnsureManifest()
   at NuGet.UnzippedPackage..ctor(IFileSystem fileSystem, String manifestPath)
   at NuGet.PackageInfo.get_Package()
   at Microsoft.Framework.Runtime.NuGetDependencyResolver.FindCandidate(String name, SemanticVersionRange versionRange)
   at Microsoft.Framework.Runtime.NuGetDependencyResolver.GetDescription(LibraryRange libraryRange, FrameworkName targetFramework)
   at Microsoft.Framework.PackageManager.LocalWalkProvider.FindLibrary(LibraryRange libraryRange, FrameworkName targetFramework)
   at Microsoft.Framework.PackageManager.RestoreOperations.<>c__DisplayClass8_0.<FindLibraryByVersion>b__2(IWalkProvider provider)
   at Microsoft.Framework.PackageManager.RestoreOperations.<FindLibrary>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---

When such an invalid state is detected, either a corrective action should be suggested via error text, or (I'd be fine with this) just blow away that package folder if you can find a version-matching package.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions