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

Adding DotNet restore support #1309

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
59 changes: 59 additions & 0 deletions src/app/FakeLib/DotNetCLIHelper.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/// Contains a task which can be used to run [DotCover](http://www.jetbrains.com/dotcover/) on .NET assemblies.
module Fake.DotNet

open Fake
open System
open System.Text

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

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

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

/// Whether to use the NuGet cache.
NoCache : bool
}

let private DefaultRestoreParams : RestoreParams = {
ToolPath = "dotnet"
WorkingDir = Environment.CurrentDirectory
NoCache = false
TimeOut = TimeSpan.FromMinutes 30.
}

/// Runs the dotnet "restore" command.
/// ## Parameters
///
/// - `setRestoreParams` - Function used to overwrite the restore default parameters.
///
/// ## Sample
///
/// DotNet.Restore
/// (fun p ->
/// { p with
/// NoCache = true })
let Restore (setRestoreParams: RestoreParams -> RestoreParams) =
traceStartTask "DotNetRestore" ""

try
let parameters = setRestoreParams DefaultRestoreParams
let args =
new StringBuilder()
|> append "restore"
|> appendIfTrue parameters.NoCache "--no-cache"
|> toText

if 0 <> ExecProcess (fun info ->
info.FileName <- parameters.ToolPath
info.WorkingDirectory <- parameters.WorkingDir
info.Arguments <- args) parameters.TimeOut
then
failwithf "Restore failed on %s" args
finally
traceEndTask "DotNetRestore" ""
1 change: 1 addition & 0 deletions src/app/FakeLib/FakeLib.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
<Compile Include="NuGet\Install.fs" />
<Compile Include="NuGet\NugetVersion.fs" />
<Compile Include="TestFlightHelper.fs" />
<Compile Include="DotNetCLIHelper.fs" />
<Compile Include="DotCover.fs" />
<Compile Include="PaketHelper.fs" />
<Compile Include="PaketTemplateHelper.fs" />
Expand Down