New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make packages folder optional #2638

Merged
merged 19 commits into from Aug 26, 2017
Commits
Jump to file or symbol
Failed to load files and symbols.
+21 −26
Diff settings

Always

Just for now

Viewing a subset of changes. View all

make isExtracted ignore any existing license files (this might be foo…

…led if a package only contains a specially named license file)
  • Loading branch information...
matthid committed Aug 26, 2017
commit 48341bd663b0278af331b7e2f32ead15b78e9912
@@ -603,13 +603,16 @@ let GetVersions force alternativeProjectRoot root (sources, packageName:PackageN
let _,v,_ = List.head sorted
SemVer.Parse v,sorted |> List.map (fun (_,_,x) -> x)) }
let private getLicenseFile (packageName:PackageName) version =
Path.Combine(NuGetCache.GetTargetUserFolder packageName version, NuGetCache.GetLicenseFileName packageName version)
/// Downloads the given package to the NuGet Cache folder
let DownloadPackage(alternativeProjectRoot, root, config:PackagesFolderGroupConfig, (source : PackageSource), caches:Cache list, groupName, packageName:PackageName, version:SemVerInfo, isCliTool, includeVersionInPath, force, detailed) =
let nupkgName = packageName.ToString() + "." + version.ToString() + ".nupkg"
let normalizedNupkgName = packageName.ToString() + "." + version.Normalize() + ".nupkg"
let normalizedNupkgName = NuGetCache.GetPackageFileName packageName version
let targetFileName = NuGetCache.GetTargetUserNupkg packageName version
let targetFile = FileInfo targetFileName
let licenseFileName = Path.Combine(NuGetCache.GetTargetUserFolder packageName version, packageName.ToString() + "." + version.Normalize() + ".license.html")
let licenseFileName = getLicenseFile packageName version
let rec getFromCache (caches:Cache list) =
match caches with
@@ -242,20 +242,24 @@ let fixArchive fileName =
if isMonoRuntime then
fixDatesInArchive fileName
let inline isExtracted (directory:DirectoryInfo) fileName =
let fi = FileInfo(fileName)
let GetLicenseFileName (packageName:PackageName) (version:SemVerInfo) = packageName.ToString() + "." + version.Normalize() + ".license.html"
let GetPackageFileName (packageName:PackageName) (version:SemVerInfo) = packageName.ToString() + "." + version.Normalize() + ".nupkg"
let inline isExtracted (directory:DirectoryInfo) (packageName:PackageName) (version:SemVerInfo) =
let inDir f = Path.GetFullPath(Path.Combine(directory.FullName, f))
let packFile = GetPackageFileName packageName version |> inDir
let licenseFile = GetLicenseFileName packageName version |> inDir
let fi = FileInfo(packFile)
if not fi.Exists then false else
if not directory.Exists then false else
directory.EnumerateFileSystemInfos()
|> Seq.exists (fun f -> f.FullName <> fi.FullName)
|> Seq.exists (fun f -> f.FullName <> fi.FullName && f.FullName <> licenseFile)
let IsPackageVersionExtracted(config:ResolvedPackagesFolder, packageName:PackageName, version:SemVerInfo) =
match config.Path with
| Some target ->
let targetFolder = DirectoryInfo(target)
let targetFileName = packageName.ToString() + "." + version.Normalize() + ".nupkg"
isExtracted targetFolder targetFileName
isExtracted targetFolder packageName version
| None ->
// Need to extract in .nuget dir?
true
@@ -295,7 +299,7 @@ let rec private cleanup (dir : DirectoryInfo) =
let GetTargetUserFolder packageName (version:SemVerInfo) =
DirectoryInfo(Path.Combine(Constants.UserNuGetPackagesFolder,packageName.ToString(),version.Normalize())).FullName
let GetTargetUserNupkg packageName (version:SemVerInfo) =
let normalizedNupkgName = packageName.ToString() + "." + version.Normalize() + ".nupkg"
let normalizedNupkgName = GetPackageFileName packageName version
let path = GetTargetUserFolder packageName version
Path.Combine(path, normalizedNupkgName)
@@ -315,7 +319,7 @@ let rec ExtractPackageToUserFolder(fileName:string, packageName:PackageName, ver
DirectoryInfo(dir)
use _ = Profile.startCategory Profile.Category.FileIO
if isExtracted targetFolder fileName |> not then
if isExtracted targetFolder packageName version |> not then
Directory.CreateDirectory(targetFolder.FullName) |> ignore
let fi = FileInfo fileName
let targetPackageFileName = Path.Combine(targetFolder.FullName,fi.Name)
@@ -342,7 +346,7 @@ let ExtractPackage(fileName:string, targetFolder, packageName:PackageName, versi
async {
use _ = Profile.startCategory Profile.Category.FileIO
let directory = DirectoryInfo(targetFolder)
if isExtracted directory fileName then
if isExtracted directory packageName version then
if verbose then
verbosefn "%O %O already extracted" packageName version
else
@@ -106,7 +106,7 @@ let removeOlderVersionsFromCache(cache:Cache, packageName:PackageName, versions:
| Some CacheType.CurrentVersion ->
let fileNames =
versions
|> Seq.map (fun v -> packageName.ToString() + "." + v.Normalize() + ".nupkg" |> normalizePath)
|> Seq.map (fun v -> NuGetCache.GetPackageFileName packageName v |> normalizePath)
|> Set.ofSeq
targetFolder.EnumerateFiles(packageName.ToString() + ".*.nupkg")
@@ -112,20 +112,8 @@ let ExtractPackage(alternativeProjectRoot, root, groupName, sources, caches, for
return! extractPackage caches package alternativeProjectRoot root source groupName v includeVersionInPath force
| LocalNuGet(path,_) ->
let path = Utils.normalizeLocalPath path
let di = Utils.getDirectoryInfoForLocalNuGetFeed path alternativeProjectRoot root
let nupkg = NuGetLocal.findLocalPackage di.FullName package.Name v
CopyToCaches force caches nupkg.FullName
let! cacheFolder = NuGetCache.ExtractPackageToUserFolder(nupkg.FullName, package.Name, package.Version, package.IsCliTool, false)
let! folder = NuGetCache.CopyFromCache(resolvedStorage, nupkg.FullName, "", package.Name, v, force, false)
let extractedFolder =
match folder with
| Some f -> f
| None -> cacheFolder
return package, NuGet.GetContent extractedFolder
| LocalNuGet(path,_) as source ->
return! extractPackage caches package alternativeProjectRoot root source groupName v includeVersionInPath force
}
// manipulate overridenFile after package extraction
ProTip! Use n and p to navigate between commits in a pull request.