Upgrading .NET project files from earlier versions of Visual COBOL

Upgrading projects from releases earlier than 7.0

You cannot use dotnet commands to work with .NET projects (previously .NET Core projects) that were created using a version of Visual COBOL before 7.0. Instead, you can either continue to use such projects using the Visual Studio IDE and the msbuild command, or upgrade them in order to be able to use the dotnet commands.

To upgrade a pre-7.0 project file so that you can use the project with dotnet commands you need to do the following:

  1. Modify the project (.cblproj) file as follows:
    1. Change the first line from:
      <Project Sdk="Microsoft.NET.Sdk">
      to:
      <Project Sdk="MicroFocus.Sdk"
    2. Delete the two lines that start with the following:
      <LanguageTargets
  2. Create a global.json file in the project folder to define the version of the Micro Focus project SDK to use. For example:
    {
        "msbuild-sdks": {
            "MicroFocus.Sdk": "1.0.16"
        }
    }

    For more information on modifying your .cblproj and global.json files to do this, see Microsoft: How to: Use MSBuild project SDKs.

Upgrading existing projects to release 8.0

Visual Studio 2022 requires that the global.json file of .NET 6 projects is placed at the directory level of the solution file in order for the project to successfully open and build. In previous versions of Visual Studio, the file could be located in subfolders of the solution such as in the project folder.

This can affect existing .NET Core 3.1 COBOL projects that you upgrade from a prior release if the global.json file is not at the directory level of the solution file. It also affects .NET 6 COBOL projects that you add to an existing solution.

In these cases, you might receive the following error message if building from the MSBuild command line, or in the IDE Output window if the project fails to load:

"The SDK 'MicroFocus.Sdk' specified could not be found"

To work around this issue, you need to move the global.json file to the directory level of the solution file.

New .NET 6 COBOL solutions and projects created with VS2022 create the global.json file in the required location.