Bug 3184 - Hide/suppress Copy to Output Directory option
Summary: Hide/suppress Copy to Output Directory option
Status: NEW
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Project Model ()
Version: Trunk
Hardware: PC Mac OS
: Low minor
Target Milestone: ---
Assignee: Lluis Sanchez
Depends on:
Reported: 2012-02-01 13:28 UTC by Mikayla Hutchinson [MSFT]
Modified: 2012-04-24 11:56 UTC (History)
2 users (show)

Tags: trident
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 3184 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Mikayla Hutchinson [MSFT] 2012-02-01 13:28:00 UTC
It should be possible for project types to hide the Copy to Output Directory option, and to suppress its action.


In MSBuild there is a "Copy to output" target at the end of the build sequence where build products are copied from the intermediate directory to the output directory. The "Copy to output directory" option is standard metadata that can be added to all MSBuild items and causes them to get added to the list of build products and copied to the output directory, however, the MS standard MSBuild targets only actually implement this for the "Compile", "EmbeddedResource", "Content", and "None" item types - for other item types it is a no-op. (Interestingly, this means they are copied transitively from referenced library projects, but of course they can't be copied from referenced dlls so this is of limited use).

It can be confusing because it's very simple - it literally just copies the items to the output directory *in addition* to whatever the build action specifies. In cases where the project is compiled into some kind of package - e.g. Silverlight xap, Windows Phone 7 xap, MonoTouch app bundle, Mono for Android apk - the file is not embedded into the package/bundle, it simply ends up in the output directory *beside* that bundle/package. Users are often are likely to be confused and set the flag unnecessarily for all Content files, thus wasting disk space and slowing the build.

There are a few issues here:
* it's not useful for projects that generate packages, it's only confusing
* MD's implementation isn't accurate to MSBuild, it displays the options and implements the copy for all item types

So IMO we should add a virtual method to DotNetProject:
public virtual bool CanCopySupportFile (string buildAction)
   return buildAction == BuildAction.Compile
       || buildAction == BuildACtion.EmbeddedResource
       || buildAction == BuildAction.Content
       || buildAction == BuilAction.None;

and the command and the support file copying could check this, and MonoTouch projects could override it to simply return false.