Share source code across multiple projects using Project Linker

Page updated :

About extended add-ins

First, there is a note about the add-in before the instructions.

This time, we're using the Project Linker 2012 extension add-in for Visual Studio 2012, but some of it is called Project Linker, which has almost the same functionality. It's the same feature, but project linker only works fine in Visual Studio 2010 because it's different from the producer. This time, the add-in to use will be Project Linker 2012, as it will be described in Visual Studio 2012.

Conversely, if you are using Visual Studio 2010, you can include Project Linker. I think that i can set it in almost the same way as the content described this time.

About sharing source code between multiple projects

Visual Studio is standard for sharing source code between multiple projects. Because the source file basically needs to be placed below the folder where the project file is located, for example, dragging the source file of Project A to Project B will make a copy of the file and double manage the code.

Let's start with the ability to share source code in Visual Studio. It becomes an image to make the link (shortcut) of the source file if it says simply what. To create a link to the code:

We're creating a project called Application1 and Application2, where Application1 has the substance of the source file, and Application2 refers to the source file. In the figure below, the "ProfileLoader.cs" file is in Application1 so that the Application2 project refers to it.

Application1 が ProfileLoader.cs ファイルを持つ

Right-click the Application2 project and select Add - Existing Items.


The file selection dialog is displayed, selecting the ProfileLoader.cs file in the folder of "Application1" as the referring point, clicking the "▼to the right of the add button" button in the lower right corner, and select "Add as link".


The ProfileLoader.cs file is added to the Application2 project. It is only a link to the apllication1 ProfileLoader.cs file, not a copy. You can see that a square and arrow icon have been added to the bottom right of the file icon.

If you open and edit the Application2 ProfileLoader.cs file in this state, you are editing the application1 ProfileLoader.cs file.

Application2 にファイルのリンクが追加される

Of course, the referenced file, i do the same as when I put the source file normally. Because the namespace remains Application1, you can use the class as usual by specifying the namespace as shown in the figure below.


Automate source code sharing using Project Linker

If you have only two projects that share source files, or if you have only a few files to share, manually as described above is fine, but if you have more projects or files, manually can be quite a hassle. Since the number of files that can be shared at a time by the above operation is one folder, it is said that the same procedure must be taken if the folder is layered. You must also reconfigure all projects to change the hierarchy of folders.

You can automate these operations by using the following Visual Studio extension Project Linker. Note that extensions must be professional or higher for Visual Studio Edition.

Download it from the following URL:

Project Linker 2012 ダウンロード

After downloading the file, double-click to start it. It is in installer format. Close all Visual Studio before installing.

ProjectLinker.vsix ファイルをダブルクリックしてインストール

Make sure that visual studio you want to install is checked, and then click the Install button.


Close it if it is installed successfully.


When you are finished, open the solution file with multiple projects. Let's say that project Application1 has the substance of the source file, and Application2 has its references.

Right-click the project you want to refer to and select Add project link.


As the dialog opens, select the project from the referring device Applicarion1. Select the project that has the substance of the source file, as the title says Select Source Project. When you select it, click the OK button.

"Link all items by default" when you press the "OK" button when you press the "OK" button, application1 files, folder configuration is synchronized to Application2, if you do not want to synchronize suddenly, please uncheck. On the other hand, it is convenient to check if you want to synchronize in bulk.


If the link is successful, click the OK button.


Application2 is linked to Application1, so let's try adding a class to Apllication1. Once you've created a link for your project, you're basically referring to application1.

Right-click the project and select Add - New Item.

追加 - 新しい項目

Add a class. You can add classes to what you need. We're creating a class called StringHelper to help you edit strings.


When you add a source file, a file link is automatically created in the Application2 project.


Try to create a folder.


Folders are also created automatically. By the way, folders do not have the concept of links, so they are created by physical folders.


If you move the file into the folder you just created, the link will be moved automatically as well.


Try to delete the folder and the files in it.


The link is deleted as well. In this way, You can use Project Linker to synchronize files and folder configurations across multiple projects.


When more than one project is linked, you can see what it is in today. Select Edit project links from Projects on the menu.

Here you can check the list of links and break them. To break the link, select the link from the list and click the Unlink button.