0

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

Ali Foroughi
  • 4,540
  • 7
  • 42
  • 66
  • Ensure your VS2017 version is up to date, I think you need at least 15.5 And always favor targeting 4.7.1 whenever you do anything .NETStandard. – Hans Passant Mar 20 '18 at 09:48
  • @HansPassant I`ve installed 15.6.1 – Ali Foroughi Mar 20 '18 at 09:50
  • Even I got exactly same issue even though I have .Net 4.7.1 installed in my machine and I have the latest VS2017 installed v15.6.6. https://github.com/dotnet/roslyn/issues/26169 – Bachu Apr 16 '18 at 11:16

0 Answers0