Document your code
Every project on GitHub comes with a version-controlled wiki to give your documentation the high level of care it deserves. It’s easy to create well-maintained, Markdown or rich text documentation alongside your code.
Sign up for free See pricing for teams and enterprises[Spec] Package download API
Status: Incubation
Intro
Msbuild SDK Resolver need an API From NuGet which can download nuget package to .nuget folder by passing package Id and version.
The goal of this API is to provider a high level interface (supports cross-platform) to download nuget package directly and return the package path.
Public APIs
- It will be some static utility methods in project NuGet.Commands or new Project
// Download the package
public static async Task<string> DownloadPackageAsync(string packageId,
string versionRange,
string initialConfigDirectory,
ILogger log);
public static async Task<string> DownloadPackageAsync(string packageId,
string versionRange,
string configFile
ILogger log);
// Download the package and all dependency packages
public static async Task<string> DownloadPackageClosureAsync(string packageId,
string versionRange,
string initialConfigDirectory,
string targetFramework
ILogger log);
public static async Task<string> DownloadPackageClosureAsync(string packageId,
string versionRange,
string configFile
string targetFramework
ILogger log);
public static async Task<string> IsPackageInstalled(string packageId, string version);
Parameters
- Package Id Type: String
- Package Version Range Type: String
- Target Framework Type: String
- NuGet Setting Root Path Type: String
- NuGet Config File Path Type: String
Option Parameters
- NoCache
Returns
Package path for the package which is passed as parameter
Msbuild Task
(In) Task Parameters
- Package Id
- Package version Range
- NuGet Setting Root
- NuGet Config File Path
- TargetFramework
- Nocahe
(out) Msbuild item
- Package installed Path for the package which is passed as parameter
Design
-
How to discover Package source, Package Credential?
This API will use NuGet.Config to get Package Source information
- User pass NuGet.Config file to the API, then it will use this specified NuGet.Config
- If No NuGet.Config passed and Root path is null or empty, it will load NuGet.Config from Appdata and ProgramData
- If No NuGet.Config passed and Root path is not null, it will load every Nuget.Config from Root Path to Driver root and also load NuGet.Config from Appdata and ProgramData.
- How to consume this API?
- Reference NuGet.Commands or a new package which contains this API in their project.
- NuGet provides a msbuild task to call this API. (need a msbuild task spec for this)
-
Does this API ignore failed source?
Yes, this API ignore failed source by default. we might add parameter to override this behavior in the future.
Open Questions:
- Does NuGet need to support downloading multiple packages in one call?
- Does NuGet need to provide a way to find all dependency packages after the top package downloaded?
- Do we need a new project for this API?
- what's the return type (string / Boolean / result type)?
- Does this API accept VersionRange Type?
- Should we put this API in a new dll?