Skip to content

Commit

Permalink
Update to Paket 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Sep 15, 2015
1 parent 6c39f96 commit 225c445
Show file tree
Hide file tree
Showing 20 changed files with 104 additions and 73 deletions.
1 change: 1 addition & 0 deletions Paket.sln
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "content", "content", "{8E6D
docs\content\editor-support.md = docs\content\editor-support.md
docs\content\faq.md = docs\content\faq.md
docs\content\getting-started.md = docs\content\getting-started.md
docs\content\glossary.md = docs\content\glossary.md
docs\content\groups.md = docs\content\groups.md
docs\content\http-dependencies.md = docs\content\http-dependencies.md
docs\content\index.md = docs\content\index.md
Expand Down
2 changes: 1 addition & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#### 2.0.0-rc004 - 13.09.2015
#### 2.0.0 - 14.09.2015
* Support for `Dependency groups` in paket.dependencies files - http://fsprojects.github.io/Paket/groups.html
* Support for Roslyn-based analyzers - http://fsprojects.github.io/Paket/analyzers.html
* Support for reference conditions - https://github.com/fsprojects/Paket/issues/1026
Expand Down
2 changes: 1 addition & 1 deletion build.cmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@echo off
cls

.paket\paket.bootstrapper.exe prerelease
.paket\paket.bootstrapper.exe
if errorlevel 1 (
exit /b %errorlevel%
)
Expand Down
2 changes: 1 addition & 1 deletion build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ let tempDir = "temp"
let buildMergedDir = buildDir @@ "merged"
let buildMergedDirPS = buildDir @@ "Paket.PowerShell"


Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
// Read additional information from the release notes document
let releaseNotesData =
File.ReadAllLines "RELEASE_NOTES.md"
Expand Down
23 changes: 23 additions & 0 deletions docs/content/glossary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Glossary

### paket.dependencies

The [`paket.dependencies` file](dependencies-file.html) is used to specify rules regarding your application's dependencies.

### paket.lock

The [`paket.lock` file](lock-file.html) records the concrete dependency resolution of all direct and indirect dependencies of your project.

### paket.references

The [`paket.references` files](references-files.html) are used to specify which dependencies are to be installed into the MSBuild projects in your repository.

### paket.template

Thee [`paket.template` files](template-files.html) are used to specify rules to create new NuGet packages by using the [`paket pack` command](paket-pack.html).

### .paket folder

