diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index a786b6bc357..a5c9f20e178 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -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 diff --git a/src/app/FakeLib/DotNetCLIHelper.fs b/src/app/FakeLib/DotNetCLIHelper.fs index 09ab0c47ea3..a4426f68a32 100644 --- a/src/app/FakeLib/DotNetCLIHelper.fs +++ b/src/app/FakeLib/DotNetCLIHelper.fs @@ -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 -> @@ -134,4 +134,61 @@ let Test (setTestParams: TestParams -> TestParams) projects = then failwithf "Test failed on %s" args finally - traceEndTask "DotNet.Test" "" \ No newline at end of file + 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" "" \ No newline at end of file