开发者

What's the best way to learn about how to develop macros (syntax, system libraries) in Visual Studio?

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 subdirecto开发者_运维知识库ries 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