This folder is used the same way a `.nuget` folder is used for the NuGet package restore. Place this folder into the root of your solution.
It should include the paket.targets and [paket.bootstrapper.exe](https://github.com/fsprojects/Paket/releases/latest) files which can be downloaded from GitHub.
The bootstrapper.exe will always download the latest version of the paket.exe file into this folder.
2 changes: 0 additions & 2 deletions docs/content/groups.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Dependency Groups

<blockquote>Only in Paket 2.0 - currently in Release Candidate phase</blockquote>

*Groups* allow for better organization of dependencies and also enable [easier conflict resolution](groups.html#Conflict-resolution-with-groups).
Let's consider a small example:

Expand Down
10 changes: 1 addition & 9 deletions docs/content/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,7 @@ After that completes execute the install, to install Paket as a command line uti

### Installation on Windows

When using Windows, the previous installation methods work, just exchange the `*.sh` files for the `*.cmd` files.

build.cmd

Then run the install script to install Paket for command line use.

install.cmd

NOTE: If you use git-bash on Windows you can actually follow the Linux installation instructions and just use the `*.sh` files.
Please use the [Installation per repository](installation.html#Installation-per-repository) option.

### Post Installation

Expand Down
1 change: 1 addition & 0 deletions docs/tools/templates/template.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<li><a href="@Root/index.html">Home page</a></li>
<li><a href="@Root/getting-started.html">Getting started</a></li>
<li><a href="@Root/faq.html">FAQ</a></li>
<li><a href="@Root/glossary.html">Glossary</a></li>
<li><a href="@Root/release-notes.html">Release Notes</a></li>
<li><a href="@Root/testimonials.html">Testimonials</a></li>
<li><a href="@Root/license.html">License</a></li>
Expand Down
2 changes: 1 addition & 1 deletion src/Paket.Bootstrapper/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[assembly: AssemblyDescriptionAttribute("A package dependency manager for .NET with support for NuGet packages and GitHub repositories.")]
[assembly: AssemblyVersionAttribute("2.0.0")]
[assembly: AssemblyFileVersionAttribute("2.0.0")]
[assembly: AssemblyInformationalVersionAttribute("2.0.0-rc004")]
[assembly: AssemblyInformationalVersionAttribute("2.0.0")]
namespace System {
internal static class AssemblyVersionInformation {
internal const string Version = "2.0.0";
Expand Down
2 changes: 1 addition & 1 deletion src/Paket.Core/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ open System.Reflection
[<assembly: AssemblyDescriptionAttribute("A package dependency manager for .NET with support for NuGet packages and GitHub repositories.")>]
[<assembly: AssemblyVersionAttribute("2.0.0")>]
[<assembly: AssemblyFileVersionAttribute("2.0.0")>]
[<assembly: AssemblyInformationalVersionAttribute("2.0.0-rc004")>]
[<assembly: AssemblyInformationalVersionAttribute("2.0.0")>]
do ()

module internal AssemblyVersionInformation =
Expand Down
13 changes: 7 additions & 6 deletions src/Paket.Core/BindingRedirects.fs
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,13 @@ let private addConfigFileToProject projectFile =
project.Save())

/// Applies a set of binding redirects to all .config files in a specific folder.
let applyBindingRedirectsToFolder rootPath bindingRedirects =
// First create missing configuration files.
rootPath
|> getFoldersWithPaketReferencesAndNoConfig Directory.GetFiles
|> Seq.collect (createAppConfigInDirectory >> getProjectFilesInDirectory)
|> Seq.iter addConfigFileToProject
let applyBindingRedirectsToFolder createNewBindingFiles rootPath bindingRedirects =
if createNewBindingFiles then
// First create missing configuration files.
rootPath
|> getFoldersWithPaketReferencesAndNoConfig Directory.GetFiles
|> Seq.collect (createAppConfigInDirectory >> getProjectFilesInDirectory)
|> Seq.iter addConfigFileToProject

// Now ensure all configuration files have binding redirects.
rootPath
Expand Down
38 changes: 24 additions & 14 deletions src/Paket.Core/InstallProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,25 @@ open System.Reflection
open Paket.PackagesConfigFile
open Paket.Requirements

let updatePackagesConfigFile (model: Map<GroupName*PackageName,ResolvedPackage*InstallModel>) packagesConfigFileName =
let packagesInConfigFile = PackagesConfigFile.Read packagesConfigFileName

let packagesInModel =
model
|> Seq.filter (fun kv -> defaultArg (fst kv.Value).Settings.IncludeVersionInPath false)
|> Seq.map (fun kv ->
let settings,version = kv.Value
{ Id = kv.Key.ToString()
Version = (fst kv.Value).Version
TargetFramework = None })
|> Seq.toList

if packagesInModel <> [] then
packagesInConfigFile
|> Seq.filter (fun p -> packagesInModel |> Seq.exists (fun p' -> p'.Id = p.Id) |> not)
|> Seq.append packagesInModel
|> PackagesConfigFile.Save packagesConfigFileName

let findPackageFolder root (groupName,PackageName name) (version,settings) =
let includeVersionInPath = defaultArg settings.IncludeVersionInPath false
let lowerName = (name + if includeVersionInPath then "." + version.ToString() else "").ToLower()
Expand Down Expand Up @@ -118,7 +137,7 @@ let createModel(root, force, dependenciesFile:DependenciesFile, lockFile : LockF
extractedPackages

/// Applies binding redirects for all strong-named references to all app. and web. config files.
let private applyBindingRedirects root (extractedPackages:seq<_*InstallModel>) =
let private applyBindingRedirects createNewBindingFiles root (extractedPackages:seq<_*InstallModel>) =
extractedPackages
|> Seq.map (fun (package, model:InstallModel) -> model.GetLibReferencesLazy.Force())
|> Set.unionMany
Expand All @@ -142,7 +161,7 @@ let private applyBindingRedirects root (extractedPackages:seq<_*InstallModel>) =
Version = assembly.GetName().Version.ToString()
PublicKeyToken = token
Culture = None })
|> applyBindingRedirectsToFolder root
|> applyBindingRedirectsToFolder createNewBindingFiles root

let findAllReferencesFiles root =
root
Expand Down Expand Up @@ -228,18 +247,9 @@ let InstallIntoProjects(options : InstallerOptions, dependenciesFile, lockFile :
!d

project.UpdateReferences(model, usedPackages, options.Hard)

let packagesConfigFile = Path.Combine(FileInfo(project.FileName).Directory.FullName, Constants.PackagesConfigFile)

model
|> Seq.filter (fun kv -> defaultArg (fst kv.Value).Settings.IncludeVersionInPath false)
|> Seq.map (fun kv ->
let settings,version = kv.Value
{ Id = kv.Key.ToString()
Version = (fst kv.Value).Version
TargetFramework = None })
|> PackagesConfigFile.Save packagesConfigFile

Path.Combine(FileInfo(project.FileName).Directory.FullName, Constants.PackagesConfigFile)
|> updatePackagesConfigFile model

removeCopiedFiles project

Expand Down Expand Up @@ -299,7 +309,7 @@ let InstallIntoProjects(options : InstallerOptions, dependenciesFile, lockFile :
model
|> Seq.filter (fun kv -> (fst kv.Key) = g.Key)
|> Seq.map (fun kv -> kv.Value)
|> applyBindingRedirects root
|> applyBindingRedirects options.CreateNewBindingFiles root

/// Installs all packages from the lock file.
let Install(options : InstallerOptions, dependenciesFile, lockFile : LockFile) =
Expand Down
2 changes: 1 addition & 1 deletion src/Paket.Core/LockFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ type LockFile(fileName:string,groups: Map<GroupName,LockFileGroup>) =

member this.GetPackageHullSafe(referencesFile,groupName) =
match referencesFile.Groups |> Map.tryFind groupName with
| None -> failwithf "Group %O was not found in %s." groupName referencesFile.FileName
| None -> Result.Succeed(Set.empty)
| Some group ->
group.NugetPackages
|> Seq.map (fun package ->
Expand Down
5 changes: 4 additions & 1 deletion src/Paket.Core/ProcessOptions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@ type InstallerOptions =
{ Force : bool
Hard : bool
Redirects : bool
CreateNewBindingFiles : bool
OnlyReferenced : bool }

static member Default =
{ Force = false
Hard = false
Redirects = false
CreateNewBindingFiles = false
OnlyReferenced = false }

static member createLegacyOptions(force, hard, redirects) =
static member createLegacyOptions(force, hard, redirects, createNewBindingFiles) =
{ InstallerOptions.Default with
Force = force
Hard = hard
CreateNewBindingFiles = createNewBindingFiles
Redirects = redirects }

type UpdaterOptions =
Expand Down
49 changes: 21 additions & 28 deletions src/Paket.Core/PublicAPI.fs
Original file line number Diff line number Diff line change
Expand Up @@ -106,30 +106,22 @@ type Dependencies(dependenciesFileName: string) =

/// Adds the given package with the given version to the dependencies file.
member this.Add(groupName, package: string,version: string): unit =
this.Add(groupName, package, version, force = false, hard = false, withBindingRedirects = false, interactive = false, installAfter = true)
this.Add(groupName, package, version, force = false, hard = false, withBindingRedirects = false, createNewBindingFiles = false, interactive = false, installAfter = true)

/// Adds the given package with the given version to the dependencies file.
member this.Add(groupName, package: string,version: string,force: bool,hard: bool,interactive: bool,installAfter: bool): unit =
this.Add(groupName, package, version, force, hard, false, interactive, installAfter)

/// Adds the given package with the given version to the dependencies file.
member this.Add(groupName, package: string,version: string,force: bool,hard: bool,withBindingRedirects: bool,interactive: bool,installAfter: bool): unit =
member this.Add(groupName, package: string,version: string,force: bool,hard: bool,withBindingRedirects: bool, createNewBindingFiles:bool, interactive: bool,installAfter: bool): unit =
Utils.RunInLockedAccessMode(
this.RootPath,
fun () -> AddProcess.Add(dependenciesFileName, groupName, PackageName(package.Trim()), version,
InstallerOptions.createLegacyOptions(force, hard, withBindingRedirects),
InstallerOptions.createLegacyOptions(force, hard, withBindingRedirects, createNewBindingFiles),
interactive, installAfter))

/// Adds the given package with the given version to the dependencies file.
member this.AddToProject(groupName, package: string,version: string,force: bool,hard: bool,projectName: string,installAfter: bool): unit =
this.AddToProject(groupName, package, version, force, hard, false, projectName, installAfter)

/// Adds the given package with the given version to the dependencies file.
member this.AddToProject(groupName, package: string,version: string,force: bool,hard: bool,withBindingRedirects: bool,projectName: string,installAfter: bool): unit =
member this.AddToProject(groupName, package: string,version: string,force: bool,hard: bool,withBindingRedirects: bool, createNewBindingFiles:bool, projectName: string,installAfter: bool): unit =
Utils.RunInLockedAccessMode(
this.RootPath,
fun () -> AddProcess.AddToProject(dependenciesFileName, groupName, PackageName package, version,
InstallerOptions.createLegacyOptions(force, hard, withBindingRedirects),
InstallerOptions.createLegacyOptions(force, hard, withBindingRedirects, createNewBindingFiles),
projectName, installAfter))

/// Adds credentials for a Nuget feed
Expand All @@ -139,15 +131,15 @@ type Dependencies(dependenciesFileName: string) =
fun () -> ConfigFile.askAndAddAuth source username |> returnOrFail )

/// Installs all dependencies.
member this.Install(force: bool, hard: bool) = this.Install(force, hard, false)
member this.Install(force: bool, hard: bool) = this.Install(force, hard, false, false)

/// Installs all dependencies.
member this.Install(force: bool, hard: bool, withBindingRedirects: bool): unit =
this.Install(force, hard, withBindingRedirects, false)
member this.Install(force: bool, hard: bool, withBindingRedirects: bool, createNewBindingFiles:bool): unit =
this.Install(force, hard, withBindingRedirects, createNewBindingFiles, false)

/// Installs all dependencies.
member this.Install(force: bool, hard: bool, withBindingRedirects: bool, onlyReferenced: bool): unit =
this.Install({ InstallerOptions.createLegacyOptions(force, hard, withBindingRedirects) with OnlyReferenced = onlyReferenced })
member this.Install(force: bool, hard: bool, withBindingRedirects: bool, createNewBindingFiles:bool, onlyReferenced: bool): unit =
this.Install({ InstallerOptions.createLegacyOptions(force, hard, withBindingRedirects, createNewBindingFiles) with OnlyReferenced = onlyReferenced })

/// Installs all dependencies.
member private this.Install(options: InstallerOptions): unit =
Expand All @@ -157,38 +149,39 @@ type Dependencies(dependenciesFileName: string) =
{ UpdaterOptions.Default with Common = options }))

/// Creates a paket.dependencies file with the given text in the current directory and installs it.
static member Install(dependencies, ?path: string, ?force, ?hard, ?withBindingRedirects) =
static member Install(dependencies, ?path: string, ?force, ?hard, ?withBindingRedirects, ?createNewBindingFiles) =
let path = defaultArg path Environment.CurrentDirectory
let fileName = Path.Combine(path, Constants.DependenciesFileName)
File.WriteAllText(fileName, dependencies)
let dependencies = Dependencies.Locate(path)
dependencies.Install(
force = defaultArg force false,
hard = defaultArg hard false,
withBindingRedirects = defaultArg withBindingRedirects false)
withBindingRedirects = defaultArg withBindingRedirects false,
createNewBindingFiles = defaultArg createNewBindingFiles false)

/// Updates all dependencies.
member this.Update(force: bool, hard: bool): unit = this.Update(force, hard, false)
member this.Update(force: bool, hard: bool): unit = this.Update(force, hard, false, false)

/// Updates all dependencies.
member this.Update(force: bool,hard: bool,withBindingRedirects:bool): unit =
this.Update(force, hard, withBindingRedirects, true)
member this.Update(force: bool,hard: bool,withBindingRedirects:bool, createNewBindingFiles:bool): unit =
this.Update(force, hard, withBindingRedirects, createNewBindingFiles, true)

/// Updates all dependencies.
member this.Update(force: bool, hard: bool, withBindingRedirects: bool, installAfter: bool): unit =
member this.Update(force: bool, hard: bool, withBindingRedirects: bool, createNewBindingFiles:bool, installAfter: bool): unit =
Utils.RunInLockedAccessMode(
this.RootPath,
fun () -> UpdateProcess.Update(dependenciesFileName,
{ UpdaterOptions.Default with
Common = InstallerOptions.createLegacyOptions(force, hard, withBindingRedirects)
Common = InstallerOptions.createLegacyOptions(force, hard, withBindingRedirects, createNewBindingFiles)
NoInstall = installAfter |> not }))

/// Updates the given package.
member this.UpdatePackage(groupName, package: string, version: string option, force: bool, hard: bool): unit =
this.UpdatePackage(groupName, package, version, force, hard, false, true)
this.UpdatePackage(groupName, package, version, force, hard, false, false, true)

/// Updates the given package.
member this.UpdatePackage(groupName: string option, package: string, version: string option, force: bool, hard: bool, withBindingRedirects: bool, installAfter: bool): unit =
member this.UpdatePackage(groupName: string option, package: string, version: string option, force: bool, hard: bool, withBindingRedirects: bool, createNewBindingFiles:bool, installAfter: bool): unit =
let groupName =
match groupName with
| None -> Constants.MainDependencyGroup
Expand All @@ -198,7 +191,7 @@ type Dependencies(dependenciesFileName: string) =
this.RootPath,
fun () -> UpdateProcess.UpdatePackage(dependenciesFileName, groupName, PackageName package, version,
{ UpdaterOptions.Default with
Common = InstallerOptions.createLegacyOptions(force, hard, withBindingRedirects)
Common = InstallerOptions.createLegacyOptions(force, hard, withBindingRedirects, createNewBindingFiles)
NoInstall = installAfter |> not }))

/// Restores all dependencies.
Expand Down
2 changes: 1 addition & 1 deletion src/Paket.Core/RemoveProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ let private remove removeFromProjects dependenciesFileName groupName (package: P
dependenciesFile,UpdateProcess.SelectiveUpdate(dependenciesFile,false,None,force)

if installAfter then
InstallProcess.Install(InstallerOptions.createLegacyOptions(force, hard, false), dependenciesFile, lockFile)
InstallProcess.Install(InstallerOptions.createLegacyOptions(force, hard, false, false), dependenciesFile, lockFile)

/// Removes a package with the option to remove it from a specified project.
let RemoveFromProject(dependenciesFileName, groupName, packageName:PackageName, force, hard, projectName, installAfter) =
Expand Down
2 changes: 1 addition & 1 deletion src/Paket.PowerShell/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ open System.Reflection
[<assembly: AssemblyDescriptionAttribute("A package dependency manager for .NET with support for NuGet packages and GitHub repositories.")>]
[<assembly: AssemblyVersionAttribute("2.0.0")>]
[<assembly: AssemblyFileVersionAttribute("2.0.0")>]
[<assembly: AssemblyInformationalVersionAttribute("2.0.0-rc004")>]
[<assembly: AssemblyInformationalVersionAttribute("2.0.0")>]
do ()

module internal AssemblyVersionInformation =
Expand Down
Loading

0 comments on commit 225c445

Please sign in to comment.