Highlighted
Honored Contributor.
Honored Contributor.
953 views

Question or Issue with generated Directives file - Managed Winforms application

Either there is an issue with generating the dir file ... or I have a question related to the intended behavior when generating the dir file and the subsequent use of the COBOL command to generate the executable, which I need confirmed.

Scenarios:

1. Using Visual Studio 2013 and Visual COBOL 2.2, create a new Win forms project (in my example, I called it TestDir2).

After initial creation, there will be a Form1.cbl and a Form1.Designer.cbl, as shown in the VS solution explorer pane.

2. Go to the project properties COBOL tab and click-check the "Generate directives file" option.  Build / Rebuild the project and examine the generated directives file.  Notice especially the ILSOURCE entries - which ones are there and which ones are not there (the ILSOURCE for Form1.cbl is not there but this (is? / may be?) intended - see the next step).  For your convenience, move or copy the .dir file to the folder with the source code, in preparation for the next step.

3. Test the generated .dir file by using the VS 2013 Command Line (32-bit) and position to the appropriate folder and issue the following command:

COBOL Form1.cbl use(TestDir2.dir);

(note that the semicolon above is important)

This will/should generate / regenerate the Exe (or DLL) as appropriate.  So far, so good.

4. Now, go back into the project in Visual Studio, and using Solution Explorer, add a new class to the project (just use the default class name:  "Class1.cbl").  Now rebuild the project and examine the newly-generated dir file, especially the ILSOURCE entries - which ones are there and which ones are not there (the ILSOURCE for Form1.cbl IS there but the ILSOURCE for Class1.cbl is NOT there.  But this (is? / may be?) intended - see the next step).

5. Now move or copy the new dir file to the appropriate folder for convenience and test the generated .dir file by using the VS 2013 Command Line (32-bit) and position to the appropriate folder and issue the following command:

COBOL Class1.cbl use(TestDir2.dir);

(note that the semicolon above is important)

This will/should generate / regenerate the Exe (or DLL) as appropriate.

6. Now delete "Class1.cbl" in Solution Explorer and repeat steps 4 and 5 adding a class named "xClass1.cbl" (instead of "Class1.cbl").  Notice the dir file - you will have to now issue the following to test the generated dir file:

COBOL Form1.cbl use(TestDir2.dir);

(*NOTE* Do not take a shortcut and just rename Class1.cbl to xClass1.cbl as it appears that renaming does not currently take care of all the behind-the-scenes refactoring that is necessary.)

The point (issue? or question?) is this:  The Visual-Studio-generated dir file has ILSOURCE entries for each .cbl class of the project, except for the first one appearing alphabetically.  This is intended (?), as the typical next step is to use the VS command line prompt and the COBOL command which syntactically must mention a .cbl and this should be the alphabetically first class (as the dir file has ILSOURCE entries for all the other classes, except this first one).

Please confirm:  Is the above an issue or is this the intended behavior?

Also, is there any way to generate the dir from the command line rather than from Visual Studio?

0 Likes
1 Reply
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Question or Issue with generated Directives file - Managed Winforms application

The generated dir file is really just an informative file that will show you which directives are used when building the project using Visual Studio. You can use this .dir file anyway that you see fit but it is really not meant to be used as is when building from the command line.

If you wish to use all project settings then the best way to build your application from the command line is to use the msbuild.exe utility from Microsoft that is provided as part of Visual Studio.

If you have a full version of Visual Studio installed then you can open up a Visual Studio Developer command prompt from the Visual Studio-->Tools group under the Start menu and navigate to your project folder and run:

msbuild projname.cblproj

or

msbuild solname.sln

or msbuild

and it will automatically build your project or solution using the specified file name. If you run msbuild without a file name it will search for a file with the .sln extension and build it.

If you are using the Visual Studio shell then you won't have a Visual Studio command prompt and then you just need to add the full path name to the msbuild command when running it from a Visual COBOL command prompt:

The msbuild.exe is part of the .NET Framework and can be located here.

C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe

Currently only the 32-bit version of msbuild is supported.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.