Search code examples
c#visual-studio-2012benchmarkdotnet

Can't install BenchmarkDotNet 0.10.2 on Visual Studio Ultimate 2012


I'm trying to install BenchmarkDotNet package into a brand new, blank console project on Visual Studio 2012 ultimate and I'm getting this error log:

PM> Install-Package BenchmarkDotNet
Attempting to resolve dependency 'BenchmarkDotNet.Toolchains.Roslyn (≥ 0.10.2)'.
Attempting to resolve dependency 'BenchmarkDotNet.Core (≥ 0.10.2)'.
Attempting to resolve dependency 'System.Threading.Tasks.Extensions (≥ 4.0.0)'.
Attempting to resolve dependency 'Microsoft.CodeAnalysis.CSharp (≥ 1.3.2)'.
Attempting to resolve dependency 'Microsoft.CodeAnalysis.Common (= 1.3.2)'.
Attempting to resolve dependency 'System.Collections.Immutable (≥ 1.1.37)'.
Attempting to resolve dependency 'System.Reflection.Metadata (≥ 1.2.0)'.
Install-Package : 'System.Reflection.Metadata' already has a dependency defined for 'System.Collections.Immutable'.
At line:1 char:1
+ Install-Package BenchmarkDotNet
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidOperationException
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand

BenchmarkDotNet looks so deceptively simple... But it just doesn't install for me! Has anyone got this problem, or overcome it on Visual Studio 2012?

NOTE: It did install in Visual Studio 2015 Community, but this is not a version I can use for actual development.


Solution

  • Short answer: you can install BenchmarkDotNet only in VisualStudio 2015+. Visual Studio 2012 uses an old version of NuGet (2.x) which doesn't support some modern packages. One of the BenchmarkDotNet dependencies is Roslyn (Microsoft.CodeAnalysis.CSharp) which requires NuGet 3.x+.

    Here are related discussion about minimal supported version of Visual Studio in the BenchmarkDotNet and Roslyn repositories:

    A possible workaround: you can create a new console project in VS2015/2017, install BenchmarkDotNet and copy the whole project (with the packages folder) to your computer with VS2012.