简体   繁体   中英

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)

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".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM