Add a third-party library to the Visual Studio Code project

Add a third-party .NET library by editing the
CSPROJ
project file.
Prerequisites
Set Visual Studio Code as the default external code editor. See Set the default code editor.
  1. To add a third-party library to the Visual Studio Code project
  2. Copy the .NET assembly for the library to the
    ProjectFiles/NetSolution
    project folder.
  3. From the main toolbar, select
    Open .NET Solution
    .
    The default external code editor opens.
    TIP: Rockwell Automation recommends using
    Visual Studio®
    2022 or
    Visual Studio Code
    as the default code editor. Some development assistance features may not be available when using a different code editor.
  4. In Visual Studio Code, open the
    CSPROJ
    project file.
  5. Add the following
    <Reference>
    element as a child of the
    <ItemGroup>
    element.
    <Reference Include="
    library
    "> <HintPath>
    path
    </HintPath> </Reference>
    library
    The library that you want to add. For example:
    MyLibrary
    path
    The path to the library from 1. For example:
    "MyLibrary.dll"
    . Include the path to the library in the project directory to allow the project .NET solution to be compiled on different devices. In this way, the library is correctly referenced whenever acessing the project from other devices.
    <ItemGroup> <Reference Include="MyLibrary"> <HintPath>MyLibrary.dll</HintPath> </Reference> <!-- The rest of the code --> </ItemGroup>
    If the library is located in a different folder than the one set by default
    ProjectFiles/NetSolution
    , provide a path accordingly, for example:
    <Reference Include="MyLibrary"> <HintPath>../SampleFolder/MyLibrary.dll</HintPath> </Reference>
  6. Save the
    CSPROJ
    file.
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.