Skip to Main Content
Visual Studio Hacks
book

Visual Studio Hacks

by James Avery
March 2005
Intermediate to advanced content levelIntermediate to advanced
304 pages
19h 23m
English
O'Reilly Media, Inc.
Content preview from Visual Studio Hacks
134
|
Chapter 4, Customizing Visual Studio
#34 Customize Your Project Build Process
HACK
In the Build Events tab, choose to run a Post-Build event when a successful
build occurs and add a Post-Build event command line of:
copy "$(ProjectDir)EndUser.config" "$(TargetDir)"
Note the use of quotes around the variables and commands—the quotes are
there because there may be spaces in the file and pathnames. Also, the vari-
ables that generate pathnames will append an ending slash automatically.
After a successful build of this project the current version of the EndUser.
config file in the project directory will be copied to the output directory.
Copying files after a build is just one example of how these build events can
be useful. More complex operations can be performed as well. For example,
a Windows script or executable could be run when a build completes to kick
off a set of test scripts against the newly built output. The build event could
just as easily automatically create and register an output type library for use
with COM or even register a newly built component with the GAC.
Pre- and post-build commands are available only to nonweb C# applica-
tions in Visual Studio .NET 2003, but they are also available to nonweb
Visual Basic .NET applications in Visual Studio 2005.
Handling Build Events
Some of the limitations of the custom pre- and post-build command events
are that they are available for
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Microsoft Visual Studio 2015 Unleashed, Third Edition

Microsoft Visual Studio 2015 Unleashed, Third Edition

Mike Snell, Lars Powers
.Net Framework Essentials

.Net Framework Essentials

Thuan L. Thai, Hoang Lam
C# 5.0 Unleashed

C# 5.0 Unleashed

Bart De Smet
Programming .NET Security

Programming .NET Security

Adam Freeman, Allen Jones

Publisher Resources

ISBN: 0596008473Errata Page