Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

This is more a question about Visual Studio .NET Solutions than .NET in general. You can add custom pre-build and post-build events to individual projects in VS.NET. I was wondering if there is a way to do this for the solution as a whole? I want to run a program everytime I build my solution, but only after all the projects in the solution are built.

 

I suppose I could set the post-build event for the last project built (determined by looking at the Project Build Order) but that could potentially change depending on how VS.NET wants to build the projects. If VS.NET changes the build order then I will need to change my post-build event!

 

Any suggestions?

  • *Experts*
Posted

No idea how to do it "right", from within the IDE - not sure Visual Studio even supports any kind of event like what you want. Maybe, but it seems like a lot of work to write an "add-in" to do what you want.

 

Can you just "fake" dependencies in your solution? So have Project C depend on Project B which depends on Project A, even though none actually have any references or other dependencies. In effect, force which project will be built last.

 

Now, there might still be a problem. From what I've experienced, the Post Build command only runs when a project is Built. If VS determines everything is up to date, it won't run the Post Build command. So unless you're changing your "last" project, the one with the Post Build event, it won't be running that command.

 

Two other suggestions, though neither may work for you: do ALL your compiling from a batch file (which would include your custom post build step) OR just run a batch file after you rebuild, which is all a Post Build command is.

 

-ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted
I know I am going to catch some flak for this, but what would you use the pre and post build? I know one comment will be, if I don't know, then I don't need them. Just something I have seen and was curious about.
"Nobody knows what I do until I stop doing it."
Posted
I know I am going to catch some flak for this' date=' but what would you use the pre and post build? I know one comment will be, if I don't know, then I don't need them. Just something I have seen and was curious about.[/quote']

Rule: "The only dumb questions are the questions unasked"

Corrallary: "There are dumb answers"

 

One usage is to do a source backup and binary association. You might find yourself trying to pinpoint a bug, your build events can make a backup directory, move the source and compiled binary over giving you an easy way to audit change effects as you try to fix the problem.

 

At my last job, we wanted the installation splash screens to mirror Applications splash screens including the specific version build of the application. If the application was run with a /splashonly command line switch, the Splashcreen would be shown, a bmp would be created from it, the jpg would be saved and the application would exit. The post build event executes that command line and therefore after every build we have bmp that can be used in the installshield project.

 

Primarily, pre and post build events are used to perform housekeeping and project audit tasks. but I am sure if you are creative you can find other uses for them.

 

joe mamma

Joe Mamma

Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized.

Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.

Posted
Rule: "The only dumb questions are the questions unasked"

Corrallary: "There are dumb answers"

 

One usage is to do a source backup and binary association. You might find yourself trying to pinpoint a bug, your build events can make a backup directory, move the source and compiled binary over giving you an easy way to audit change effects as you try to fix the problem.

 

At my last job, we wanted the installation splash screens to mirror Applications splash screens including the specific version build of the application. If the application was run with a /splashonly command line switch, the Splashcreen would be shown, a bmp would be created from it, the jpg would be saved and the application would exit. The post build event executes that command line and therefore after every build we have bmp that can be used in the installshield project.

 

Primarily, pre and post build events are used to perform housekeeping and project audit tasks. but I am sure if you are creative you can find other uses for them.

 

joe mamma

 

 

Thanks for the reply, I feel MUCH more knowledgeable now. Also gives me a few ideas on handling some things as well.

"Nobody knows what I do until I stop doing it."
  • *Experts*
Posted

As a note, a pre/post build event is just a batch file that VS creates and runs for you at the proper time. I've used them for such things as copying files to a shared resource (for simple Dev environment pushes) though the sky's the limit. A batch file could, for example, run another program - even the app you just compiled if you had the need (select Build off the menu and the program runs, go figure).

 

-nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...