Click here to Skip to main content
13,048,584 members (82,965 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

10K views
2 bookmarked
Posted 27 Jan 2012

Triggering a Build when File Changed in Visual Studio

, 27 Jan 2012
Rate this:
Please Sign up or sign in to vote.
How to trigger a build when file changed in Visual Studio

In Visual Studio, when a source code file is changed, the project it belongs to will be built when the whole solution is being built. So far, so good. But what happens if you want some other files (read: non source code files) to have the same behavior?

In my case, I had some translation files (XML files), and a custom build event that converted them into a binary representation. So when one of the translation files changed, I wanted this change to trigger a build for the project the translation files were contained in, so that they could be converted into binary form (i.e., so that the build event was executed).

Visual Studio (at least version 2010) provides an easy but hidden way to achieve exactly this. After you’ve added the file(s) to your project, right-click them and choose Properties (Alt+Return).

The Properties menu item

Note: You need to open the properties for the files you want to trigger the build – don’t open the project’s properties. Also, you need to open the “Properties” dialog. You can’t do this from the “Properties” panel (which usually opens up when hitting F4).

Note 2: You could have selected multiple files to make them all trigger a build when changed in one step.

In the “Properties” dialog, under Configuration Properties –> General –> Item Type, you select Custom Build Tool. Then you hit “OK”. And that’s it.

Selecting "Custom Build Tool" as "Item Type".

Changing the file(s) should now trigger a build when you build the solution (via menu Build –> Build Solution).

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Sebastian Krysmanski
Software Developer University of Stuttgart
Germany Germany
I have studied Software Engineering and am currently working at the University of Stuttgart, Germany.

I have been programming for many years and have a background in C++, C#, Java, Python and web languages (HTML, CSS, JavaScript).

You may also be interested in...

Pro

Comments and Discussions

 
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170713.1 | Last Updated 27 Jan 2012
Article Copyright 2012 by Sebastian Krysmanski
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid