This project has moved and is read-only. For the latest updates, please go here.

Running scripts before deployment

Topics: General Questions, Getting Started/Beginner, Server Deployment
Jan 6, 2015 at 8:59 AM
Edited Jan 7, 2015 at 1:44 AM
Hi All,

I have a scenario that requires me to run a script before my assemblies are gac-ed.

How should i go about doing this?

I tried packaging the script with the msi and Execute command with:

When i run the MSI, the biztalk deployment part cant find the .bat file (exited with code:3)
    <Exec Command="..\Deployment\ExternalDLL\sn.bat" ContinueOnError="True" />
    <Exec Command="$(RedistDir)\ExternalDLL\sn.bat" ContinueOnError="True" />
Is there a Propertiy name for current installed directory? or a better way of doing this?

Also, I have a project with maps and orchestration(schemas in another project), what ArtifactName should it have?

Jan 7, 2015 at 6:06 AM
When the deployment executes, the current directory is the one holding the .btdfproj.

CustomRedist is for packaging files into the MSI. You can add a Copy task in CustomRedist to create a folder in $(RedistDir) and copy your script files into it. That executes when you run the Build Server Deploy MSI task. Some of the sample applications package test files into the MSI that way. To keep things simple, ensure that that directory exists at the same location relative to the Deployment project folder in your solution source tree and in $(RedistDir) (under obj\Debug or obj\Release).

At runtime, the Deployment project folder is then the starting point for your relative path.

A project that contains both maps and orchestrations can go into an Orchestrations ItemGroup.

Jan 7, 2015 at 7:07 AM
Edited Jan 7, 2015 at 7:21 AM
Hi Tom,
Thanks for the reply.

First off, its awesome that you manage to keep this project going and documented alone(mostly?). :thumbs:

As you said, i am using copy to package the batch files into the MSI
<Target Name="CustomRedist">
    <Copy SourceFiles="..\Deployment\ExternalDLL\sn_x32.exe" DestinationFolder="$(RedistDir)\ExternalAssemblies" />
    <Copy SourceFiles="..\Deployment\ExternalDLL\sn_x64.exe" DestinationFolder="$(RedistDir)\ExternalAssemblies" />
    <Copy SourceFiles="..\Deployment\ExternalDLL\sn.bat" DestinationFolder="$(RedistDir)\ExternalAssemblies" />
    <Copy SourceFiles="..\bin\Deployment\sn_x32.exe" DestinationFolder="$(RedistDir)" />
    <Copy SourceFiles="..\bin\Deployment\sn_x64.exe" DestinationFolder="$(RedistDir)" />
    <Copy SourceFiles="..\bin\Deployment\sn.bat" DestinationFolder="$(RedistDir)" />
To run it I use Exec Command
  <Target Name="CustomDeployTarget">
    <Exec Command="\ExternalAssemblies\sn.bat" ContinueOnError="True" />
    <Exec Command="\sn.bat" ContinueOnError="True" />
But during the deployment stage im getting
"D:\Program Files (x86)\BizTalk for BizTalk\1.0\Deployment\Deployment.btdfproj"
 (Deploy target) (1) ->
(CustomDeployTarget target) ->
  MSBUILD : warning MSB3073: The command "\ExternalAssemblies\sn.bat" exited with code 3.
  MSBUILD : warning MSB3073: The command "\sn.bat" exited with code 9009.
Im guessing code 3 is folder/file not found.
9009 is command not found

I also tried
<Exec Command="$(InstallDir)\sn.bat" ContinueOnError="True" />
<Exec Command="sn.bat" ContinueOnError="True" />
You probably guessed what those scripts are for by now..
I notice btdf is using x32 version of gacutil, but just to be safe...
Jan 8, 2015 at 5:02 AM
Edited Nov 27, 2017 at 9:18 AM
Thanks, I do keep this going alone, usually late at night...

Based on your copy steps for the MSI, it looks like you'll have \Program Files\YourApp\Deployment and \Program Files\YourApp\ExternalAssemblies when the MSI is installed. As I mentioned, the current working directory is the Deployment folder. Assuming those paths, to reach ExternalAssemblies is ..\ExternalAssemblies.
  <Target Name="CustomDeployTarget">
    <Exec Command="..\ExternalAssemblies\sn.bat" WorkingDirectory="..\ExternalAssemblies" ContinueOnError="True" />
Marked as answer by nfree25 on 1/8/2015 at 7:21 PM
Jan 8, 2015 at 6:07 AM
Edited Jan 9, 2015 at 3:22 AM
I dont know how I missed trying "..\" ...
Now I need to figure out how to work powershell or a batch file to silently install it.

Thanks so much.

I guess its good that you have a hobby..? Haha
Its great that you can find the motivation to keep working on it.