Using Synergy/DE repositories in Visual Studio
To use a Synergy/DE repository with a traditional Synergy or Synergy .NET project in Visual Studio, you can do either of the following:
- create a Synergy/DE 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. 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 (for example, when running your Synergy program or Synergy/DE Repository). See Precedence for environment variables and references for details.
- 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, 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.
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.
- For information on adding references and build dependencies, see Visual Studio documentation.
- For information on creating repository projects, see Creating a Synergy/DE Repository project below.
If your application uses multiple repositories, create a Synergy/DE Repository project for each of the repositories. Then in your application projects that use the repositories, add a reference to the primary repository, and add build dependencies to the projects for secondary repositories (i.e., repositories specified with DBLNET2XML_RPS or DBL2XML_RPS, or a repository specified with an .INCLUDE statement).
Using repositories that don't have projects
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.
Note that settings on the Environment Variables and Common Properties pages 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). Otherwise, settings on these pages override synergy.ini and synuser.ini settings (for both Visual Studio and MSBuild). For more information, see Precedence for environment variables and references.
Creating a Synergy/DE Repository project
With a Synergy/DE 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.
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/DE 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., NuGet Package Manager UI). 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/DE 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/DE 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. |