How to add external assembly (.dll) to .NET Core 2.0 on Visual Studio Code

After some research I managed to get it working.

  1. Open your .csproj file

  2. Below </PropertyGroup> tag, add

<ItemGroup>
  <Reference Include="Your dll file name">
    <HintPath>Your dll file name.dll</HintPath>
    <SpecificVersion>False</SpecificVersion> 
    <!-- You may set it to true if your dll has a specific version -->
  </Reference>
</ItemGroup>
  1. Move the dll to the root folder of your project (where Program.cs is)

  2. Navigate to the root folder of your project using console/terminal and execute dotnet restore to import all the references

  3. Then, execute dotnet run

  4. Do not remove the dll from your root folder. If you do, you will receive the following error:

error CS0246: The type or namespace name 'Your dll File' could not be found (are you missing a using directive or an assembly reference?)


Right click project Add existing item > select path to .dll After added dll in project,right click .dll

build-action = Content, Copy-to-output-dir = Always/ or if newer