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.
+429 −212
Diff settings

Always

Just for now

View
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26430.6
VisualStudioVersion = 15.0.26730.8
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{A6A6AF7D-D6E3-442D-9B1E-58CC91879BE1}"
EndProject
@@ -54,6 +54,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "content", "content", "{8E6D
docs\content\local-file.md = docs\content\local-file.md
docs\content\lock-file.md = docs\content\lock-file.md
docs\content\nuget-dependencies.md = docs\content\nuget-dependencies.md
docs\content\paket-and-dotnet-cli.md = docs\content\paket-and-dotnet-cli.md
docs\content\paket-folder.md = docs\content\paket-folder.md
docs\content\paket.dependencies = docs\content\paket.dependencies
docs\content\paket.lock = docs\content\paket.lock
@@ -109,9 +110,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".paket", ".paket", "{62D18A
EndProjectSection
EndProject
Global
GlobalSection(Performance) = preSolution
HasPerformanceSessions = true
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
@@ -153,6 +151,12 @@ Global
{7C622582-E281-4EAB-AADA-B5893BB89B45} = {ED8079DD-2B06-4030-9F0F-DC548F98E1C4}
{7234B9B4-8CF5-4E68-AA29-050C087B9246} = {ED8079DD-2B06-4030-9F0F-DC548F98E1C4}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {61E9964A-34E0-4B78-8854-B092E6764056}
EndGlobalSection
GlobalSection(Performance) = preSolution
HasPerformanceSessions = true
EndGlobalSection
GlobalSection(Performance) = preSolution
HasPerformanceSessions = true
EndGlobalSection
@@ -155,6 +155,33 @@ nuget Example >= 2.0
If you change the target framework of the projects then you need to run
[`paket install`](paket-install.html) again.
### Disable packages folder
With the net netcore release and the switch to provide more and more netstandard-only packages
the Paket team noticed an dramatic increase of the well known "packages" folder.
Historically one way was to tell Paket that you only want to compile for `framework: net45`.
However, this doesn't prevent netstandard dependencies in all situations.
On the other side more features are provided by Paket and the packages folder has become more and more redundant:
- Load scripts can reference the files in the global cache
- csproj/fsproj files can references files in the global cache
- netcore project files don't require any explicit dll-references
Therefore, the paket team decided to make the "packages" folder opt-out.
> This feature is currently considered beta
You can opt-out of generating the `packages` folder by using the `storage` option:
```paket
// Do not extract into the "packages" folder but use a globally shared directory
storage: none
source https://nuget.org/api/v2
nuget jQuery
```
The storage option may be overriden by packages.
However, the behavior is undefined and may change (please open an issue if you depend on the current behavior or we break you).
### Controlling whether content files should be copied to the project
The `content` option controls the installation of any content files:
@@ -51,6 +51,10 @@ allows you to use specialized NuGet packages that provide `dotnet` CLI tools.
CLI tools are only available for .NET SDK-based projects.
> Consider setting `storage: none` in your dependencies file for the relevant groups to mirror NuGet behavior and
> not copy all dependencies to the packages folder. This will keep your repository folder small and clean.
> Please read the relevant section of the [`paket.dependencies` file](dependencies-file.html) documentation.
### Installing dependencies
Install all required packages with:
@@ -28,7 +28,8 @@ let ``#49 windsor should resolve correctly``() =
[<Test>]
let ``#51 should resolve with pessimistic strategy correctly``() =
let lockFile = update "i000051-resolve-pessimistic"
// TODO: change back to i000051-resolve-pessimistic
let lockFile = update "i000051"
lockFile.Groups.[Constants.MainDependencyGroup].Resolution.[PackageName "Castle.Windsor-log4net"].Version
|> shouldEqual (SemVer.Parse "3.2.0.1")
@@ -39,6 +39,7 @@
<Compile Include="$(PaketCoreSourcesDir)\Dependencies\PackageResolver.fs" />
<Compile Include="$(PaketCoreSourcesDir)\Dependencies\Nuspec.fs" />
<Compile Include="$(PaketCoreSourcesDir)\Dependencies\NuGetCache.fs" />
<Compile Include="$(PaketCoreSourcesDir)\Dependencies\CacheExtensions.fs" />
<Compile Include="$(PaketCoreSourcesDir)\Dependencies\NuGetV3.fs" />
<Compile Include="$(PaketCoreSourcesDir)\Dependencies\NuGetV2.fs" />
<Compile Include="$(PaketCoreSourcesDir)\Dependencies\NuGetLocal.fs" />
@@ -24,7 +24,7 @@ let [<Literal>] TargetsFileName = "paket.targets"
let [<Literal>] ReferencesFile = "paket.references"
let [<Literal>] AccessLockFileName = "paket.locked"
let [<Literal>] PaketFilesFolderName = "paket-files"
let [<Literal>] PackagesFolderName = "packages"
let [<Literal>] DefaultPackagesFolderName = "packages"
let [<Literal>] SolutionFolderProjectGuid = "2150E333-8FDC-42A3-9474-1A3956D46DE8"
let [<Literal>] PaketVersionFileName = "paket.version"
let [<Literal>] TemplateFile = "paket.template"
@@ -155,7 +155,23 @@ let getDirectoryInfoForLocalNuGetFeed pathInfo alternativeProjectRoot root =
match alternativeProjectRoot with
| Some root -> DirectoryInfo(Path.Combine(root, s))
| None -> DirectoryInfo(Path.Combine(root, s))
// show the path that was too long
let FileInfo(str) =
try
FileInfo(str)
with
:? PathTooLongException as exn -> raise (PathTooLongException("Path too long: " + str, exn))
// show the path that was too long
let DirectoryInfo(str) =
try
DirectoryInfo(str)
with
:? PathTooLongException as exn -> raise (PathTooLongException("Path too long: " + str, exn))
/// Creates a directory if it does not exist.
let createDir path =
try
@@ -786,20 +802,52 @@ let inline windowsPath (path:string) = path.Replace(Path.DirectorySeparatorChar,
/// Gets all files with the given pattern
let inline FindAllFiles(folder, pattern) = DirectoryInfo(folder).GetFiles(pattern, SearchOption.AllDirectories)
let getTargetFolder root groupName (packageName:PackageName) version includeVersionInPath =
let packageFolder = string packageName + if includeVersionInPath then "." + string version else ""
if groupName = Constants.MainDependencyGroup then
Path.Combine(root, Constants.PackagesFolderName, packageFolder)
else
Path.Combine(root, Constants.PackagesFolderName, groupName.CompareString, packageFolder)
type ResolvedPackagesFolder =
/// No "packages" folder for the current package
| NoPackagesFolder
/// the /packages/group/ExtractedPackage.X.Y.Z folder
| ResolvedFolder of string
member x.Path =
match x with
| NoPackagesFolder -> None
| ResolvedFolder f -> Some f
type PackagesFolderGroupConfig =

This comment has been minimized.

@matthid

matthid Aug 20, 2017

Member

I don't like the name and the location :/

@matthid

matthid Aug 20, 2017

Member

I don't like the name and the location :/

| NoPackagesFolder
| GivenPackagesFolder of string
| DefaultPackagesFolder
member x.ResolveGroupDir root groupName =
match x with
| NoPackagesFolder -> None
| GivenPackagesFolder p ->
// relative to root
Some p
| DefaultPackagesFolder ->
let groupDir =
if groupName = Constants.MainDependencyGroup then
Path.Combine(root, Constants.DefaultPackagesFolderName)
else
Path.Combine(root, Constants.DefaultPackagesFolderName, groupName.CompareString)
Some groupDir
member x.Resolve root groupName (packageName:PackageName) version includeVersionInPath =
match x with
| NoPackagesFolder -> ResolvedPackagesFolder.NoPackagesFolder
| GivenPackagesFolder p ->
// relative to root
ResolvedPackagesFolder.ResolvedFolder p
| DefaultPackagesFolder ->
let groupDir = x.ResolveGroupDir root groupName |> Option.get
let packageFolder = string packageName + if includeVersionInPath then "." + string version else ""
let parent = Path.Combine(groupDir, packageFolder)
ResolvedPackagesFolder.ResolvedFolder parent
static member Default = DefaultPackagesFolder
let RunInLockedAccessMode(rootFolder,action) =
let packagesFolder = Path.Combine(rootFolder,Constants.PackagesFolderName)
if Directory.Exists packagesFolder |> not then
Directory.CreateDirectory packagesFolder |> ignore
let paketFilesFolder = Path.Combine(rootFolder,Constants.PaketFilesFolderName)
if Directory.Exists paketFilesFolder |> not then
Directory.CreateDirectory paketFilesFolder |> ignore
let p = System.Diagnostics.Process.GetCurrentProcess()
let fileName = Path.Combine(packagesFolder,Constants.AccessLockFileName)
let fileName = Path.Combine(paketFilesFolder,Constants.AccessLockFileName)
// Checks the packagesFolder for a paket.locked file or waits until it get access to it.
let rec acquireLock (startTime:DateTime) (timeOut:TimeSpan) trials =
@@ -0,0 +1,21 @@
namespace Paket
open System.IO
open Paket.Domain
[<AutoOpen>]
module CacheExtensions =
type Nuspec with
static member LoadFromCache(name:PackageName, version) =
let folder = DirectoryInfo(NuGetCache.GetTargetUserFolder name version).FullName
let nuspec = Path.Combine(folder,sprintf "%O.nuspec" name)
Nuspec.Load nuspec
type PackageResolver.PackageInfo with
member x.Folder root groupName =
let settings = x.Settings
let includeVersion = defaultArg settings.IncludeVersionInPath false
let storageConf = defaultArg settings.StorageConfig PackagesFolderGroupConfig.Default
match (storageConf.Resolve root groupName x.Name x.Version includeVersion).Path with
| Some f -> f
| None ->
NuGetCache.GetTargetUserFolder x.Name x.Version
@@ -194,6 +194,7 @@ module DependenciesFileParser =
| AutodetectFrameworkRestrictions
| ImportTargets of bool
| CopyLocal of bool
| StorageConfig of PackagesFolderGroupConfig option
| SpecificVersion of bool
| CopyContentToOutputDir of CopyToOutputDirectorySettings
| GenerateLoadScripts of bool option
@@ -281,6 +282,14 @@ module DependenciesFileParser =
| _ -> None
Some (ParserOptions (ParserOption.Redirects setting))
| String.RemovePrefix "storage" trimmed ->
let setting =
match trimmed.Replace(":","").Trim() with
| String.EqualsIC "none" -> Some PackagesFolderGroupConfig.NoPackagesFolder
| String.EqualsIC "packages" -> Some PackagesFolderGroupConfig.DefaultPackagesFolder
| _ -> None
Some (ParserOptions (ParserOption.StorageConfig setting))
| String.RemovePrefix "strategy" trimmed ->
let setting =
match trimmed.Replace(":","").Trim() with
@@ -432,6 +441,7 @@ module DependenciesFileParser =
| Redirects mode -> { current.Options with Redirects = mode }
| ResolverStrategyForTransitives strategy -> { current.Options with ResolverStrategyForTransitives = strategy }
| ResolverStrategyForDirectDependencies strategy -> { current.Options with ResolverStrategyForDirectDependencies = strategy }
| StorageConfig mode -> { current.Options with Settings = { current.Options.Settings with StorageConfig = mode } }
| CopyLocal mode -> { current.Options with Settings = { current.Options.Settings with CopyLocal = Some mode } }
| SpecificVersion mode -> { current.Options with Settings = { current.Options.Settings with SpecificVersion = Some mode } }
| CopyContentToOutputDir mode -> { current.Options with Settings = { current.Options.Settings with CopyContentToOutputDirectory = Some mode } }
@@ -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, (source : PackageSource), caches:Cache list, groupName, packageName:PackageName, version:SemVerInfo, isCliTool, includeVersionInPath, force, detailed) =
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 targetFileName = Path.Combine(Constants.NuGetCacheFolder, normalizedNupkgName)
let normalizedNupkgName = NuGetCache.GetPackageFileName packageName version
let targetFileName = NuGetCache.GetTargetUserNupkg packageName version
let targetFile = FileInfo targetFileName
let licenseFileName = Path.Combine(Constants.NuGetCacheFolder, packageName.ToString() + "." + version.Normalize() + ".license.html")
let licenseFileName = getLicenseFile packageName version
let rec getFromCache (caches:Cache list) =
match caches with
@@ -648,6 +651,8 @@ let DownloadPackage(alternativeProjectRoot, root, (source : PackageSource), cach
let nupkg = NuGetLocal.findLocalPackage di.FullName packageName version
use _ = Profile.startCategory Profile.Category.FileIO
let parent = Path.GetDirectoryName targetFileName
if not (Directory.Exists parent) then Directory.CreateDirectory parent |> ignore
File.Copy(nupkg.FullName,targetFileName)
| _ ->
// discover the link on the fly
@@ -678,6 +683,8 @@ let DownloadPackage(alternativeProjectRoot, root, (source : PackageSource), cach
if authenticated && verbose then
tracefn "Downloading from %O to %s" !downloadUrl targetFileName
let dir = Path.GetDirectoryName targetFileName
if Directory.Exists dir |> not then Directory.CreateDirectory dir |> ignore
use trackDownload = Profile.startCategory Profile.Category.NuGetDownload
let! license = Async.StartChild(DownloadLicense(root,force,packageName,version,nugetPackage.LicenseUrl,licenseFileName), 5000)
@@ -756,6 +763,12 @@ let DownloadPackage(alternativeProjectRoot, root, (source : PackageSource), cach
async {
do! download true 0
let! files = NuGetCache.CopyFromCache(root, groupName, targetFile.FullName, licenseFileName, packageName, version, isCliTool, includeVersionInPath, force, detailed)
return targetFileName,files
let! extractedUserFolder = ExtractPackageToUserFolder(targetFile.FullName, packageName, version, isCliTool, detailed)
let configResolved = config.Resolve root groupName packageName version includeVersionInPath
let! files = NuGetCache.CopyFromCache(configResolved, targetFile.FullName, licenseFileName, packageName, version, force, detailed)
let finalFolder =
match files with
| Some f -> f
| None -> extractedUserFolder
return targetFileName,finalFolder
}
Oops, something went wrong.
ProTip! Use n and p to navigate between commits in a pull request.