Skip to content

How to fail the run if NuGet restored with warnings? #2581

Open
@mstefarov

Description

@mstefarov

I ran into several cases where I accidentally benchmarked the wrong version of a NuGet package because NuGet restore warnings (e.g. NU1102 "Unable to find package 'Foo' with version (>= X.Y.Z)" or NU1603 "An approximate best match of X.Y.Z was resolved.") were not reported by BenchmarkDotNet when I use CsProjClassicNetToolchain or CsProjCoreToolchain, and these warnings did not fail the build/run.

I've been looking for a way to treat these warnings as errors, but have not found a way yet.

  • <WarningsAsErrors>NU1102;NU1603</WarningsAsErrors> in the benchmark csproj has no effect, because it does not get copied over to generated projects.
  • Passing /p:WarningsAsErrors="NU1102;NU1603" as an MsBuildArgument to the job does not work, because BenchmarkDotNet uses dotnet restore (which does not respect this option) instead of nuget restore or msbuild /t:Restore (which would).

Is there another way, short of forking CsProj toolchains?

IMO treating NuGet restore problems as run failures seems like a resonable default behavior too.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions