Search code examples
asp.netvisual-studio-2010publish

Uploading a file with VS2010 "Publish" to custom directory


I have a file I need to have published with my ASP.NET site to the server. I put it in the project root and set 'Copy to Output Directory' to 'Copy if newer'. When I publish, it copies the file to a 'bin' sub-directory. No good! I need it at the root of the site. Other files (such as my *.aspx files) that are right next to it in my project get copied to the root. How do I set it so this file also get copied to the root?


Solution

  • Change the "Copy to Output Directory" to "Do Not Copy", then Set the Build Action to "Content". Copy to output directory copies the file to the bin folder. You would use that feature to copy a license file needed for the assemblies for example. Setting the build action to Content causes the file to be sent to the server in its relative place.