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

New dotnet pack helper #1313

Merged
merged 1 commit into from
Jul 21, 2016
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
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"

Choose a reason for hiding this comment

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

why src/test/project.json? pack work on the directory, like all dotnet commands, not on the file

Copy link
Member Author

Choose a reason for hiding this comment

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

image

/// |> 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" ""