Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Content Build Action in Visual Studio?

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?

like image 287
Martin Prikryl Avatar asked Mar 21 '14 07:03

Martin Prikryl


People also ask

How do you set a build action to a resource?

using command promptClick in the solution explorer the file that will be modified. Then hit F4 or click with the right button in the file and then select the "Properties" option. In the Properties window, change Build Action to Embedded Resource.

Where is build file in Visual Studio?

To open the project's property pages, right-click on the project node in Solution Explorer and select Properties. Select the appropriate tab based on your project type: For C#, select the Build tab. For Visual Basic, select the Compile tab.

How do you create a file in Visual Studio?

There is an option under 'project and solution' / 'Build and run', 'only build startup projects and dependencies on Run' that helps. Edited: Ctrl-f7 for 'build file' is for C++ projects.

How do I add embedded resources to Visual Studio?

Open Solution Explorer add files you want to embed. Right click on the files then click on Properties . In Properties window and change Build Action to Embedded Resource . After that you should write the embedded resources to file in order to be able to run it.


1 Answers

"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.

like image 124
Hans Passant Avatar answered Sep 24 '22 19:09

Hans Passant