BenchmarkDotNet icon indicating copy to clipboard operation
BenchmarkDotNet copied to clipboard

Not able to run a project referencing to private nuget package

Open kesiyaabraham opened this issue 5 years ago • 12 comments

I have a project which has a dependency on Azure functions, class libraries and private NuGet packages.

I am trying to benchmark a method inside a service class. But I am getting the below error

 Build Exception: C:\Program Files\dotnet\sdk\3.1.100\NuGet.targets(123,5): error : Unable to load the service index for source https://pkgs.dev.azure.com/.../index.json. [C:\..\Benchmarking\bin\Release\netcoreapp2.1\e50243bd-a276-4e7c-b2bc-33b3959a1b2c\BenchmarkDotNet.Autogenerated.csproj]
C:\Program Files\dotnet\sdk\3.1.100\NuGet.targets(123,5): error :   Response status code does not indicate success: 401 (Unauthorized). [C:\..\Benchmarking\bin\Release\netcoreapp2.1\e50243bd-a276-4e7c-b2bc-33b3959a1b2c\BenchmarkDotNet.Autogenerated.csproj]

I am not sure why this error is happening as we are taking nuget packages from cache when running a project.

Please let me know if you need more information on the project or error.

kesiyaabraham avatar Jan 22 '20 10:01 kesiyaabraham

I am also experiencing this exact issue

frankhaugen avatar Mar 18 '20 12:03 frankhaugen

I won't have time to take a look at this in the near future.

It would be great if you could run some troubleshooting described here: https://benchmarkdotnet.org/articles/guides/troubleshooting.html

It's really strange that BDN fails, as all it does is generating a new project that references the project with benchmarks and running dotnet restore in its folder...

adamsitnik avatar Oct 23 '20 17:10 adamsitnik

I have the same problem. I'm trying to run BDN on azure pipelines but the main project has a reference to a package from a private source. Is there a solution for this? Or, is there a way to run bechmarkRunner without the dotnet restore command?

eginsjd avatar Nov 26 '21 20:11 eginsjd

Same here. Only happend on Linux and use sudo command. If not use sudo command, then it will be fine, except have a message: Failed to set up high priority. Make sure you have the right permissions. Message: Permission denied

boblaw99 avatar Dec 05 '21 19:12 boblaw99

Yes I was able to solve the problem by disabling the private sources (dotnet nuget disable [sourceName]) right before running BDN. But I get the same warning.

eginsjd avatar Dec 05 '21 20:12 eginsjd

I'm also suffering from this issue. It is like the dotnet restore executed it is not using the nuget.config (in which the credentials are defined) to perform the nuget restore. I tried to copy inside my BDN project the Nuget.Config but no luck so far. I will take a lot to the code to see if I find a way to fix it

jrodrigv avatar Jan 22 '23 09:01 jrodrigv

Ok I have found a way to avoid this error and it is simple. If you are using private nugets feeds you would have a NuGet.config in your solution folder, add as link that file inside your benchmark project folder and set the properties of the file to "Content" and "Copy Always". After that the dotnet restore should work just fine.

jrodrigv avatar Jan 23 '23 07:01 jrodrigv

@jrodrigv thanks for sharing!

adamsitnik avatar Jan 23 '23 10:01 adamsitnik

Is @jrodrigv workaround suffice or BenchmarkDotNet team is looking for a solution? Or maybe documentation? Please let me know so I can grab this issue to try fixing it.

JobaDiniz avatar Jun 13 '23 19:06 JobaDiniz

@JobaDiniz, Thank you for your interest in this issue and for offering your help. I believe we should start with a stable repro for this problem. I just tried to reproduce it myself with BenchmarkDotNet v0.13.5, but everything works fine out of the box. Since BenchmarkDotNet creates an autogenerated project in a subfolder of the original project, it inherits all the relevant NuGet.Config files with all the declared credentials.

@kesiyaabraham @frankhaugen @eginsjd @boblaw99 @jrodrigv If the issue is still relevant for you, we would appreciate any additional details on how you configure your benchmarks.

AndreyAkinshin avatar Jun 16 '23 16:06 AndreyAkinshin

I'm also getting this issue. I've tried @jrodrigv's workaround but it doesn't help. Rebuilding the benchmark project fixes it, but I gotta do it pretty often, it's a bit annoying.

amazingalek avatar Mar 10 '24 17:03 amazingalek

@amazingalek Can you please share how to reproduce?

timcassell avatar Mar 10 '24 18:03 timcassell