I am very new to netstandard and I just encountered exception when I want to run a debug mode a .Net Framework (console) which has reference to a netstandard library.
So I later figured out that the exception would be gone if I installed the System.IO.Ports from nuget onto the .Net Framework Project. But this library has already installed onto netstandard project.
So I highly doubt that if I need to install all the libraries which netstandard project required if I uses the netstandard project from another .net framework project.
I must be missing something, can anyone who is familiar with netstandard give me some insights about it.
your inputs are much appreciated !
Open up the .csproj file for the .Net Framework project that is hosting the .Net standard library and add this line within the first <PropertyGroup>
like this to change the restore style:
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
Check out this article by Scott Hanselman about the cause of the issue and the fix.
From the article:
The "full" Framework projects are using the older .csproj format and by default, they use package.config to manage dependencies. The newer projects can reference Packages as first-class references. So we need to tell ALL projects in this solution to manage and restore their packages as "PackageReferences."
EDIT:
This fix worked perfectly for me on a new project. When I apply it to the csproj before I restore packages in that new project, nuget gets the correct references.
When applying this to an existing project, it doesn't work. The libraries that are referenced inside the .net standard class library are not pulled by nuget and therefore, it would still throw the same error.
To fix it try this:
<Reference Include="yournetstandardlibrary, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\yournetstandardlibrary\lib\netstandard2.0\.dll</HintPath> </Reference>
<ItemGroup> <PackageReference Include="yournetstandardlibrary"> <Version>1.0.1</Version> </PackageReference> </ItemGroup>
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