I have a DotNetCore 2.1 Web App (just created it today from the VS 2017 scaffold). This solution also includes a DotNet Core 2.1 Library DLL project. The solution builds ok.
I have another (brand new) DotNetCore 2.1 Web App that wants to use the Library DLL. But when I try to add a new reference (on the Browse tab), it complains:
One or more errors occurred.
The reference is invalid or unsupported.
Any suggestions?
(Curiously, the DLL doesn't show up directly under the Bin\Debug folder like it does in classic .Net; It's under Bin\Debug\netcoreapp2.1)
I got this error after I moved some of my code repos around and suddenly my .NET Core 2.1 console app wouldn't recognize a .NET 4.5 DLL anymore when I added it.
Turned out that although the broken reference did not show in the solution explorer, the project file still contained it, along with the now broken HintPath to the DLL's old location. Manually removing this reference from the project file solved it.
Go into your .csproj and make sure the <Reference Include=...
is pointing to the correct directory.
For example, my references were pointing to the bin\Debug
path of another project when the only build that was actually there was the bin\Release
When you create a new project from the Visual Studio 2017 Class Library (.NET Core)
template, the csproj file contains:
<TargetFramework>netcoreapp2.1</TargetFramework>
Since this is a library, it (apparently) needs to target netstandard2.0
. (BTW, creating a library project from the dotnet
command line command correctly targets netstandard2.0
. Go figure.)
So changing the line in the library's csproj file to
<TargetFramework>netstandard2.0</TargetFramework>
and rebuilding the library now allows me to reference the library from the DotNet Core 2.1 (netcoreapp2.1
) application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With