When adding an existing item to VS2010, why can't I add a file link from the same project?

I have two folders in my library project, folder A and folder B. Folder A will contain all the real files, but folder B (and many other folders) should contain links to the files A of the folder.

I tried adding an existing item (go to folder A) → add (down arrow) → add a link, but the add existing item dialog just closes and nothing happens. It seems I can add links to files outside the library project. What's going on here?

-Isaac

+6
source share
4 answers

For some reason, Visual Studio seems to silently ignore possible problems with adding a file as a link. I had the same problem and the solution was:

  • Make sure that the project folder already contains a file with the name of the linked file, if it is so delete or rename this resource.

  • Visual Studio 2010 seems to cache the contents of the project directory, because (1) was not enough to successfully link the file. Restarting VS helps.

+8
source

For some reason, it sounds like Visual Studio. I just tested this on a project that has many folders. I had a folder with images, and I was able to add the link and image to another folder, so it seems to be possible.

0
source

It adds the file to the project, but does it in the original location, and not in a new location.

You can see this if you exclude the source file from your VS project (but do not delete the file from disk) - the file will then add the original location to your project

eg. if you have the folder FolderA\index.htm and FolderB , and you want to create a link to index.htm in FolderB . Exclude index.htm from your project (but leave it in FolderA on disk), so your project has only two empty folders. Right-click on FolderB and select Add Existing Item , select index.htm from FolderA and click Add as Link . The file will be added to your project, but in FolderA (where it is located on the disk), not within FolderB , where you said to add it.

This is what the VS error looks like to me.

As already mentioned, this is a valid scenario if there are several root websites in the same project, but you want to share resources between them.

0
source

In my case (using Visual Studio 2013), I just needed to show all the files (the button at the top of the solution explorer), right-click on each file / folder and click "Include in Project".

0
source

Source: https://habr.com/ru/post/893639/


All Articles