Skip to main content

I've not ventured back to VS Code for a fair while, so have some questions and things that need clarification.

My understanding for searching through the community posts what when you start vs code (such as from the command line 'code . ') if an existing .cblproj file exists it is read and the compile directives used, SQL directives and copybook paths.

I seem to find this isn't true. To locate my copybooks I ended up creating a cobol.dir file and used COPYPATH(C:\\MF\\COPY;C:\\MF\\CPB)

I also configured tasks.json:


{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "COBOL-MSBuild",
            "command": "C:\\\\Program Files\\\\Microsoft Visual Studio\\\\2022\\\\Enterprise\\\\MSBuild\\\\Current\\\\Bin\\\\amd64\\\\MSBuild.exe",
            "buildTarget": "${workspacefolder}/MyProg.cblproj",
            "problemMatcher": [
                "$COBOLMSBuild"
            ],
            "group": "build",
            "label": "COBOL: MSBuild (Compile Current File)",
            "compileSource": {
  "isDefault": true
             }
        }
    ]
}


But pressing CTRL + Shift +B resulted in:
The term 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\MSBuild\\Current\\Bin\\amd64\\MSBuild.exe",' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

msbuild.exe is at that location and its folder is also on the environment PATH.

In Visual Studio:

EXEC SQL INCLUDE SQLCA END-EXEC.

EXEC SQL BEGIN DECLARE SECTION END-EXEC.
Would bring in the copybook SQLA.CPY which is in the path of COPYPATH, this doesn't seem to happen in VS Code?
The above seems to assume the source code is NATIVE and says the SQL(DMAN) directive option isn't supported, when I have defined SQL(ADO) in the directives.mf.
Even if I set this in the source code it seems to still assume its native COBOL rather than COBOL .NET

      $set ILGEN
      $set ilusing "System"
If I want to use VS Code as a primary editor, what is the best way to add dependencies (other COBOL DLL's)  as well as Micro Focus nuget packages?






------------------------------
Neil Hayes

------------------------------

I've not ventured back to VS Code for a fair while, so have some questions and things that need clarification.

My understanding for searching through the community posts what when you start vs code (such as from the command line 'code . ') if an existing .cblproj file exists it is read and the compile directives used, SQL directives and copybook paths.

I seem to find this isn't true. To locate my copybooks I ended up creating a cobol.dir file and used COPYPATH(C:\\MF\\COPY;C:\\MF\\CPB)

I also configured tasks.json:


{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "COBOL-MSBuild",
            "command": "C:\\\\Program Files\\\\Microsoft Visual Studio\\\\2022\\\\Enterprise\\\\MSBuild\\\\Current\\\\Bin\\\\amd64\\\\MSBuild.exe",
            "buildTarget": "${workspacefolder}/MyProg.cblproj",
            "problemMatcher": [
                "$COBOLMSBuild"
            ],
            "group": "build",
            "label": "COBOL: MSBuild (Compile Current File)",
            "compileSource": {
  "isDefault": true
             }
        }
    ]
}


But pressing CTRL + Shift +B resulted in:
The term 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\MSBuild\\Current\\Bin\\amd64\\MSBuild.exe",' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

msbuild.exe is at that location and its folder is also on the environment PATH.

In Visual Studio:

EXEC SQL INCLUDE SQLCA END-EXEC.

EXEC SQL BEGIN DECLARE SECTION END-EXEC.
Would bring in the copybook SQLA.CPY which is in the path of COPYPATH, this doesn't seem to happen in VS Code?
The above seems to assume the source code is NATIVE and says the SQL(DMAN) directive option isn't supported, when I have defined SQL(ADO) in the directives.mf.
Even if I set this in the source code it seems to still assume its native COBOL rather than COBOL .NET

      $set ILGEN
      $set ilusing "System"
If I want to use VS Code as a primary editor, what is the best way to add dependencies (other COBOL DLL's)  as well as Micro Focus nuget packages?






------------------------------
Neil Hayes

------------------------------

Hi Neil,

If you have copied that error exactly as it appears in the console it appears to have a trailing quote character for some reason. I noticed that  the code block in the documentation does contain an incorrect quote character so if you copied and pasted maybe that is the problem. If not, you could try commenting out the 'command'  argument as the code should attempt to locate msbuild if you haven't specified it the command.

Without an example it difficult to determine what the problem is with the editor not picking up directives but I will try to reproduce it.

Gael 



------------------------------
Gael Wilson
Lead Software Engineer
Rocket Forum Shared Account
Newbury United Kingdom
------------------------------

Hi Neil,

If you have copied that error exactly as it appears in the console it appears to have a trailing quote character for some reason. I noticed that  the code block in the documentation does contain an incorrect quote character so if you copied and pasted maybe that is the problem. If not, you could try commenting out the 'command'  argument as the code should attempt to locate msbuild if you haven't specified it the command.

Without an example it difficult to determine what the problem is with the editor not picking up directives but I will try to reproduce it.

Gael 



------------------------------
Gael Wilson
Lead Software Engineer
Rocket Forum Shared Account
Newbury United Kingdom
------------------------------

@Neil Hayes

If your project is a .NET project you need to enable the following setting to allow the directives to be picked up:

 



------------------------------
Gael Wilson
Lead Software Engineer
Rocket Forum Shared Account
Newbury United Kingdom
------------------------------

@Neil Hayes

If your project is a .NET project you need to enable the following setting to allow the directives to be picked up:

 



------------------------------
Gael Wilson
Lead Software Engineer
Rocket Forum Shared Account
Newbury United Kingdom
------------------------------

Thank you Gael, one step forward - now enabled & MSBUILD path sorted.


Now it starts to read MyProg.cblproj (Created in Visual Studio using Visual COBOL and ser to use .NET Core 8.0)

Now cannot resolve the SDK "MicroFocus.Sdk".

The project file:

<Project Sdk="MicroFocus.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <EnableDefaultItems>false</EnableDefaultItems>
    <MFDependencyPaths>C:\\COPY;C:\\CPB</MFDependencyPaths>
    <SQLDirectives>SQL(DBMAN=ADO) SQL(BEHAVIOR=UNOPTIMIZED) SQL(TARGETDB=MSSQLSERVER) SQL(AUTOCOMMIT)</SQLDirectives>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <PlatformTarget>x64</PlatformTarget>
    <AdditionalDirectives>DIR"VC64.DIR" P64</AdditionalDirectives>
    <OutputPath>bin\\Debug\\</OutputPath>
    <SourceFormat>Fixed</SourceFormat>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="MyProg.cbl" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="MicroFocus.COBOL.SqlCLR.Runtime" Version="4.100.600379295" />
  </ItemGroup>
</Project>

The error stack my VS Code.

Error: Starting server failed

at p.$start (c:\\Users\\{Neil}\\.vscode\\extensions\\rocketsoftware.rocket-cobol-2.0.9\\dist\\extension.js:1:527954)
at async p.sendNotification (c:\\Users\\{Neil}\\.vscode\\extensions\\rocketsoftware.rocket-cobol-2.0.9\\dist\\extension.js:1:513387)
at async didChangeConfiguration (c:\\Users\\{Neil}\\.vscode\\extensions\\rocketsoftware.rocket-cobol-2.0.9\\dist\\extension.js:1:227072)
[Information - 11:39:46 AM] Rocket COBOL Language Server is starting
[Trace - 11:39:46 AM] Received response 'shutdown - (12)' in 223ms.
[Trace - 11:39:46 AM] Sending notification 'exit'.
[Trace - 11:39:53 AM] Sending request 'initialize - (0)'.
[Trace - 11:39:54 AM] Received notification 'window/logMessage'.
[Error - 11:39:54 AM] c:\\git-repo\\VSCode-Test\\MyProg.cblproj : error : Could not resolve SDK "MicroFocus.Sdk". Exactly one of the probing messages below indicates why we could not resolve the SDK. Investigate and resolve that message to correctly specify the SDK.
c:\\git-repo\\VSCode-Test\\MyProg.cblproj : error :   SDK resolver "Microsoft.DotNet.MSBuildWorkloadSdkResolver" returned null.
c:\\git-repo\\VSCode-Test\\MyProg.cblproj : error :   The NuGetSdkResolver did not resolve this SDK because there was no version specified in the project or global.json.
[Trace - 11:39:54 AM] Received notification 'window/logMessage'.
[Error - 11:39:54 AM] c:\\git-repo\\VSCode-Test\\MyProg.cblproj : error MSB4236: The SDK 'MicroFocus.Sdk' specified could not be found.
[Trace - 11:39:54 AM] Received notification 'window/logMessage'.
[Error - 11:39:54 AM] The SDK 'MicroFocus.Sdk' specified could not be found.  c:\\git-repo\\VSCode-Test\\MyProg.cblproj
[Trace - 11:39:54 AM] Received response 'initialize - (0)' in 1165ms.
[Information - 11:39:54 AM] Rocket COBOL Language Server is running
[Trace - 11:39:54 AM] Sending notification 'initialized'.
[Trace - 11:39:54 AM] Sending notification 'textDocument/didOpen'.
[Trace - 11:39:54 AM] Received request 'client/registerCapability - (2)'.
[Trace - 11:39:54 AM] Sending response 'client/registerCapability - (2)'. Processing request took 1ms
[Trace - 11:39:56 AM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 11:39:56 AM] Received notification 'mf/textDocument/publishParseData'.
This doesn't stop this.



Neil


------------------------------
Neil Hayes
Software Development Specialist
Syspro (Pty) Ltd
Rivonia GB
------------------------------

Thank you Gael, one step forward - now enabled & MSBUILD path sorted.


Now it starts to read MyProg.cblproj (Created in Visual Studio using Visual COBOL and ser to use .NET Core 8.0)

Now cannot resolve the SDK "MicroFocus.Sdk".

The project file:

<Project Sdk="MicroFocus.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <EnableDefaultItems>false</EnableDefaultItems>
    <MFDependencyPaths>C:\\COPY;C:\\CPB</MFDependencyPaths>
    <SQLDirectives>SQL(DBMAN=ADO) SQL(BEHAVIOR=UNOPTIMIZED) SQL(TARGETDB=MSSQLSERVER) SQL(AUTOCOMMIT)</SQLDirectives>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <PlatformTarget>x64</PlatformTarget>
    <AdditionalDirectives>DIR"VC64.DIR" P64</AdditionalDirectives>
    <OutputPath>bin\\Debug\\</OutputPath>
    <SourceFormat>Fixed</SourceFormat>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="MyProg.cbl" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="MicroFocus.COBOL.SqlCLR.Runtime" Version="4.100.600379295" />
  </ItemGroup>
</Project>

The error stack my VS Code.

Error: Starting server failed

at p.$start (c:\\Users\\{Neil}\\.vscode\\extensions\\rocketsoftware.rocket-cobol-2.0.9\\dist\\extension.js:1:527954)
at async p.sendNotification (c:\\Users\\{Neil}\\.vscode\\extensions\\rocketsoftware.rocket-cobol-2.0.9\\dist\\extension.js:1:513387)
at async didChangeConfiguration (c:\\Users\\{Neil}\\.vscode\\extensions\\rocketsoftware.rocket-cobol-2.0.9\\dist\\extension.js:1:227072)
[Information - 11:39:46 AM] Rocket COBOL Language Server is starting
[Trace - 11:39:46 AM] Received response 'shutdown - (12)' in 223ms.
[Trace - 11:39:46 AM] Sending notification 'exit'.
[Trace - 11:39:53 AM] Sending request 'initialize - (0)'.
[Trace - 11:39:54 AM] Received notification 'window/logMessage'.
[Error - 11:39:54 AM] c:\\git-repo\\VSCode-Test\\MyProg.cblproj : error : Could not resolve SDK "MicroFocus.Sdk". Exactly one of the probing messages below indicates why we could not resolve the SDK. Investigate and resolve that message to correctly specify the SDK.
c:\\git-repo\\VSCode-Test\\MyProg.cblproj : error :   SDK resolver "Microsoft.DotNet.MSBuildWorkloadSdkResolver" returned null.
c:\\git-repo\\VSCode-Test\\MyProg.cblproj : error :   The NuGetSdkResolver did not resolve this SDK because there was no version specified in the project or global.json.
[Trace - 11:39:54 AM] Received notification 'window/logMessage'.
[Error - 11:39:54 AM] c:\\git-repo\\VSCode-Test\\MyProg.cblproj : error MSB4236: The SDK 'MicroFocus.Sdk' specified could not be found.
[Trace - 11:39:54 AM] Received notification 'window/logMessage'.
[Error - 11:39:54 AM] The SDK 'MicroFocus.Sdk' specified could not be found.  c:\\git-repo\\VSCode-Test\\MyProg.cblproj
[Trace - 11:39:54 AM] Received response 'initialize - (0)' in 1165ms.
[Information - 11:39:54 AM] Rocket COBOL Language Server is running
[Trace - 11:39:54 AM] Sending notification 'initialized'.
[Trace - 11:39:54 AM] Sending notification 'textDocument/didOpen'.
[Trace - 11:39:54 AM] Received request 'client/registerCapability - (2)'.
[Trace - 11:39:54 AM] Sending response 'client/registerCapability - (2)'. Processing request took 1ms
[Trace - 11:39:56 AM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 11:39:56 AM] Received notification 'mf/textDocument/publishParseData'.
This doesn't stop this.



Neil


------------------------------
Neil Hayes
Software Development Specialist
Syspro (Pty) Ltd
Rivonia GB
------------------------------

I replied directly but I'll also include the detail here in case anybody else encounters a similar problem.

The error information would suggest that the global.json is missing, and that should have been created when the project was created. For a project created with a 10.0 product it should contain 

{
    "msbuild-sdks": {
        "MicroFocus.Sdk": "2.2.0"
    }
}

You also need to ensure that the product's NuGetPackages folder is registered as a package source

 dotnet nuget list source 

 Will let you see if its there. If not, follow these instructions from the Visual Studio docs

 dotnet nuget add source <product-install-dir>/NuGetPackages --name <source-name>

where <product-install-dir> is the directory in which your Rocket product is installed, and <source-name> is the name given to the source in the repository.

If you run the dotnet nuget list source command again, the new source is listed.



------------------------------
Gael Wilson
Lead Software Engineer
Rocket Forum Shared Account
Newbury United Kingdom
------------------------------