What is Content Build Action in Visual Studio?

Martin Prikryl picture Martin Prikryl · Mar 21, 2014 · Viewed 40.9k times · Source

What does the Content Build Action in Visual Studio do? It does not look like it's doing anything.

The File Properties article on MSDN (does not exist anymore) says:

Content - The file is not compiled, but is included in the Content output group. For example, this setting is the default value for an .htm or other kind of Web file.

But I have no idea what the "Content output group" means.

Is this something about deployment? Meaning, the action has no actual effect, when building, but only later when deploying?

Answer

Hans Passant picture Hans Passant · Mar 31, 2014

"Content" means that it is a deployable project item, it signals that the file needs to be copied to the target machine.

Something you can see with a simple console mode project. Project + Add New Item, pick the Bitmap File item template. Its Build Action is automatically set to "Content". Use Project + Properties, Publish tab and click the Application Files button. Note how the bitmap automatically got added to the list of deployed files:

enter image description here

Go back to the Properties window and change its Build Action to None. Click the button again and note how the file is now no longer included.

Also used by installer utilities that integrate with VS for the exact same reason. And a big deal in web applications, they usually have a lot of files that need to be deployed to the web server.