Include file in outdir, but not in Msi

Topics: Server Deployment
May 17, 2013 at 9:17 PM
I have a need to copy a batch file from the Deployment folder to the outdir while building the MSI installer. Normally I'd just set Copy to Output folder to true in VS, but since the deployment framework isn't a project template, I don't have that option.

I tried creating a postbuild action that just copies the file, but that doesn't seem to be executed. Here's how I set that up:
  <ItemGroup>
    <PostBuildEvent Include="MsiDeploy.bat">
      <Command>xcopy ..\..\MsiDeploy.bat .</Command>
    </PostBuildEvent>
  </ItemGroup>
But even after creating the MSI all I get are the ProjectName-Version.msi and Install-ProjectName-Version.bat files. What am I missing?
Coordinator
May 19, 2013 at 5:18 AM
Use this:
  <Target Name="CustomPostInstaller">
    <CreateItem Include="..\..\MsiDeploy.bat">
      <Output TaskParameter="Include" ItemName="CopyPostInstaller" />
    </CreateItem>

    <Copy DestinationFolder="$(TargetDir)" SourceFiles="@(CopyPostInstaller)"/>
  </Target>
Thanks,
Tom
May 20, 2013 at 4:14 PM
Thanks, but that doesn't seem to be working for me.

This goes in the btdfproj file, in the Project element, right? The CreateItem node is underlined with the message "Target element has invalid child element CreateItem. List of possible elements expected: Task, PropertyGroup, ItemGroup, OnError".

When I build an MSI, it works as normal, but the MsiDeploy.bat doesn't show up in the \bin\release folder.
Coordinator
May 21, 2013 at 6:35 AM
Yes. Then I would assume that the path to MsiDeploy.bat is incorrect. The path is relative to the Deployment project folder. Try a full explicit path if you can't get a relative path to work, just to see if you can get the file copied.

Thanks,
Tom
May 22, 2013 at 4:12 AM
I updated to use an absolute path but that didn't work either. I even tried using msbuild and pointed it to the CustomPostInstaller target to determine if it maybe it just wasn't running that target, but again nothing. I also don't see any errors or warnings about not finding the MsiDeploy.bat file, so I don't think it's the path.

One other possibility to get the file I need would be to customize the Install-ProjectName-Version.bat file. Is that possible?

Thanks for your help.
Coordinator
May 22, 2013 at 6:33 AM
On BizTalk 2010 and newer you can use:
  <Target Name="CopyFilesToTargetDir" AfterTargets="Installer">
    <CreateItem Include="..\..\MsiDeploy.bat">
      <Output TaskParameter="Include" ItemName="CopyPostInstaller" />
    </CreateItem>

    <Message Text="CopyPostInstaller = '@(CopyPostInstaller)'" />
    <Message Text="TargetDir = '$(TargetDir)'" />

    <Copy DestinationFolder="$(TargetDir)" SourceFiles="@(CopyPostInstaller)"/>
  </Target>
See if the Message tasks write something out and whether the values are valid. It is not easily possible to modify the .bat file contents on initial creation.

Thanks,
Tom
May 23, 2013 at 3:21 AM
This worked, once I got the correct path for the file I wanted to copy.

Thanks.