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

Allow to run arbitrary dotnet CLI commands #1322

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,9 +1,10 @@
#### 4.34.3 - 21.07.2016
#### 4.34.4 - 21.07.2016
* DotNet version support - https://github.com/fsharp/FAKE/pull/1310
* DotNet test support - https://github.com/fsharp/FAKE/pull/1311
* DotNet build support - https://github.com/fsharp/FAKE/pull/1318
* DotNet pack support - https://github.com/fsharp/FAKE/pull/1313
* Allows to set version in project.json
* Allow to run arbitrary dotnet CLI commands
* DotNet restore support - https://github.com/fsharp/FAKE/pull/1309
* BUGFIX: Update DACPAC module - https://github.com/fsharp/FAKE/pull/1307

Expand Down
46 changes: 46 additions & 0 deletions src/app/FakeLib/DotNetCLIHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,52 @@ let isInstalled() =

processResult.OK

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

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

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

let private DefaultCommandParams : CommandParams = {
ToolPath = commandName
WorkingDir = Environment.CurrentDirectory
TimeOut = TimeSpan.FromMinutes 30.
}

/// Runs a dotnet command.
/// ## Parameters
///
/// - `setCommandParams` - Function used to overwrite the default parameters.
/// - `args` - command and additional arguments.
///
/// ## Sample

Choose a reason for hiding this comment

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

Wrong sample

Copy link
Member Author

Choose a reason for hiding this comment

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

wouspi. thx

///
/// !! "src/test/project.json"
/// |> DotNet.Pack
/// (fun p ->
/// { p with
/// Configuration = "Release" })
let RunCommand (setCommandParams: CommandParams -> CommandParams) args =
traceStartTask "DotNet" ""

try
let parameters = setCommandParams DefaultCommandParams

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

/// DotNet restore parameters
type RestoreParams = {
/// ToolPath - usually just "dotnet"
Expand Down