Skip to content

Instantly share code, notes, and snippets.

@adamsitnik
Last active August 26, 2019 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamsitnik/f151dc68ea30f8138cfc55d81195f363 to your computer and use it in GitHub Desktop.
Save adamsitnik/f151dc68ea30f8138cfc55d81195f363 to your computer and use it in GitHub Desktop.
How to compare local changes vs nuget package using single BDN config
<Project Sdk="Microsoft.NET.Sdk">
<!-- IMPORTANT! MSBuild sets the Optimize=true only if the Configuration name == Release -->
<PropertyGroup Condition="$(Configuration.StartsWith('Release'))">
<Optimize>true</Optimize>
</PropertyGroup>
<ItemGroup Condition=" '$(Configuration)' == 'Release' Or '$(Configuration)' == 'Debug' ">
<ProjectReference Include="SomeProject.csproj" />
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)' == 'ReleasePackage' Or '$(Configuration)' == 'DebugPackage' ">
<PackageReference Include="SomePackage" Version="2.2.4" />
</ItemGroup>
</Project>
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Running;
namespace BenchmarkDotNet.Samples
{
class Program
{
static void Main(string[] args)
{
var config = DefaultConfig.Instance
.With(Job.Default.WithId("Project"))
.With(Job.Default.WithCustomBuildConfiguration("ReleasePackage").WithId("Package")); // BDN is going to do --configuration ReleasePackage for all dotnet cli commands
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args, config);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment