질문하기질문하기
 

답변됨Invoking the data generator from the command line

  • 2006년 6월 16일 금요일 오전 4:56Tanveer Rashid 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     

    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

답변

  • 2006년 6월 16일 금요일 오후 7:48Jamie Laflen MSFTMSFT사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨

     

    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.

모든 응답

  • 2006년 6월 16일 금요일 오후 12:29Mickey GMVP사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    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.
  • 2006년 6월 16일 금요일 오후 1:10Jon Liperi - MSFTMSFT사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     

    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!

  • 2006년 6월 16일 금요일 오후 7:48Jamie Laflen MSFTMSFT사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨

     

    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.

  • 2008년 12월 1일 월요일 오전 10:11ccoteMVP사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    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
  • 2008년 12월 1일 월요일 오후 8:51Genevieve OrchardMSFT사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     제안된 답변
     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)
    • 답변으로 제안됨ccoteMVP2008년 12월 2일 화요일 오후 12:49
    •  
  • 2008년 12월 2일 화요일 오후 12:49ccoteMVP사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
     It works perfectly.

    Thank you!