Skip to content

Provide a mechanism to get root of the restore folder of the resolved nuget package #4174

Closed

Description

@ramarag

I am currently using the following to get the to the root:
FallbackPackagePathResolver.PathResolver.GetVersionListPath("") ;

as in ramarag/sdk@a352148#diff-42d31913aec3dcadaa9bf9b5eafba94cR42

Is this is the right way to consume The API ?

Activity

  1. ramarag commented on Dec 31, 2016

    @ramarag
    Author
  2. emgarten commented on Dec 31, 2016

    @emgarten
    Member

    packageDir = pkginfo.PathResolver.GetInstallPath(packageId, version); will give you the root of the package folder.

    Example:

    c:\users\user\.nuget\packages\a\1.0.0\a.nuspec
    
    GetInstallPath("a", "1.0.0") -> c:\users\user\.nuget\packages\a\1.0.0\
    

    Paths in the lock file are relative to the install path, you should combine based on that. In your case you already have it as packageDir

  3. ramarag commented on Dec 31, 2016

    @ramarag
    Author

    @emgarten i need the cache Root not packagDir
    In the above example it translates to the nuget cache root directory

    GetVersionListPath("") -> C:\users\user\.nuget\packages

  4. emgarten commented on Dec 31, 2016

    @emgarten
    Member

    There isn't a helper method for that currently, is this code copying all of the packages from each folder, or what will this do?

    The safest way to get the root for all packages would be to:

    1. Take the list of root package folders: ramarag/sdk@a352148#diff-42d31913aec3dcadaa9bf9b5eafba94cR51
    2. Sort by path length desc
    3. Take the first folder when the packageDir starts with the package folder path

    Ordering by length would protect against any nested folder scenarios

  5. schellap commented on Jan 9, 2017

    @schellap
  6. emgarten commented on Jan 9, 2017

    @emgarten
    Member

    I've checked in a fix to make the Root property public on the VersoinFolderPathResolver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions