microsoft / RoslynClrHeapAllocationAnalyzer

Roslyn based C# heap allocation diagnostic analyzer that can detect explicit and many implicit allocations like boxing, display classes a.k.a closures, implicit delegate creations, etc.
Apache License 2.0
645 stars 61 forks source link

Failed to add reference. The package 'System.Numerics.Vectors' tried to add a framework reference to 'System.Numerics' which was not found in the GAC. This is possibly a bug in the package. #82

Open jessehouwing opened 4 years ago

jessehouwing commented 4 years ago

Installation as nuget fails in Visual Studio 2019 16.7.0-pre2.0

Attempting to gather dependency information for package 'ClrHeapAllocationAnalyzer.3.0.0' with respect to project 'Core\DAL\Nextens.DataAccess.SolrDataPush', targeting '.NETFramework,Version=v4.8'
Gathering dependency information took 161 ms
Attempting to resolve dependencies for package 'ClrHeapAllocationAnalyzer.3.0.0' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'ClrHeapAllocationAnalyzer.3.0.0'
Resolved actions to install package 'ClrHeapAllocationAnalyzer.3.0.0'
Package 'Microsoft.CodeAnalysis.Analyzers.2.9.6' already exists in folder 'C:\TFS\Base2\Solutions\packages'
Added package 'Microsoft.CodeAnalysis.Analyzers.2.9.6' to 'packages.config'
Executing script file 'C:\TFS\Base2\Solutions\packages\Microsoft.CodeAnalysis.Analyzers.2.9.6\tools\install.ps1'...
Successfully installed 'Microsoft.CodeAnalysis.Analyzers 2.9.6' to XXXXX
Package 'System.Buffers.4.4.0' already exists in folder 'C:\TFS\Base2\Solutions\packages'
Added package 'System.Buffers.4.4.0' to 'packages.config'
Successfully installed 'System.Buffers 4.4.0' to XXXXX
Package 'System.Collections.Immutable.1.5.0' already exists in folder 'C:\TFS\Base2\Solutions\packages'
Added package 'System.Collections.Immutable.1.5.0' to 'packages.config'
Successfully installed 'System.Collections.Immutable 1.5.0' to XXXXX
Package 'System.Composition.AttributedModel.1.0.31' already exists in folder 'C:\TFS\Base2\Solutions\packages'
Added package 'System.Composition.AttributedModel.1.0.31' to 'packages.config'
Successfully installed 'System.Composition.AttributedModel 1.0.31' to Nextens.Modules.Dashboard.Content
Package 'System.Composition.Convention.1.0.31' already exists in folder 'C:\TFS\Base2\Solutions\packages'
Added package 'System.Composition.Convention.1.0.31' to 'packages.config'
Successfully installed 'System.Composition.Convention 1.0.31' to XXXXX
Package 'System.Composition.Runtime.1.0.31' already exists in folder 'C:\TFS\Base2\Solutions\packages'
Added package 'System.Composition.Runtime.1.0.31' to 'packages.config'
Successfully installed 'System.Composition.Runtime 1.0.31' to XXXXX
Package 'System.Composition.Hosting.1.0.31' already exists in folder 'C:\TFS\Base2\Solutions\packages'
Added package 'System.Composition.Hosting.1.0.31' to 'packages.config'
Successfully installed 'System.Composition.Hosting 1.0.31' to XXXXX
Package 'System.Composition.TypedParts.1.0.31' already exists in folder 'C:\TFS\Base2\Solutions\packages'
Added package 'System.Composition.TypedParts.1.0.31' to 'packages.config'
Successfully installed 'System.Composition.TypedParts 1.0.31' to XXXXX
Adding package 'System.Composition.1.0.31', which only has dependencies, to project 'XXXXX'.
Package 'System.Composition.1.0.31' already exists in folder 'C:\TFS\Base2\Solutions\packages'
Added package 'System.Composition.1.0.31' to 'packages.config'
Successfully installed 'System.Composition 1.0.31' to XXXXX
Package 'System.Numerics.Vectors.4.4.0' already exists in folder 'C:\TFS\Base2\Solutions\packages'
Install failed. Rolling back...
Package 'System.Numerics.Vectors.4.4.0' does not exist in project 'XXXXX'
Removed package 'System.Composition.1.0.31 : System.Composition.AttributedModel [1.0.31, ), System.Composition.Convention [1.0.31, ), System.Composition.Hosting [1.0.31, ), System.Composition.Runtime [1.0.31, ), System.Composition.TypedParts [1.0.31, )' from 'packages.config'
Removed package 'System.Composition.TypedParts.1.0.31 : System.Composition.AttributedModel [1.0.31, ), System.Composition.Hosting [1.0.31, ), System.Composition.Runtime [1.0.31, )' from 'packages.config'
Removed package 'System.Composition.Hosting.1.0.31 : System.Composition.Runtime [1.0.31, )' from 'packages.config'
Removed package 'System.Composition.Runtime.1.0.31' from 'packages.config'
Removed package 'System.Composition.Convention.1.0.31 : System.Composition.AttributedModel [1.0.31, )' from 'packages.config'
Removed package 'System.Composition.AttributedModel.1.0.31' from 'packages.config'
Removed package 'System.Collections.Immutable.1.5.0' from 'packages.config'
Removed package 'System.Buffers.4.4.0' from 'packages.config'
Executing script file 'C:\TFS\Base2\Solutions\packages\Microsoft.CodeAnalysis.Analyzers.2.9.6\tools\uninstall.ps1'...
Removed package 'Microsoft.CodeAnalysis.Analyzers.2.9.6' from 'packages.config'
Executing nuget actions took 13.64 sec
Failed to add reference. The package 'System.Numerics.Vectors' tried to add a framework reference to 'System.Numerics' which was not found in the GAC. This is possibly a bug in the package. Please contact the package owners for assistance.
  Object reference not set to an instance of an object.
