Implementing a VS2005 Macro for automating transformation and exporting of outputs from DSL templates

For those who are working with Domain Specific Languages Designers, there is on recurring two step task that should be automated: Tranforming and exporting the various templates ouputs to the proper locations in our working project.

To do so we can implement a simple macro that does the job for us.

Basically we need to create a method that call one command that transform all the templates in the current project:


and then call a set of commands to copy the templates ouput to the desired directory. Here is a sample of what I said:

DTE.ExecuteCommand(“Tools.Shell”, “cmd /c copy /Y “”” + GetOriginPath() + “BusinessEntities.cs” + “””  “”” + BusinessEntitiesDestinationFile + “”””)

where GetOriginPath()  is defined as:

Private Function GetOriginPath() As String
      Dim lastIndex As Integer = InStrRev(DTE.Solution.FullName, “\”)
      Return Left(DTE.Solution.FullName, lastIndex) & “GeneratedCode\”
End Function

To learn how to assign a macro to a toolbar button check out this site.

To learn how to Edit and Programmatically Create Macros check out this site.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: