VS2010 "Copy to output directory" not working?
Asked Answered
A

4

5

I'm trying to publish my web solution to the file system, using the "Only files needed to run this appllication" option.

I have the following problems:

a) I have a connectionStrings.config file that should be included; I've marked this file as Content and Copy Always.

b) For testing purposes, I've added a textfile.txt that should not be included; I've marked this as Content and Do Not Copy.

Both of these settings fail... It seems that the setting "Copy to output directory" is simply disregarded.

Any ideas why this happens, and what to do about it?

Autoplasty answered 24/6, 2010 at 10:34 Comment(0)
M
5

The "Copy to output directory" is for when you are building your application, not publishing it.

This property specifies the conditions under which the selected source file will be copied to the output directory. Select Do not copy if the file is never to be copied to the output directory. Select Copy always if the file is always to be copied to the output directory. Select Copy if newer if the file is to be copied only when it is newer than an existing file of the same name in the output directory.

Source

There's more information on publishing web sites and applications here

Moneywort answered 24/6, 2010 at 10:38 Comment(8)
OK, but how do I specify what is included/excluded when publishing? (My site will crash if the connectionStrings.config file is not included, and I don't intend to copy it manually...)Autoplasty
It's obvious that the buildaction plays a part here; I've experimented by setting the build-action of my textfile.txt to None, and then the file does not show up in the publish directory. As explained above, it does show up in the publish directory when the action is Content, even if it's set to Do Not Copy. How can I control what is included in the publish? (In VS2008, I used the Do Not Copy / Copy Always setting, and it worked.)Autoplasty
@Autoplasty - Sorry I can't be of more help.Moneywort
@ChrisF: What is the "output directory"? What is the definition of this? Specificallly I am interested in an ASP.NET web form project. Thanks.Meaning
@OldGeezer - "output directory" is where VS copies the binaries to when the project is built.Moneywort
Thanks. By binaries do you mean the dlls or the exe? If so, isn't this just bin? But every file has this property.Meaning
@OldGeezer - I meant exe or dll (depending on the type of project). The intermediate files are in binMoneywort
I was just wondering about this and discovered that files marked Copy to Output Directory: Copy Always were being copied to folders in the bin folder.Greegree
M
2

I had the same problem, that files marked as content, with "copy always" set, were not appearing in the output dir.

At the time i noticed this, i was tracking down why certain of my dlls were not getting deployed.

Sorting my project dependencies fixed both issues.

Mistrustful answered 7/11, 2011 at 9:51 Comment(2)
Same problem here. In project generating EXE, I had to add reference to project containing the files to copy.Tavis
I have the same problem. How do I sort project dependencies?Shuttering
M
0

I just had this problem and for some reason choosing "Create application without a manifest" under the project's properties finally copied the linked content file to the build directory.

Mutation answered 12/12, 2014 at 22:47 Comment(0)
C
0

I re-started my visual studio and select the "copy always" option again. Rebuild and worked.

Good Luck.

Coldblooded answered 29/6, 2016 at 17:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.