1

Can you add a reference to a .Net Core assembly without creating a nuget package or adding a reference to the project ?

Steef
  • 569
  • 5
  • 21
  • Can you give an example of the case when this would be necessary? – Alexey Andrushkevich Jan 13 '21 at 09:36
  • Yes, I am working on NopCommerce which has a plugin system in where you can reference plugins by adding a reference to the project, but when i do so it is failing, so I want to try to add an assembly to the reference of that project to see what happens in that case. – Steef Jan 13 '21 at 13:01

1 Answers1

3

Yes, it is possible, if you add something like this to your csproj:

<ItemGroup>
  <Reference Include="RequiredAssembly">
    <HintPath>path\to\RequiredAssembly.dll</HintPath>
  </Reference>
</ItemGroup>

Be sure that, when building, it is possible to resolve the reference, since compilation errors only when using in the code. The build prints a warning like this, in such a case:

warning MSB3245: Could not resolve this reference. Could not locate the assembly "RequiredAssembly". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

Two good answers related with this:

However, you could still use a nuget package, even locally - setup a local nuget repository and manage your dependencies using it. It is pretty straightforward :)

These two links walk through the process:

nunohpinheiro
  • 2,169
  • 13
  • 14