Skip to content
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

Add Paket helper to push specific files #1665

Merged
merged 4 commits into from
Sep 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 28 additions & 16 deletions src/app/Fake.DotNet.Paket/Paket.fs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ type PaketPackParams =
TemplateFile : string
ExcludedTemplates : string list
WorkingDir : string
OutputPath : string
ProjectUrl : string
OutputPath : string
ProjectUrl : string
Symbols : bool
IncludeReferencedProjects : bool
MinimumFromLockFile : bool
Expand All @@ -45,7 +45,7 @@ let PaketPackDefaults() : PaketPackParams =
ProjectUrl = null
ExcludedTemplates = []
WorkingDir = "."
OutputPath = "./temp"
OutputPath = "./temp"
Symbols = false
IncludeReferencedProjects = false
MinimumFromLockFile = false
Expand Down Expand Up @@ -82,7 +82,7 @@ type PaketRestoreParams =
ReferenceFiles: string list }

/// Paket restore default parameters
let PaketRestoreDefaults() : PaketRestoreParams =
let PaketRestoreDefaults() : PaketRestoreParams =
{ ToolPath = (Tools.findToolFolderInSubPath "paket.exe" (Directory.GetCurrentDirectory() @@ ".paket")) @@ "paket.exe"
TimeOut = System.TimeSpan.MaxValue
WorkingDir = "."
Expand Down Expand Up @@ -118,9 +118,9 @@ let Pack setParams =
let projectUrl = if String.IsNullOrWhiteSpace parameters.ProjectUrl then "" else " --project-url " + Process.toParam parameters.ProjectUrl

let packResult =
let cmdArgs =
sprintf "%s%s%s%s%s%s%s%s%s%s%s%s%s"
version specificVersions releaseNotes buildConfig buildPlatform templateFile lockDependencies excludedTemplates
let cmdArgs =
sprintf "%s%s%s%s%s%s%s%s%s%s%s%s%s"
version specificVersions releaseNotes buildConfig buildPlatform templateFile lockDependencies excludedTemplates
symbols includeReferencedProjects minimumFromLockFile pinProjectReferences projectUrl
Process.ExecProcess
(fun info ->
Expand All @@ -130,14 +130,15 @@ let Pack setParams =

if packResult <> 0 then failwithf "Error during packing %s." parameters.WorkingDir

/// Pushes all NuGet packages in the working dir to the server by using Paket push.
/// Pushes the given NuGet packages to the server by using Paket push.
/// ## Parameters
///
/// - `setParams` - Function used to manipulate the default parameters.
let Push setParams =
/// - `files` - The files to be pushed to the server.
let PushFiles setParams files =
let parameters : PaketPushParams = PaketPushDefaults() |> setParams

let packages = !! (parameters.WorkingDir @@ "/**/*.nupkg") |> Seq.toList
let packages = Seq.toList files
let url = if String.IsNullOrWhiteSpace parameters.PublishUrl then "" else " --url " + Process.toParam parameters.PublishUrl
let endpoint = if String.IsNullOrWhiteSpace parameters.EndPoint then "" else " --endpoint " + Process.toParam parameters.EndPoint
let key = if String.IsNullOrWhiteSpace parameters.ApiKey then "" else " --apikey " + Process.toParam parameters.ApiKey
Expand Down Expand Up @@ -165,6 +166,7 @@ let Push setParams =
let pushResult =
Process.ExecProcess (fun info ->
info.FileName <- parameters.ToolPath
info.WorkingDirectory <- parameters.WorkingDir
info.Arguments <- sprintf "push %s%s%s%s" url endpoint key (Process.toParam package)) parameters.TimeOut
if pushResult <> 0 then failwithf "Error during pushing %s." package })

Expand All @@ -181,6 +183,16 @@ let Push setParams =
info.Arguments <- sprintf "push %s%s%s%s" url endpoint key (Process.toParam package)) parameters.TimeOut
if pushResult <> 0 then failwithf "Error during pushing %s." package

/// Pushes all NuGet packages in the working dir to the server by using Paket push.
/// ## Parameters
///
/// - `setParams` - Function used to manipulate the default parameters.
let Push setParams =
let parameters : PaketPushParams = PaketPushDefaults() |> setParams
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unused?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just remove this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used to get the WorkingDir for the globbing pattern below.

I can change the functions so we don't evaluate setParams twice.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wow apparently I'm blind, thanks ;)

So you suggest to (fun _ -> parameters), correct? Yes we can do that.


