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.
- To add a third-party library to the Visual Studio Code project
- Copy the .NET assembly for the library to theProjectFiles/NetSolutionproject folder.
- From the main toolbar, selectOpen .NET Solution.The default external code editor opens.TIP: We recommend using Microsoft Visual Studio 2022 or Microsoft Visual Studio Code as the default code editor. Some development assistance features may not be available when using a different code editor.
- In Visual Studio Code, open theCSPROJproject file.
- Add the following<Reference>element as a child of the<ItemGroup>element.<Reference Include="library"> <HintPath>path</HintPath> <Private>False</Private> </Reference>
- library
- The library that you want to add. For example:MyLibrary
- path
- The path to the library from 1. For example:..\MyLibrary.dll
<ItemGroup> <Reference Include="MyLibrary"> <HintPath>..\MyLibrary.dll</HintPath> <Private>False</Private> </Reference> <!-- The rest of the code --> </ItemGroup> - Save theCSPROJfile.
Provide Feedback