views:

17

answers:

1

I'm working on a C# project that has a post-build event command line that looks like this:

for /R "$(ProjectDir)TestData\GoldFiles" %%f in ("*.csv") DO 
    @xcopy "%%f" "R:\Root\$(TargetName)\1.0\TestData\GoldFiles\" /Y

This is my first exposure to Visual Studio Macros. I can understand this well enough to know what it's doing. Now I want to extend the macro to copy subdirectories and their files. Pretty basic stuff. I should be able to figure it out for myself. I thought I would just find and crack open the online Macro Development Guilde, or something like that, but I can't find a guide anywhere.

What's the best way to learn the syntax and development of macros for Visual Studio?

A: 

Well, there's two parts to what you're doing here in that example.

The first is the $(MacroVariable) variables that visual studio uses. All it does with these is to substitute in appropriate values from it's own settings and from the settings of the project. The best way to use these IMO is to go into something like the post-build event editor in a project's settings dialog and expand the Macros list - this shows what they are for that project. That's all you really do with these.

The second part is that after Visual Studio's performed its substitutions, you're left with a standard batch script which is then executed. There's any amount of help online for DOS batch script syntax and you can develop and test these using cmd.exe and an editor. Figure out what Visual Studio variables you want and set them as environment variables in cmd before running your batch script.

Finally, an actual visual studio macro is a VB.NET subroutine that uses the VIsual Studio API to perform tasks within the environment. You can get access to this from Tools -> Macros -> MacrosIDE in Visual Studio.

Kev
@Kev, thanks. The term "macro" is liberally used throughout the microsoft documentation. Most of the time I think "macro" is used in the most general of terms.
Martin Jasper
You're welcome. I know what you mean - macro *is* used liberally in lots of places.
Kev