Project Linker: Synchronization Tool
This topic is the starting point to learn how to use and the features available in Visual Studio Tooling Synchronization Package, also known as the Project Linker.
The approach the patterns & practices team is taking for multi-targeting is to provide guidance on structuring application and module code into multiple linked projects. Each project manages all the references, resources, and code specific to the Windows Presentation Foundation (WPF) or Silverlight target environment.
Manually maintaining the links between files in multiple projects using Visual Studio is possible, but it can be time consuming and error prone. For this reason, the Composite Application Guidance for WPF and Silverlight provides the Project Linker tool. This tool helps to automatically create and maintain links from a source project to a target project to share code that is common to Silverlight and WPF. Therefore, shared code can be written once and built for the target environment.
The follow procedure describes how to install the Project Linker.
To install the Project Linker
- Run the file MicrosoftPracticesProjectLinker.msi. The welcome screen appears. Click Next to continue.
- After you read and accept the End-User License Agreement (EULA), click Next.
- Select the installation folder, and then click Next.
- Click Next to confirm the installation. The installation will proceed.
- Click Close to exit the installer.
| There are no known issues with installing the Project Linker in Visual Studio; however, all scenarios for the Project Linker have not been tested, so you are strongly encouraged to use a recoverable version of Visual Studio.|
Alternatively, you can compile and run the Project Linker in the Visual Studio Experimental Hive. For information about how to do this, see the Running the Project Linker in the Visual Studio Experimental Hive section.
Project Linker Features
This section describes the features and operations that can be performed with the Project Linker.
Linking a Source Project to a Target Project
To link a source project to a target project, right-click the target project, and then click Add Project Link. In the Select Project dialog box, click the source project, and then click OK. The Select Project dialog box is shown in Figure 1.
Viewing and Removing Project Links
To see the current links in Visual Studio, click Edit Links on the Project menu. In the Project Links dialog box, you can also unlink a project; to do this, click the project link, and then click the Unlink button, as illustrated in Figure 2.
Adding a File to the Source Project
When a file is added to the source project, and if the filter does not filter it out, a link to this file will be added on the target solution. (For more information about filters, see the File Filtering section.)
If you are adding a file to a folder that exists only in the source project but not in the target project, and if the file passes the filter conditions, a link to file will be added, and the folders needed to meet that path in the target project will also be added. If the file does not meet the filtering conditions, no changes will be made to the target project.
When a file is added to the source project and a physical file with the same name already exists on the target project's folder (whether or not it is included in the project), no action will be taken. Adding a file to the source project and its results are shown in Figure 3.
Adding a Folder to the Source Project
When a folder is added to the source project, and if the filter allows it, a new folder will be created on the target solution.
When a folder is added to the source project and a folder with the same name already exists on the target project but it is not included on it, the Project Linker will include the folder to the project with all its contained files. If the folder is already included on the target project, no action will be taken.
|The behavior of including all files contained in a folder is the same behavior that occurs when you right-click an excluded folder and then click the Include in Project option.|
Adding a folder to the source project and its results is shown in Figure 4.
Removing a File in the Source Project
When a file is removed on the source project, the linked file associated with it on the target project will also be removed, as illustrated in Figure 5.
Removing a Folder in the Source Project
When a folder is removed on the source project, and if the folder on the target project has no physical files on its substructure (that is, it contains folders or link files), it will be removed.
However, when you delete a folder on the source project, and if the linked folder on the target project contains items in addition to empty folders (that is, files or manually created links to other files), the folder will not be deleted from the target project. Removing a folder in the source projects and its results is shown in Figure 6.
Renaming and Moving Files
When you move or rename files, this is accomplished internally by removing the old file and adding a new one. If the file cannot be removed because the linked file did not exist on the target project, it is still added in the new folder (or with the new name) if the filter allows it, as illustrated in Figure 7.
Renaming and Moving Folders
Moving a folder first moves all the files that it contains; after that, the folder is deleted, and then the folder addition will be attempted. This is because all rules from additions and deletions apply for renaming and moving. The renaming and moving operations and their results are shown in Figure 8.
Filters can be specified to avoid auto-linking every file. This is useful if you are writing code specific to Silverlight or WPF that should not be shared across projects.
Currently, files that fulfill at least one of the following conditions are filtered out:
- Files that have the file name suffixes .Silverlight.cs or .WPF.cs
- Files that reside in Silverlight or Desktop folders
- XAML files
|Plans are being made to allow defining custom filters using regular expressions in future versions of the tool.|
The following procedure describes how to uninstall the Project Linker.
To uninstall the Project Linker
- In Windows Vista, double-click the Programs and Features icon in Control Panel, and then click Uninstall for the MicrosoftPracticesProjectLinker item.
- In Windows XP, double-click the Add or Remove Programs icon in Control Panel, and then click Remove for the MicrosoftPracticesProjectLinker item.
- To use the installer to remove the Project Linker, select the Remove the MicrosoftPracticesProjectLinker option, and then click the Finish button.
Running the Project Linker in the Visual Studio Experimental Hive
The following procedure describes how to run the Project Linker in the Visual Studio Experimental Hive.
To run the Project Linker in the Visual Studio Experimental Hive
- In Visual Studio, open the solution file ProjectLinker.sln.
- Right-click the ProjectLinker project, and then click Properties.
- Click the Debug tab. It the Start Actions section, select Start external program, look for the Visual Studio executable file, Devenv.exe (typically, it is located at Program Files\Microsoft Visual Studio 9.0\Common7\IDE\), and then click OK.
- In the Command line arguments text box in the Start Options section, type the following arguments: /rootsuffix Exp /RANU.
- Save the changes.
- Run the solution. To do this, press F5, making sure that the ProjectLinker project is set as the startup project.
Frequently Asked Questions About the Project Linker
Can a project link to itself (self-reference)? If it can, what is the expected behavior?
It is not possible. This is being validated; therefore, self reference is not allowed.
How do you identify which project is linked to which other project? How do you identify the source project and the destination project in the linking?
On the Project menu, click Edit Links. The Edit Links dialog box shows all the current links, including the source project and the project it is linked to. You can also use this dialog box to unlink projects.
Can you link projects between incompatible project types? For example, can you link a WPF (Visual Basic) project with Silverlight (C#) project or a Windows Workflow project with a Silverlight project?
Currently, the Project Linker works with any project type that you want. Keep in mind that linking between incompatible kinds of projects, such as between a Workflow project and a Silverlight project, is allowed, but it might lead to compile errors.
However, linking between C# projects and Visual Basic projects is not allowed. The OK button in the Select Source Project dialog box is not available if the project languages are different.
What happens if the linked files are deleted in the destination projects and the same file is updated in the source project?
If the updates are within the file, the destination project should not be affected.
What happens if the linked files are deleted in the destination projects and the files are renamed in the source project?
Currently, this causes the linked file to appear in the destination project with the new name, by design.
What happens if the destination project already has the file that is being synchronized?
If the destination project already contains the file being synchronized, the Project Linker does not ignore it; therefore, it will not create the link.
Is multi-project linking allowed?
You can have several projects linked to the same source, but each target project can have only one source project associated.
Is it valid to link an existing WPF project to an existing Silverlight project? What is the expected behavior? Will the existing files be linked/synchronized?
Yes, it is possible. The project starts synchronizing the moment the projects are linked. However, you have to manually synchronize existing files.
The Project Linker solution includes a separate solution that includes acceptance tests. The acceptance tests describe how the application should perform when you follow a series of steps; you can use the acceptance tests to explore the functional behavior of the application in a variety of scenarios.
Some acceptance tests were developed using the testing framework White. To run these tests, you need to have White installed. For more information about White, including download information, see White on CodePlex.
|The acceptance tests have been developed and verified with the White 0.1.5.0 release. Although other releases of White might work, it is recommended to use this release to avoid any issues when running the tests.|
To run the Project Linker acceptance tests
- Place the assemblies required by White in the folder Source\Lib\White. The files are the following:
- In Visual Studio, open the solution file ProjectLinker\ProjectLinker.Tests.AcceptanceTest\ ProjectLinker.Tests.AcceptanceTest.sln.
Note: No other tasks or operations should be performed during the acceptance tests because the handle of the Visual Studio is used for performing acceptance testing.
Solution Explorer should be made visible and should not be dockable in the file ProjectLinker.Tests.AcceptanceTest.sln.
- Right-click the project ProjectLinker.Tests.AcceptanceTest, and then click Set as StartUp Project.
- Press F5.
For information about creating multi-targeted applications in WPF and Silverlight, see the following topics:
- Multi-Targeting design concept
- Contrasting Silverlight and WPF
- Multi-Targeting technical concept
- Multi-Targeting QuickStart