Created
January 28, 2016 20:38
-
-
Save anonymous/e04333e0aa5173a3b090 to your computer and use it in GitHub Desktop.
Build Target and Web.config file transformations
This file contains 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
Target "Build" (fun _ -> | |
!! "ContractLookup.sln" | |
|> MSBuild buildDir "Build" [ | |
"Optimize", "True" | |
"DebugSymbols", "True" | |
"Configuration", "Debug" | |
"Platform", "Any CPU" | |
] | |
|> Log "Build-Output: " | |
let fileMap = new WebConfigurationFileMap() | |
fileMap.VirtualDirectories.Add("/config", new VirtualDirectoryMapping(webConfigDestDir, true)) | |
fileMap.VirtualDirectories.Add("/", new VirtualDirectoryMapping(webConfigDestDir, true, "web.config")) | |
!! (srcWebDir @@ "\web.*.config") | |
|> Seq.iter (fun file -> | |
let webConfig = (srcWebDir @@ "Web.Config") | |
let transformResult = | |
ExecProcess (fun info -> | |
{info with | |
FileName = (DeployScriptsDir @@ "/ctt.exe") | |
WorkingDirectory = buildDir | |
Arguments = sprintf "s:'%s' d:'%s/web.config.test' t:'%s' i e:utf8" webConfig webConfigDestDir file} (TimeSpan.FromMinutes 5.0)) | |
if transformResult <> 0 then failwithf "Config file could not be transformed" | |
try | |
WebConfigurationManager.OpenWebConfiguration fileMap destConfig | |
with | |
| :? System.Exception -> failwithf "Config file could not be validated") | |
|> Log "Transform-Output: " | |
CopyDir (buildDir @@ "_PublishedWebsites/ContractLookup.Web") "ContractLookup" (fun f -> f.EndsWith ".config") | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment