Skip to content

Commit

Permalink
Merge pull request #1313 from fsharp/pack
Browse files Browse the repository at this point in the history
New dotnet pack helper
  • Loading branch information
forki authored Jul 21, 2016
2 parents c1b9e58 + 34bc37c commit 39ccec5
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 3 deletions.
3 changes: 2 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#### 4.33.1 - 21.07.2016
#### 4.33.2 - 21.07.2016
* DotNet version support - https://github.com/fsharp/FAKE/pull/1310
* DotNet test support - https://github.com/fsharp/FAKE/pull/1311
* DotNet pack support - https://github.com/fsharp/FAKE/pull/1312

#### 4.33.0 - 21.07.2016
* DotNet restore support - https://github.com/fsharp/FAKE/pull/1309
Expand Down
61 changes: 59 additions & 2 deletions src/app/FakeLib/DotNetCLIHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ let Test (setTestParams: TestParams -> TestParams) projects =
new StringBuilder()
|> append "test"
|> append project
|> appendIfNotNullOrEmpty parameters.Configuration "--configuration"
|> appendIfNotNullOrEmpty parameters.Configuration "--configuration "
|> toText

if 0 <> ExecProcess (fun info ->
Expand All @@ -134,4 +134,61 @@ let Test (setTestParams: TestParams -> TestParams) projects =
then
failwithf "Test failed on %s" args
finally
traceEndTask "DotNet.Test" ""
traceEndTask "DotNet.Test" ""


/// DotNet pack parameters
type PackParams = {
/// ToolPath - usually just "dotnet"
ToolPath: string

/// Working directory (optional).
WorkingDir: string

/// A timeout for the command.
TimeOut: TimeSpan

/// The build configuration.
Configuration : string
}

let private DefaultPackParams : PackParams = {
ToolPath = commandName
WorkingDir = Environment.CurrentDirectory
Configuration = "Release"
TimeOut = TimeSpan.FromMinutes 30.
}

/// Runs the dotnet "pack" command.
/// ## Parameters
///
/// - `setPackParams` - Function used to overwrite the pack default parameters.
///
/// ## Sample
///
/// !! "src/test/project.json"
/// |> DotNet.Pack
/// (fun p ->
/// { p with
/// Configuration = "Release" })
let Pack (setPackParams: PackParams -> PackParams) projects =
traceStartTask "DotNet.Pack" ""

try
for project in projects do
let parameters = setPackParams DefaultPackParams
let args =
new StringBuilder()
|> append "pack"
|> append project
|> appendIfNotNullOrEmpty parameters.Configuration "--configuration "
|> toText

if 0 <> ExecProcess (fun info ->
info.FileName <- parameters.ToolPath
info.WorkingDirectory <- parameters.WorkingDir
info.Arguments <- args) parameters.TimeOut
then
failwithf "Pack failed on %s" args
finally
traceEndTask "DotNet.pack" ""

0 comments on commit 39ccec5

Please sign in to comment.