views:

328

answers:

1

I am trying to have a PostBuildEvent in my SSIS project. This is my original .DTProj file from a test project with one test package.

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
  <ProductVersion>10.0.2531.0</ProductVersion>
  <SchemaVersion>9.0.1.0</SchemaVersion>
  <State>$base64$PFNvdXnRyb2xJbmZvPg==</State>
  <Database>
    <Name>PreBeforeDeployTest.database</Name>
    <FullPath>PreBeforeDeployTest.database</FullPath>
  </Database>
  <Cubes />
  <Dimensions />
  <DataSources />
  <DataSourceViews />
  <MiningModels />
  <Roles />
  <Miscellaneous />
  <Configurations>
    <Configuration>
      <Name>Development</Name>
      <Options>
        <OutputPath>bin</OutputPath>
        <ConnectionMappings />
        <ConnectionProviderMappings />
        <ConnectionSecurityMappings />
        <DatabaseStorageLocations />
      </Options>
    </Configuration>
  </Configurations>
  <DTSPackages>
    <DtsPackage FormatVersion="3">
      <Name>TestPackage.dtsx</Name>
      <FullPath>TestPackage.dtsx</FullPath>
      <References />
    </DtsPackage>
  </DTSPackages>
</Project>

I have tried inserting <PostBuildEvent> and it looks like this

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
  <PropertyGroup>
    <PostBuildEvent>copy "$(TargetDir)TestPackage.dtsx" "C:\"</PostBuildEvent> 
  </PropertyGroup>
  <ProductVersion>10.0.2531.0</ProductVersion>
  <SchemaVersion>9.0.1.0</SchemaVersion>
  <State>$base64$PFNvdXnRyb2xJbmZvPg==</State>
  <Database>
    <Name>PreBeforeDeployTest.database</Name>
    <FullPath>PreBeforeDeployTest.database</FullPath>
  </Database>
  <Cubes />
  <Dimensions />
  <DataSources />
  <DataSourceViews />
  <MiningModels />
  <Roles />
  <Miscellaneous />
  <Configurations>
    <Configuration>
      <Name>Development</Name>
      <Options>
        <OutputPath>bin</OutputPath>
        <ConnectionMappings />
        <ConnectionProviderMappings />
        <ConnectionSecurityMappings />
        <DatabaseStorageLocations />
      </Options>
    </Configuration>
  </Configurations>
  <DTSPackages>
    <DtsPackage FormatVersion="3">
      <Name>TestPackage.dtsx</Name>
      <FullPath>TestPackage.dtsx</FullPath>
      <References />
    </DtsPackage>
  </DTSPackages>
</Project>

The PostBuildEvent does not fire at all. What am I doing wrong here?

A: 

Who told you .dtproj supports <PostBuildEvent>? <PostBuildEvent> is supported by MSBUILD-based projects, but .dtproj has completely different schema, and simply does not know about PropertyGroup or PostBuildEvent tags.

If you just want to copy .dtsx files to c:\, as in this sample - you can change the OutputPath to c:\, and .dtproj will copy the .dtsx files (and configs) to c:\ instead of bin\ directory it used by default.

If you need more general solution, I would add some other project (that does support <PostBuildEvent>) to the solution, and define custom commands there. Then build the whole solution, instead of building just .dtproj project.

Michael
@Michael: Can you point me to a sample where I can learn this? I am not able to reproduce the copy behaviour in my environment.
Raj More