Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add a reference to an external configuration file to Visual Studio 2010?

I have an external configuration file, for a third party tool, which I would like to be able to edit as part of editing other project components in VS2010.

The project I'm working on is an MVC-3 project, and the file is located outside of the folder structure for the project (it's in the equivalent of ../ExternalConfig to the root).

How do I add a reference to this file to VS2010? Currently, all my attempts have resulted in VS creating a copy of the file inside of its directory structure, which is not ideal.

(Sure, I could go to some strange lengths, like adding a script to the build process to put the config file in the right place, but I'd rather just be able to edit it where it sits)

like image 289
blueberryfields Avatar asked Mar 15 '12 22:03

blueberryfields


People also ask

How do I add a reference in Visual Studio?

To add a reference, right-click on the References or Dependencies node in Solution Explorer and choose Add Project Reference. You can also right-click on the project node and select Add > Project Reference.


1 Answers

The trick is to add the item as a link:

  1. Right-click your project in Solution Explorer
  2. Select "Add" -> "Existing Item..."
  3. Navigate to the file that you want to add to the solution
  4. [Important] Instead of hitting Enter or clicking the Add button, you want to click the down-arrow icon at the right edge of the Add button, and select "Add As Link".
like image 187
Igor ostrovsky Avatar answered Sep 21 '22 05:09

Igor ostrovsky