Time Elapsed: 00:00:35.4033895
========== Finished ==========

It seems specific to this project:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="16.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="..\..\..\..\Solutions\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.3.0.0\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props" Condition="Exists('..\..\..\..\Solutions\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.3.0.0\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props')" />
  <Import Project="..\..\..\..\Solutions\packages\Microsoft.NetFramework.Analyzers.3.0.0\build\Microsoft.NetFramework.Analyzers.props" Condition="Exists('..\..\..\..\Solutions\packages\Microsoft.NetFramework.Analyzers.3.0.0\build\Microsoft.NetFramework.Analyzers.props')" />
  <Import Project="..\..\..\..\Solutions\packages\Microsoft.NetCore.Analyzers.3.0.0\build\Microsoft.NetCore.Analyzers.props" Condition="Exists('..\..\..\..\Solutions\packages\Microsoft.NetCore.Analyzers.3.0.0\build\Microsoft.NetCore.Analyzers.props')" />
  <Import Project="..\..\..\..\Solutions\packages\Microsoft.CodeQuality.Analyzers.3.0.0\build\Microsoft.CodeQuality.Analyzers.props" Condition="Exists('..\..\..\..\Solutions\packages\Microsoft.CodeQuality.Analyzers.3.0.0\build\Microsoft.CodeQuality.Analyzers.props')" />
  <Import Project="..\..\..\..\Solutions\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.3.0.0\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props" Condition="Exists('..\..\..\..\Solutions\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.3.0.0\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props')" />
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{A5C40632-EF2D-4518-A7BB-1FBECAAB33B5}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>XXXXX</RootNamespace>
    <AssemblyName>XXXXX</AssemblyName>
    <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <SccProjectName>SAK</SccProjectName>
    <SccLocalPath>SAK</SccLocalPath>
    <SccAuxPath>SAK</SccAuxPath>
    <SccProvider>SAK</SccProvider>
    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\..\Solutions\</SolutionDir>
    <RestorePackages>true</RestorePackages>
    <TargetFrameworkProfile />
    <NuGetPackageImportStamp>
    </NuGetPackageImportStamp>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup>
    <SignAssembly>false</SignAssembly>
  </PropertyGroup>
  <PropertyGroup>
    <AssemblyOriginatorKeyFile>
    </AssemblyOriginatorKeyFile>
  </PropertyGroup>
  <ItemGroup>
  </ItemGroup>
  <ItemGroup>
    <None Include="packages.config" />
  </ItemGroup>
  <ItemGroup>
  </ItemGroup>
  <ItemGroup>
    <Analyzer Include="..\..\..\..\Solutions\packages\AsyncFixer.1.3.0\analyzers\dotnet\cs\AsyncFixer.dll" />
    <Analyzer Include="..\..\..\..\Solutions\packages\Microsoft.CodeAnalysis.Analyzers.2.9.6\analyzers\dotnet\cs\Microsoft.CodeAnalysis.Analyzers.dll" />
    <Analyzer Include="..\..\..\..\Solutions\packages\Microsoft.CodeAnalysis.Analyzers.2.9.6\analyzers\dotnet\cs\Microsoft.CodeAnalysis.Analyzers.dll" />
    <Analyzer Include="..\..\..\..\Solutions\packages\Microsoft.CodeAnalysis.Analyzers.2.9.6\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll" />
    <Analyzer Include="..\..\..\..\Solutions\packages\Microsoft.CodeAnalysis.Analyzers.2.9.6\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll" />
    <Analyzer Include="..\..\..\..\Solutions\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.3.0.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.VersionCheckAnalyzer.resources.dll" />
    <Analyzer Include="..\..\..\..\Solutions\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.3.0.0\analyzers\dotnet\Microsoft.CodeAnalysis.VersionCheckAnalyzer.dll" />
    <Analyzer Include="..\..\..\..\Solutions\packages\Microsoft.CodeQuality.Analyzers.3.0.0\analyzers\dotnet\cs\Humanizer.dll" />
    <Analyzer Include="..\..\..\..\Solutions\packages\Microsoft.CodeQuality.Analyzers.3.0.0\analyzers\dotnet\cs\Microsoft.CodeQuality.Analyzers.dll" />
    <Analyzer Include="..\..\..\..\Solutions\packages\Microsoft.CodeQuality.Analyzers.3.0.0\analyzers\dotnet\cs\Microsoft.CodeQuality.CSharp.Analyzers.dll" />
    <Analyzer Include="..\..\..\..\Solutions\packages\Microsoft.NetCore.Analyzers.3.0.0\analyzers\dotnet\cs\Microsoft.NetCore.Analyzers.dll" />
    <Analyzer Include="..\..\..\..\Solutions\packages\Microsoft.NetCore.Analyzers.3.0.0\analyzers\dotnet\cs\Microsoft.NetCore.CSharp.Analyzers.dll" />
    <Analyzer Include="..\..\..\..\Solutions\packages\Microsoft.NetFramework.Analyzers.3.0.0\analyzers\dotnet\cs\Microsoft.NetFramework.Analyzers.dll" />
    <Analyzer Include="..\..\..\..\Solutions\packages\Microsoft.NetFramework.Analyzers.3.0.0\analyzers\dotnet\cs\Microsoft.NetFramework.CSharp.Analyzers.dll" />
  </ItemGroup>
  <ItemGroup>
    <Reference Include="System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\..\..\..\Solutions\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
      <Private>True</Private>
    </Reference>
  </ItemGroup>
  <Target Name="Build">
    <Copy SourceFiles="@(Content)" DestinationFiles="@(Content->'$(OutputPath)%(RelativeDir)%(Filename)%(Extension)')" />
  </Target>
  <Target Name="Clean">
    <Exec Command="rd /s /q $(OutputPath)" Condition="Exists($(OutputPath))" />
  </Target>
  <Target Name="Rebuild" DependsOnTargets="Clean;Build">
  </Target>
  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('..\..\..\..\Solutions\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.3.0.0\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\Solutions\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.3.0.0\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props'))" />
    <Error Condition="!Exists('..\..\..\..\Solutions\packages\Microsoft.CodeQuality.Analyzers.3.0.0\build\Microsoft.CodeQuality.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\Solutions\packages\Microsoft.CodeQuality.Analyzers.3.0.0\build\Microsoft.CodeQuality.Analyzers.props'))" />
    <Error Condition="!Exists('..\..\..\..\Solutions\packages\Microsoft.NetCore.Analyzers.3.0.0\build\Microsoft.NetCore.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\Solutions\packages\Microsoft.NetCore.Analyzers.3.0.0\build\Microsoft.NetCore.Analyzers.props'))" />
    <Error Condition="!Exists('..\..\..\..\Solutions\packages\Microsoft.NetFramework.Analyzers.3.0.0\build\Microsoft.NetFramework.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\Solutions\packages\Microsoft.NetFramework.Analyzers.3.0.0\build\Microsoft.NetFramework.Analyzers.props'))" />
    <Error Condition="!Exists('..\..\..\..\Solutions\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.3.0.0\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\Solutions\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.3.0.0\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props'))" />
  </Target>
</Project>
jessehouwing commented 4 years ago

Related to https://github.com/dotnet/runtime/issues/27931?

jessehouwing commented 4 years ago

Installing System.Numerics.Vectors 4.5.0 prior to installing the analyzer solves the issue.

kn327 commented 3 years ago

None of the recommended steps above appear to resolve this issue..

Attempting to gather dependency information for package 'wc-domain.1.8.2' with respect to project 'PROJECT', targeting '.NETFramework,Version=v4.7.2'
Gathering dependency information took 1.76 sec
Attempting to resolve dependencies for package 'wc-domain.1.8.2' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'wc-domain.1.8.2'
Resolved actions to install package 'wc-domain.1.8.2'
Package 'Microsoft.Extensions.DependencyInjection.Abstractions.5.0.0' already exists in folder 'Z:\Projects\XXXXX\XXXXXX\packages'
This reference cannot be removed from the project because it is always referenced by the compiler.
Added package 'Microsoft.Extensions.DependencyInjection.Abstractions.5.0.0' to 'packages.config'
Successfully installed 'Microsoft.Extensions.DependencyInjection.Abstractions 5.0.0' to PROJECT
Package 'Microsoft.Extensions.Logging.Abstractions.5.0.0' already exists in folder 'Z:\Projects\XXXXXX\XXXXXX\packages'
This reference cannot be removed from the project because it is always referenced by the compiler.
Added package 'Microsoft.Extensions.Logging.Abstractions.5.0.0' to 'packages.config'
Successfully installed 'Microsoft.Extensions.Logging.Abstractions 5.0.0' to PROJECT
Package 'Newtonsoft.Json.12.0.3' already exists in folder 'Z:\Projects\XXXXXX\XXXXXX\packages'
This reference cannot be removed from the project because it is always referenced by the compiler.
Added package 'Newtonsoft.Json.12.0.3' to 'packages.config'
Successfully installed 'Newtonsoft.Json 12.0.3' to PROJECT
Package 'System.Buffers.4.5.1' already exists in folder 'Z:\Projects\XXXXXX\XXXXXX\packages'
This reference cannot be removed from the project because it is always referenced by the compiler.
Added package 'System.Buffers.4.5.1' to 'packages.config'
Successfully installed 'System.Buffers 4.5.1' to PROJECT
Package 'System.Numerics.Vectors.4.5.0' already exists in folder 'Z:\Projects\XXXXXX\XXXXXX\packages'
This reference cannot be removed from the project because it is always referenced by the compiler.
Install failed. Rolling back...
Package 'System.Numerics.Vectors.4.5.0' does not exist in project 'PROJECT'
Removed package 'System.Buffers.4.5.1' from 'packages.config'
This reference cannot be removed from the project because it is always referenced by the compiler.
Removed package 'Newtonsoft.Json.12.0.3' from 'packages.config'
This reference cannot be removed from the project because it is always referenced by the compiler.
Removed package 'Microsoft.Extensions.Logging.Abstractions.5.0.0' from 'packages.config'
This reference cannot be removed from the project because it is always referenced by the compiler.
Removed package 'Microsoft.Extensions.DependencyInjection.Abstractions.5.0.0' from 'packages.config'
This reference cannot be removed from the project because it is always referenced by the compiler.
Executing nuget actions took 2.3 sec
Failed to add reference. The package 'System.Numerics.Vectors' tried to add a framework reference to 'System.Numerics' which was not found in the GAC. This is possibly a bug in the package. Please contact the package owners for assistance.
  Reference unavailable.
Time Elapsed: 00:00:04.1770244
========== Finished ==========