Is is possible to publish a website instead of building it as part of a FAKE script?
I do not have experience with this myself, but it looks like there are two ways to run the web deploymnent process by hand. One (looks older) is to invoke MSBuild with a special target (as described here) and another option (looks more modern) is to use the MSDeploy tool (which has a command line interface).
Both of these should be easy to call from FAKE script. Here is a sample that calls a command line tool:
Target "Deploy" (fun _ ->
let result =
ExecProcess (fun info ->
info.FileName <- "file-to-run.exe"
info.Arguments <- "--parameters:go-here"
) (System.TimeSpan.FromMinutes 1.0)
if result <> 0 then failwith "Operation failed or timed out"
)
Calling an MSBuild script should look something like this:
Target "BuildTest" (fun _ ->
"Blah.csproj"
|> MSBuildRelease "" "ResolveReferences;_CopyWebApplication"
|> ignore
)
As I said, I have not tested this (so it might be completely wrong), but hopefully it can point you into a useful direction, before some web deployment or FAKE experts come to SO!
Here is one way to do it. (Actually it doesn't exactly answer the question, because publishing is not performed without building.)
Here is a piece of code from build.fsx
illustrating this approach:
let testProjects = @"src/**/*Tests.csproj"
let requestedTarget = getBuildParamOrDefault "target" ""
let shouldDeploy =
match requestedTarget with
| "Test" | "AcceptanceTest" | "Deploy" -> true
| _ -> false
// *** Define Targets ***
Target "BuildApp" (fun _ ->
let properties =
if shouldDeploy
then [ ("DeployOnBuild", "true"); ("PublishProfile","LocalTestServer.pubxml") ]
else []
!! @"src/**/*.csproj"
-- testProjects
|> MSBuildReleaseExt null properties "Build"
|> Log "Build-Output: "
)
// Other targets and dependencies omitted.
With this code in place, when one of the targets
"Test", "AcceptanceTest", "Deploy" is run, the website
gets published according to the publish profile defined in LocalTestServer.pubxml
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With