Configuring Visual Studio Projects

Micro Focus has the following recommendations for configuring your projects in Visual Studio:

Use the IDE settings to specify Compiler directives

The project's and file's IDE property pages in Visual COBOL provide a wide range of COBOL settings.

The IDE settings are easy to edit and easy to port. Once you use them to configure your projects, they apply both inside Visual Studio and at the command line.

Micro Focus recommends that to set Compiler directives you use the IDE property pages in preference to any other method. Specifically, you should avoid the following:

  • Manually editing the COBOL project file, .cblproj.
  • Mixing .bat files with build scripts.
  • Manually entering a Compiler directive in Additional Directives in either the file or the project's properties, if an IDE setting for the directive exists. Use the GUI setting instead.

    You might end up setting the same directive using both the GUI controls and Additional Directives which could lead to errors.

    For example, you could manually type CICSECM in Additional Directives at the project level. At the same time, it could also be set to None in a file's GUI controls. As a result, there's an ambiguity as to which of the settings actually applies.

    You should only specify a directive in Additional Directives when no corresponding IDE setting exists.

Avoid $SET statements in the source files

Avoid setting any $SET statements directly in the source files. Instead, use the project's properties pages inside the IDE to set the corresponding Compiler directive. The reasons for this are:

  • $SET statements in the code are not easily visible, especially when you are working with a large number of files.
  • Visual Studio visualizes the directives that are specified at the project or file level. However, it does not show any of the $SET statements that are in the code. This could lead to unexpected behavior, if your source code has any Compiler directives set with $SET statements that are different to the one set using the GUI properties.

Avoid external files with Compiler directives

Micro Focus recommends that you avoid using any external files (such as .dir) to store any required Compiler directives. The reasons for this are:

  • There is no easy way to see the contents of a .dir file from within Visual Studio. In scenarios where there are multiple projects, it is not easy to see which of the projects use a directives file.
  • A mix of directives specified as both projects' properties and in a .dir file could lead to confusion.

Specify properties for files opened using Open Folder

If you load your source files using the Open Folder feature, do not edit the .json that the feature creates within the file location. Instead, use the workspace, folder or file GUI property pages to specify any Compiler directives.

Within these GUI property pages, avoid manually typing a Compiler directive in the Additional Directives field if the corresponding GUI property already exists.