English 中文(简体)
Prebuild Event only on Build Solution/Project not on F5(Debug)
原标题:

As the tittle says I need a prebuild command CONDITION that executes an exe on build solution/project and passes when i use F5.

I found "$(ConfigurationName)" as a possible solution on some websites but it only works if you change each time the configuration type manually.

Anybody knows the trick??

最佳回答

I think what you actually want is a seperate build configuration or some condition that does not run the events when you are developping/debugging, right? Here are two ways I can think of:

  • create a new configuration, as a copy of the current one, and exclude the build events. It s good practice using property sheets, and if you did so, you will not have to change each configuration manually instead just change the property sheet. Then when developping/debugging, use the new configuration
  • make the buildevents conditional. The condition can be an environment variable, a custom project variable, something you specify in a batch file,... Suppose you use an environment variable named RUN_PREBUILD , then the build event commad line would be, for example: IF "%RUN_PREBUILD%" == "1" (echo not running postbuild) ELSE (/path/to/prebuild.command) Now to make this completely nice, assign two external tools in VS, one that sets the variable to 0 and one that sets it to 1 (use setx to set environment variables). You can now add these commands to the toolbar, so the only thing you need to do is click a button to specify if prebuild should happen or not.
问题回答

F5 will only build the project if there are any changes in code. So I don t think you can issue a command that will always trigger an prebuild command when using F5.





相关问题
building .net applications without Visual Studio

I m interested to hear about people working with building .net applications using MSBuild, NAnt or similar tools. What are you using, why are you using it instead of the VS IDE? I like to use ...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Visual Studio 2010 Beta 2: Can I print in color?

I have to turn in a hard copy of some code with an assignment. Is there any way in Visual Studio 2010 to print C# source code with syntax highlighting? PS: The assignment is solving a math problem, ...

Set Select command in code

On button Click I want to Set the Select command of a Gridview. I do this and then databind the grid but it doesn t work. What am i doing wrong? protected void bttnView_Click(object sender, ...

WPF design-time context menu

I am trying to create a custom wpf control, I m wondering how I can add some design-time features. I ve googled and can t seem to get to my goal. So here s my simple question, how can I add an entry ...

热门标签