I have a netstandard2 class library project, which contains some Roslyn analyzers. I'm trying to create NuGet package using a .nuspec
and msbuild \t:pack
command. All working find and i can create the nuget package easily. But as soon as i register my analyzer afteer installing the package on another project i get the following error for each analyzer in my package :
An instance of analyzer [AnalyzerName] cannot be created from [AnalyzerDllFile]: Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified
Here is the .nuspec file :
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>[PackageId]</id>
<version>1.0.9</version>
<authors>Ali</authors>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>test</description>
<!-- Solution A i found -->
<dependencies>
<group targetFramework="net46">
<dependency id="NETStandard.Library" version="2.0.0" />
</group>
</dependencies>
<!-- Solution B i found -->
<references>
<reference file="netstandard.dll" />
</references>
</metadata>
<files>
<file src="bin\Debug\netstandard2.0\[PackageName].dll" target="analyzers\dotnet\cs" />
<file src="tools\*.ps1" target="tools\" />
</files>
</package>
I tried many solution that i found on internet but seems I'm missing something else
FYI both project are targeting to .Net Framework 4.6.1