Friday, April 23, 2010

Making Visual Studio copy .config files

I'd created a few XML configuration files and given them the extension .config, since it was a descriptive name with the added bonus of IIS refusing to serve them.

However, using the Publish function in Visual Studio 2010 (right click -> "Publish...") to copy to the local file system, my custom .config files were never in my output directory. However, the .config files I'd created using the web.config file template were there.

I'd tried setting their "copy to output" setting to "always copy" and "copy if newer", all to no avail.

Eventually, it occurred to me to compare the properties of the ones that did work to the ones that didn't.

Screenshot of properties dialogue, 'Build Action' highlightedSo, the solution:

Bring up the Properties window for the file (right click -> Properties or alt+enter) and set the Build Action to "Content".

Now my files are copied successfully.