Last active
October 5, 2016 19:59
-
-
Save rflechner/58d3a3ad7266563331b4bf212d2cef5c to your computer and use it in GitHub Desktop.
MSDeploy module for FAKE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open Fake | |
open MSDeployHelper | |
Target "InstallWebSite" (fun _ -> | |
let projectDir = "mydir ..." | |
let packageFullPath = buildDir @@ "msdeploy_package.zip" | |
trace "Installing website" | |
printfn "Please type username" | |
let username = Console.ReadLine() | |
printfn "Please type password" | |
let password = Console.ReadLine() | |
MSDeployInstallPackage | |
<| fun p -> | |
{ p | |
with | |
PackageFullPath=packageFullPath | |
UserName=username | |
Password=password | |
AllowUntrusted=true | |
IISAppName="test_deploy" | |
ServerMsDeployUri="https://xxx.xxx.xxx.xxx:8172/MsDeploy.axd" //default uri with your IP | |
} | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open Fake | |
open ProcessHelper | |
open System | |
open System.IO | |
module MSDeployHelper = | |
type MSDeployPackageParams = | |
{ ProjectDir:string | |
PackageFullPath:string | |
Timeout:TimeSpan } | |
static member Default = | |
{ ProjectDir=""; PackageFullPath=""; Timeout=TimeSpan.FromMinutes 2. } | |
type MSDeployInstallParams = | |
{ IISAppName:string | |
PackageFullPath:string | |
ServerMsDeployUri:string | |
UserName:string | |
Password:string | |
Timeout:TimeSpan | |
AllowUntrusted:bool } | |
static member Default = | |
{ IISAppName=""; PackageFullPath=""; Timeout=(TimeSpan.FromMinutes 2.); | |
ServerMsDeployUri="https://localhost:8172/MsDeploy.axd"; UserName=""; | |
Password=""; AllowUntrusted=false } | |
let ExecMSDeploy timeout args = | |
let exe = "msdeploy.exe" | |
let result = | |
ExecProcess | |
(fun info -> | |
info.FileName <- exe | |
info.Arguments <- args) timeout | |
if result <> 0 | |
then failwithf "Process '%s %s' failed with exit code '%d'" exe args result | |
let MSDeployCreatePackage (f: MSDeployPackageParams -> MSDeployPackageParams) = | |
let p = f MSDeployPackageParams.Default | |
let args = sprintf """-verb:sync -source:iisApp="%s" -dest:package="%s" """ p.ProjectDir p.PackageFullPath | |
ExecMSDeploy p.Timeout args | |
let MSDeployInstallPackage (f: MSDeployInstallParams -> MSDeployInstallParams) = | |
let p = f MSDeployInstallParams.Default | |
let args = | |
sprintf | |
"""-verb:sync -source:package="%s" -dest:iisApp="%s",ComputerName="%s",UserName='%s',Password='%s',AuthType='Basic' """ | |
p.PackageFullPath p.IISAppName p.ServerMsDeployUri p.UserName p.Password | |
match p.AllowUntrusted with | |
| true -> args + " -allowUntrusted" | |
| false -> args | |
|> ExecMSDeploy p.Timeout |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment