Using Synergy repositories in Visual Studio
This topic includes the following sections:
- The two methods for using repositories in Visual Studio
- Schema files
- Creating a Synergy repository project
- Referencing multiple repositories
- Using repositories that don’t have projects
The two methods for using repositories in Visual Studio
To use a Synergy repository with a traditional Synergy or Synergy .NET project in Visual Studio, you can do either of the following:
- create a Synergy repository project and then reference that project. A project that references a repository project will be rebuilt when the repository changes. Make sure no RPSMFIL, RPSTFIL, or RPSDAT settings override references to repository projects. See Creating a Synergy repository project below.
- use RPSMFIL and RPSTFIL or RPSDAT to specify the location of repository files. In this case, the project will not be rebuilt when the repository changes (though you can create a pre-build event that rebuilds the repository when the project is built). See Using repositories that don’t have projects below.
The first method is generally best. When you add a reference or dependency to a repository project, the repository files become part of the build system, so projects that reference the repository are rebuilt if repository files change.
Schema files
By default, SDI treats files with the following extensions as repository schema files when they are in repository projects: .rps, .scm, .schema, .sdl, and .sch. IntelliSense is not supported for repository schema files, but syntax colorization is automatically applied to these files.
If you want files with some other extension to be treated as repository schema files, use the File Extensions window of Visual Studio Options:
1. | Select Tools > Options from the Visual Studio menu, and then select Text Editor > File Extensions in the Options window. |
2. | Enter the extension in the Extensions field, and select “Synergy Data Language” in the Editor field. Then click Add. |
Creating a Synergy repository project
With a Synergy repository project, you can generate the repository from one or more schema files, or you can use existing repository files. If you use schema files, repository files are generated when the project is built or rebuilt (if the schema files change). Both methods use options on the Repository page of project properties, so see Repository page of Visual Studio project properties for more information.
![]() |
Make sure no RPSMFIL, RPSTFIL, or RPSDAT settings override references to repository projects. For example, RPSMFIL and RPSTFIL or RPSDAT settings in synergy.ini and synuser.ini override references to repository projects when the Synergy Runtime is used (e.g., when running your Synergy program or Synergy/DE Repository). Refer to Precedence for environment variables and references for details. |
![]() |
Changes made in the Repository program may be lost if the repository’s schema is used by a repository project that is open in Visual Studio. If you use the Repository program to make changes to a repository whose schema is used by a repository project, export the schema immediately after making the changes and before opening Visual Studio. |
![]() |
Projects created from the Synergy repository template automatically include the Synergex.SynergyDE.Build NuGet package, which is required. When a repository project is created, the latest Build package (that is not pre-release) is downloaded to a local NuGet repository for the project. To update the Build package for existing projects, you must use the NuGet Package Manager. See Microsoft documentation for more information (e.g., Install and manage packages in Visual Studio using the NuGet Package Manager). Additionally, if you move a repository project to a different location relative to its solution, the Build package reference for that project will no longer be valid. You must use the NuGet Package Manager to uninstall and then reinstall the package. |
![]() |
See the Synergex YouTube video: Using the Repository Project Template. |
Generating a repository from schema files
To create a Visual Studio project that generates repository files from one or more schema files,
1. | Use the Synergy repository project template to create a Visual Studio project (select “Synergy/DE Repository” in the New Project dialog in Visual Studio). |
2. | Add schema file contents to the blank schema file (repository.scm) that is automatically included in the project, or delete that schema file and add one or more schema files to the project. (You can use the Schema item template in the Add New Item dialog in Visual Studio to create a new schema file.) |
3. | Check the Build Action setting for the schema file(s). The Build Action for schema files should be set to Compile. |
4. | Go to the Repository page of the Visual Studio project properties. (Select the repository project node in Solution Explorer, and then select Project > Properties.) |
5. | In the “RPS main file” and “RPS text file” fields, specify names (without extensions) for the repository files that will be generated for the project. |
6. | If you want to generate the repository files to a location other than the default, specify that location in the Output path field. |
Using existing repository files
To create a Visual Studio project that uses existing repository files,
1. | Use the Synergy repository project template to create a Visual Studio project (select “Synergy/DE Repository” in the New Project dialog in Visual Studio). |
2. | Go to the Repository page of the Visual Studio project properties. (Select the Repository project node in Solution Explorer, and then select Project > Properties.) |
3. | Select the “Use existing repository” option on the Repository page. |
4. | In the RPS main file and RPS text file fields, enter the path and names (without extensions) of the repository files you want added to the project. The repository files are copied to the project when the project is built. From that point on, the project will use its copies of these files. |
Referencing multiple repositories
If your Visual Studio project uses multiple repositories, create a repository project for each one and add references to those projects. The first repository reference is automatically set as the default repository, which is used for code colorization. To change the default repository, right-click the repository reference in Solution Explorer, select Properties, and set the Default Repository property to true or false. You can also use the Default Repository Description property to provide a description. Note that only one repository reference can be set as the default. If you set another reference’s Default Repository property to true, all others are automatically set to false. If no reference is set as the default, the first listed repository reference will be used for colorization, but attempting to build the project will result in an error.
Using repositories that don’t have projects
If you use RPSMFIL and RPSTFIL or RPSDAT to specify the location of repository files, note the following:
- Projects that use the repository will not be rebuilt when the repository changes, but you can create a pre-build event that rebuilds the repository when the project is built. See Build Events page of Visual Studio project properties.
- If you use RPSMFIL and RPSTFIL or RPSDAT to specify the location of repository files, these environment variables should be set on the Environment Variables page or the Common Properties page of project properties. (It is possible to set them in a synergy.ini or synuser.ini file used by the project, but this is not recommended.) Settings on the Environment Variables and Common Properties pages are used by Visual Studio and MSBuild, but note that they are overridden by settings in synergy.ini and synuser.ini when the Synergy Runtime is used (e.g., when running a Synergy program or Synergy/DE Repository). Refer to Precedence for environment variables and references for more information.