In my project in Visual Studio, I have files that I want included in the output, but not compiled or embedded.
I am aware that there are 2 ways to accomplish this.
- Setting the Build Action for the file to 'Content'
- Setting the 'Copy to Output Directory' to 'Copy Always' or 'Copy if newer'
Can someone tell me what the difference is and which scenario is each of the options appropriate for?
The Content build action has visible effect in WPF projects (possibly ASP too).
It adds
to
WpfApplication1_Content.g.cs
. Read aboutAssemblyAssociatedContentFileAttribute
.In WinForms and console application (what OP may be using) it does not do this, so there's no difference to None action when building.
In this comment, I've found also a note about effect on deployment:
Possibly this works even for console and WinForms applications (I haven't tried).
When setting the
Build Action
toContent
, the file will not be compiled and will be put in the Content output group.Whether the file gets copies or not depends on the
Copy to Output Directory
setting at that point.Of course, if you set
Copy Always
on a file, it may get compiled and then copied.See File Properties on MSDN:
Copy Always will also trigger a rebuild of that project in a solution even if no code has changed.