!! (parameters.WorkingDir @@ "/**/*.nupkg")
|> PushFiles (fun _ -> parameters)

/// Returns the dependencies from specified paket.references file
let GetDependenciesForReferencesFile (referencesFile:string) =
let getReferenceFilePackages =
Expand All @@ -203,7 +215,7 @@ let GetDependenciesForReferencesFile (referencesFile:string) =
let fi = FileInfo(dir </> "paket.lock")
if fi.Exists then fi.FullName else find fi.Directory.Parent.FullName
find <| FileInfo(referencesFile).Directory.FullName

let breakInParts (line : string) = match Regex.Match(line,"^[ ]{4}([^ ].+) \((.+)\)") with
| m when m.Success && m.Groups.Count = 3 -> Some (m.Groups.[1].Value, m.Groups.[2].Value)
| _ -> None
Expand All @@ -221,19 +233,19 @@ let GetDependenciesForReferencesFile (referencesFile:string) =
/// ## Parameters
///
/// - `setParams` - Function used to manipulate the default parameters.
let Restore setParams =
let Restore setParams =
let parameters : PaketRestoreParams = PaketRestoreDefaults() |> setParams
let forceRestore = if parameters.ForceDownloadOfPackages then " --force " else ""
let onlyReferenced = if parameters.OnlyReferencedFiles then " --only-referenced " else ""
let groupArg = if parameters.Group <> "" then (sprintf " --group %s " parameters.Group) else ""
let referencedFiles =
let referencedFiles =
if parameters.ReferenceFiles |> List.isEmpty |> not
then (sprintf " --references-files %s " (System.String.Join(" ", parameters.ReferenceFiles)))
else ""

use __ = Trace.traceTask "PaketRestore" parameters.WorkingDir

let restoreResult =
use __ = Trace.traceTask "PaketRestore" parameters.WorkingDir

let restoreResult =
Process.ExecProcess (fun info ->
info.FileName <- parameters.ToolPath
info.WorkingDirectory <- parameters.WorkingDir
Expand Down
19 changes: 16 additions & 3 deletions src/app/FakeLib/PaketHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,16 @@ let Pack setParams =

if packResult <> 0 then failwithf "Error during packing %s." parameters.WorkingDir

/// Pushes all NuGet packages in the working dir to the server by using Paket push.
/// Pushes the given NuGet packages to the server by using Paket push.
/// ## Parameters
///
/// - `setParams` - Function used to manipulate the default parameters.
/// - `files` - The files to be pushed to the server.
[<System.Obsolete "use Fake.DotNet.Paket instead">]
let Push setParams =
let PushFiles setParams files =
let parameters : PaketPushParams = PaketPushDefaults() |> setParams

let packages = !! (parameters.WorkingDir @@ "/**/*.nupkg") |> Seq.toList
let packages = Seq.toList files
let url = if String.IsNullOrWhiteSpace parameters.PublishUrl then "" else " url " + toParam parameters.PublishUrl
let endpoint = if String.IsNullOrWhiteSpace parameters.EndPoint then "" else " endpoint " + toParam parameters.EndPoint
let key = if String.IsNullOrWhiteSpace parameters.ApiKey then "" else " apikey " + toParam parameters.ApiKey
Expand Down Expand Up @@ -172,6 +173,7 @@ let Push setParams =
let pushResult =
ExecProcess (fun info ->
info.FileName <- parameters.ToolPath
info.WorkingDirectory <- parameters.WorkingDir
info.Arguments <- sprintf "push %s%s%s file %s" url endpoint key (toParam package)) parameters.TimeOut
if pushResult <> 0 then failwithf "Error during pushing %s." package })

Expand All @@ -188,6 +190,17 @@ let Push setParams =
info.Arguments <- sprintf "push %s%s%s file %s" url endpoint key (toParam package)) parameters.TimeOut
if pushResult <> 0 then failwithf "Error during pushing %s." package

/// Pushes all NuGet packages in the working dir to the server by using Paket push.
/// ## Parameters
///
/// - `setParams` - Function used to manipulate the default parameters.
[<System.Obsolete "use Fake.DotNet.Paket instead">]
let Push setParams =
let parameters : PaketPushParams = PaketPushDefaults() |> setParams

!! (parameters.WorkingDir @@ "/**/*.nupkg")
|> PushFiles (fun _ -> parameters)

/// Returns the dependencies from specified paket.references file
[<System.Obsolete "use Fake.DotNet.Paket instead">]
let GetDependenciesForReferencesFile (referencesFile:string) =
Expand Down