1

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

2
  • Can you give an example of the case when this would be necessary? Commented Jan 13, 2021 at 9: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. Commented Jan 13, 2021 at 13:01

1 Answer 1

4

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:

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.