简体   繁体   中英

Is there any way to run Visual Studio command-window commands as pre- or post-build steps?

I've tried to put some command-window commands (Or "internal commands"? I wish Microsoft had given these a more specific name to make discussing and searching easier.) like File.OpenFile or Edit.Goto in the Post-Build Command section of my project but the whole step just fails, at least with VS 2010.

I suspect this is because by default the pre- and post-build commands are launched with cmd.exe, which doesn't know anything about Visual Studio's "internal commands", but I wanted to ask anyway, to make sure: isn't there some special syntax or other scripting-like solution to get VS to run a set of its "internal commands" after every build of a certain project?

I know I can put a bunch of "devenv /Command" lines in the Post-Build, but this just starts several new instances of Visual Studio, which is totally not what I want (eg I need a succession of File.OpenFile and Edit.Goto commands to operate on the same file in the same instance of VS, it doesn't make any sense for each command to get executed by a separate instance of VS).

You can use Visual Commander to subscribe for DTE.Events.BuildEvents and in your handler use DTE.ExecuteCommand to run a VS internal command. See for example the Report warning if missing files on build extension.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM