Yesterday we did a final touch to our build script (by we I mean "I talked about it for five minutes, Christer did it").
We wanted to create a bat-file that installs our database in a certain version to a certain environment. So - the information we need to be able to do that is only know at runtime in the build-script.
From what I could remember there was a MSBuild community task for this - this was my input.
Christer then found the task WriteLinesToFile and wrote the following target that creates a bat-file as above.
<ItemGroup>
<CmdLine Include = "@ECHO OFF"/>
<CmdLine Include = "ECHO About to install version $(BuildVersion) on environment $(DeployEnv)"/>
<CmdLine Include = "SET /p passw=Enter DB password for $(DeployEnv): " />
<CmdLine Include = "CALL main.bat $(DeployEnv) . $(BuildVersion) %passw%"/>
<CmdLine Include = "PAUSE"/>
</ItemGroup>
<WriteLinesToFile File="$(PublishWebSitePath)\Database\Installera_$(DeployEnv)_version_$(BuildVersion).bat"
Lines="@(CmdLine)"
Overwrite="true"/>
This version will wait for a password from the user so that the password didn't need to be hard coded into the script.
Nice Christer - Nice!
If you liked this post ... here's more for you:
Published by
on Last updated