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

Added dotnet publish command to DotNetCLIHelper #1387

Merged
merged 1 commit into from
Oct 6, 2016
Merged
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
85 changes: 85 additions & 0 deletions src/app/FakeLib/DotNetCLIHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,91 @@ let Pack (setPackParams: PackParams -> PackParams) projects =
finally
traceEndTask "DotNet.Pack" ""

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

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

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

/// The build configuration.
Configuration : string

/// Allows to publish to a specific framework
Framework : string

/// Allows to test a specific runtime
Runtime : string

/// Optional version suffix.
VersionSuffix: string

/// Optional outputh path
Output : string

/// Additional Args
AdditionalArgs : string list
}

let private DefaultPublishParams : PublishParams = {
ToolPath = commandName
WorkingDir = Environment.CurrentDirectory
Configuration = "Release"
TimeOut = TimeSpan.FromMinutes 30.
Framework = ""
Runtime = ""
VersionSuffix = ""
Output = ""
AdditionalArgs = []
}

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

try
for project in projects do
let parameters = setPublishParams DefaultPublishParams
let args =
new StringBuilder()
|> append "publish"
|> append project
|> appendIfTrueWithoutQuotes (isNotNullOrEmpty parameters.Configuration) (sprintf "--configuration %s" parameters.Configuration)
|> appendIfTrueWithoutQuotes (isNotNullOrEmpty parameters.Framework) (sprintf "--framework %s" parameters.Framework)
|> appendIfTrueWithoutQuotes (isNotNullOrEmpty parameters.Runtime) (sprintf "--runtime %s" parameters.Runtime)
|> appendIfTrueWithoutQuotes (isNotNullOrEmpty parameters.Output) (sprintf "--output %s" parameters.Output)
|> appendIfTrueWithoutQuotes (isNotNullOrEmpty parameters.VersionSuffix) (sprintf "--version-suffix %s" parameters.VersionSuffix)
|> fun sb ->
parameters.AdditionalArgs
|> List.fold (fun sb arg -> appendWithoutQuotes arg sb) sb
|> toText

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



/// Sets version in project.json
let SetVersionInProjectJson (version:string) fileName =
traceStartTask "DotNet.SetVersion" fileName
Expand Down