Answered Invoking the data generator from the command line

  • Friday, June 16, 2006 4:56 AM
     
     

    Do we have the ability to invoke the data generator from the command line or as a part of the deployment of the database (i.e. using the Deploy Selection command)?

    This would be useful in automated build setups where we need to perform some sort of intermediate check after a successful creation of the database on the server but before actually loading some (test) data in it.

    -Tanveer Rashid

Answers

  • Friday, June 16, 2006 7:48 PM
     
     Answered

     

    DataGenerator is also exposed as a MSBuild task.  This makes it very easy to incorporate DataGeneration into any build process.  A simple project file using the MSBuild task is:

    <Project DefaultTargets="DataGen" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <!--Import the settings-->
      <Import Project="$(MSBuildBinPath)\Microsoft.VisualStudio.TeamSystem.Data.targets" />
     
      <Target Name="DataGen">
     <DataGeneratorTask
      ConnectionString="$(ConnectionString)"
      SourceFile="$(SourceFile)"
      PurgeTablesBeforePopulate="$(PurgeTablesBeforePopulate)"
      />
      </Target>
    </Project>

    There are other options on the build task and I would expect this to be flushed out more in future releases.

All Replies

  • Friday, June 16, 2006 12:29 PM
     
     
    I am pretty sure I heard them say that you will be able to use the data generator from the command line, but I am not sure if it is in the current CTP or not.
  • Friday, June 16, 2006 1:10 PM
     
     

    In CTP3, we do not provide a tool/executable to invoke a data generation plan from the command line. However, we do provide a public API for invoking a .dgen so you can write a simple executable yourself. The call you need to make is:

    DBTest.GenerateData(
          string dataGeneratorFilePath
    ,
          string connectionString);

    The DBTest class is located in namespace Microsoft.VisualStudio.TeamSystem.Data.UnitTesting.

    Thanks!

  • Friday, June 16, 2006 7:48 PM
     
     Answered

     

    DataGenerator is also exposed as a MSBuild task.  This makes it very easy to incorporate DataGeneration into any build process.  A simple project file using the MSBuild task is:

    <Project DefaultTargets="DataGen" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <!--Import the settings-->
      <Import Project="$(MSBuildBinPath)\Microsoft.VisualStudio.TeamSystem.Data.targets" />
     
      <Target Name="DataGen">
     <DataGeneratorTask
      ConnectionString="$(ConnectionString)"
      SourceFile="$(SourceFile)"
      PurgeTablesBeforePopulate="$(PurgeTablesBeforePopulate)"
      />
      </Target>
    </Project>

    There are other options on the build task and I would expect this to be flushed out more in future releases.

  • Monday, December 01, 2008 10:11 AM
     
     
    HI,  I tried your solution and I get the following error

    "C:\SQLDATA\test.txt" (default target) (1) ->
    (DataGen target) ->
      C:\SQLDATA\test.txt(5,6): error MSB4018: The "DataGeneratorTask" task failed
    unexpectedly.\r
    C:\SQLDATA\test.txt(5,6): error MSB4018: System.NullReferenceException: Object
    reference not set to an instance of an object.\r
    C:\SQLDATA\test.txt(5,6): error MSB4018:    at Microsoft.VisualStudio.TeamSyste
    m.Data.DataGenerator.ConfigurationLoader.LoadConfiguration()\r
    C:\SQLDATA\test.txt(5,6): error MSB4018:    at Microsoft.VisualStudio.TeamSyste
    m.Data.Tasks.DataGeneratorTask.Execute()\r
    C:\SQLDATA\test.txt(5,6): error MSB4018:    at Microsoft.Build.BuildEngine.Task
    Engine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, Task
    ExecutionMode howToExecuteTask, ITask task, Boolean& taskResult)

        0 Warning(s)

    The command line I use is:
    MSBUILD text.txt

    Here is my test.txt file content:

    Project DefaultTargets="DataGen" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <!--Import the settings-->
      <Import Project="C:\Program Files\MSBuild\Microsoft\VisualStudio\v9.0\TeamData\Microsoft.VisualStudio.TeamSystem.Data.Tasks.targets" />
      <Target Name="DataGen">
         <DataGeneratorTask
              ConnectionString="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DBAdventureWorks;Data Source=CC-Acer\ACER_DEV2008"
              SourceFile="dgpManagerEmployees.dgen"
              PurgeTablesBeforePopulate="True"
          />
      </Target>
    </Project>

    Can it be related to the fact that I am using RC0 version of DBpro?

    Thanks!
    Ccote
  • Monday, December 01, 2008 8:51 PM
     
     Proposed Answer
     It looks like you need to update the .targets file in your test.txt file. Try using this instead:

        <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\TeamData\Microsoft.Data.Schema.SqlTasks.targets" />

    Let us know if you still encounter problems.
    -Genevieve Orchard (VSTS Database Edition Test Team)
    • Proposed As Answer by ccoteMVP Tuesday, December 02, 2008 12:49 PM
    •  
  • Tuesday, December 02, 2008 12:49 PM
     
     
     It works perfectly.

    Thank you!
  • Friday, September 03, 2010 10:27 PM
     
     

    Just had similar question for vs 2010 ultimate.   looks like the import has changed.

    <Project DefaultTargets="DataGen" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <!--Import the settings-->
      <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\TeamData\Microsoft.Data.Schema.Common.targets" /> 
      <Target Name="DataGen">
     <DataGeneratorTask
      ConnectionString="Data Source=.;Initial Catalog=Volatile3;Integrated Security=True;Pooling=False"
      SourceFile=".\DataTransformPlan1.dgen"
      PurgeTablesBeforePopulate="True"
      />
      </Target>
    </Project>

  • Sunday, September 05, 2010 9:52 AM
     
     

    On a similar vein....in VS2010 is it possible to pass the connection information for the Data Bound & Sequential Data Bound Generators into the dgen plan? If not I would say that this a gaping hole in this feature - I can foresee many scenarios where I might want to run the dgen plan for multiple datasets and being able to pass in connection information would enable this.

    Moreover, I'm surprised I can't specify this connection information once for the entire dgen plan and then let all Data Bound Generators use it. 

     

    -Jamie


    http://sqlblog.com/blogs/jamie_thomson/ | @jamiet | About me
    Jamie Thomson
  • Thursday, October 21, 2010 2:45 PM
     
     

    Jamie,

    Did you ever find out anything more about this?  I am currently constructing a dgen plan for a database but have two project configurations,  one for the local development machine and one for the development servers.  I basically want to change the connection string and all the data bound generator connection strings to point to different servers based on the configuration the project is building in.

    Anyway, if you got anywhere please let me know, otherwise I will keep on plugging away (maybe some sort of build time search and replace based on the target deploy connection string in the deploy manifest file).

    Thanks,

    Gareth.

  • Thursday, October 21, 2010 2:53 PM
     
     

    Jamie,

    Did you ever find out anything more about this?  I am currently constructing a dgen plan for a database but have two project configurations,  one for the local development machine and one for the development servers.  I basically want to change the connection string and all the data bound generator connection strings to point to different servers based on the configuration the project is building in.

    Anyway, if you got anywhere please let me know, otherwise I will keep on plugging away (maybe some sort of build time search and replace based on the target deploy connection string in the deploy manifest file).

    Thanks,

    Gareth.

    Gareth,

    Its not possible I'm afraid. Bad isn't it?

    If you want to complain then head here: https://connect.microsoft.com/VisualStudio/feedback/details/595747/datadude-data-generation-data-gen-ui-is-not-condusive-to-efficient-working-practices

    Here is a bevvy of whinges that I've submitted regarding Data Generation in general: https://connect.microsoft.com/VisualStudio/SearchResults.aspx?SearchQuery=data%2bbound%2bgenerator (see suggestions)

    -Jamie


    http://sqlblog.com/blogs/jamie_thomson/ | @jamiet | About me
    Jamie Thomson