WP7 Development Tip of the Day: Copy to Output Directory Demystified

by brad 17. September 2010 06:00

Today’s a short and sweet tip that sprang from a moment of curiosity I had.  It’s quite possible that most everyone but me already know this.

I’ve never really paid much attention to the “Copy to Output Directory” property of files (specifically, images) in my Windows Phone 7 project. In the back of my mind, I always wondered what the correct choice was, but things always just worked so I didn’t question it.

If you’re not familiar with this property, it’s available for every file in your project.  The valid choices are “Do not copy”, “Copy always”, and “Copy if newer”. 

Untitled

For a Windows Phone 7 project, the “Output Directory” is “Bin\Debug” by default.  This is the same folder where the XAP will be placed.  And regardless of what you choose, all of your images will be included in the XAP file. So for a Windows Phone 7 project, this setting has no impact to your application since the XAP is the deployment package.

As a test, build your file with “Do not copy” and then “Copy always”.  In both cases, the file will be included inside the XAP.  The only difference will be if the file ends up copied to your hard drive in the “Bin\Debug” folder.

More Tips

Tags:

Windows Phone | WP7 Tip of the Day

Comments

9/23/2010 3:53:39 PM #

PHenry

re "regardless of what you choose, all of your images will be included in the XAP file. ...this setting has no impact to your application ..."
I believe this is only the case because you have selected Content as the Build Action.  If you change that to Embedded Resource, then the file is only copied to the output dir if the Copy to output is setup (always or if newer).  Or so goes my understanding.  I'm looking at doing a blog on this cause I too, like you, am very curious about this and there seems to be quite a bit of assumptions being made by the masses out there.

Thanks for digging into this further, helps prod me too! :> LOL

PHenry Canada

10/27/2010 5:56:54 AM #

trackback

Дайджест технических материалов #5 (Windows Phone 7)

Tools, Books, Guides Windows Phone 7 Developer Tools RTM (online installer) , ISO UI Design and Interaction

Oleksandr Krakovetskiy blog

6/21/2011 11:31:48 AM #

pingback

Pingback from chaokuaidi.com

超快递 beta版 » Windows Phone 7 资源汇总(超全)

chaokuaidi.com

5/17/2012 10:11:10 PM #

pingback

Pingback from dancecoder.com

Windows Phone 7 资源汇总 | DanceCoder

dancecoder.com

Comments are closed

About Brad

Brad Tutterow lives in Illinois and works in Missouri. He has 12 years of experience developing web sites and Windows applications using a variety of technologies and is most excited currently about Silverlight, Windows Phone 7, Halo Reach, and Visual Studio 2010.