Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

NCrunch was unable to restore Nuget packages required to build a test environment for this project
soadyp
#1 Posted : Friday, June 15, 2018 11:01:46 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/14/2018(UTC)
Posts: 4
Location: Australia

NCrunch was unable to restore Nuget packages required to build a test environment for this project, due to an unspecified failure when invoking 'msbuild.exe /t:restore'

The following packages do not exist under the Nuget packages folder for the active user profile, yet they have been flagged by NCrunch as potentially needed for normal operation. NCrunch has attempted to restore these files via an MSBuild restore step, which has either failed or not returned the expected result. It's possible that these packages may not be needed for building projects or running tests in your environment. If you experience downstream problems with NCrunch on this solution, it is recommended you restore or download the packages manually.


Is there a way to tell NCrunch where Nuget Packages are?
What does Ncrunch think "Nuget packages folder for the active user profile" is ? Where does it get that info from ?

I have tried setting the documented nuget environment variables.
NUGET_HTTP_CACHE_PATH=the location
NUGET_PACKAGES=the location

There is a nuget.config files at Machine level.
C:\Program Files (x86)\NuGet\Config\Nuget.config
and
C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config
both have the same content
<add key="Microsoft Visual Studio Offline Packages" value="the location"/>


There is a maintained file at user level
C:\Users\<user>\AppData\Roaming\NuGet\nuget.config
with
<config>
<add key="repositoryPath" value="the location" />
</config>

There are no project or solution level nuget package settings.

So Ncrunch should be able to find the packages.

Can I see why Ncrunch cant find packes or tell it which directories to use ?

EDIT: AFTER POSTING THIS, IT now works
not sure if was permissions on directories, an extra restart of VS or Ncrunch engine.

But I can now see Ncrunch working.
Sorry for any inconvenience
soadyp
#2 Posted : Friday, June 15, 2018 11:12:16 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/14/2018(UTC)
Posts: 4
Location: Australia

is there a close ticket option. ? If so feel free to close. I just couldnt see it.
Remco
#3 Posted : Saturday, June 16, 2018 12:51:06 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,478

Thanks: 1016 times
Was thanked: 1361 time(s) in 1264 post(s)
soadyp;12342 wrote:
is there a close ticket option. ? If so feel free to close. I just couldnt see it.


I'm glad you managed to solve this. For a bit of background, this is a step NCrunch does to restore packages that it needs internally if it can't find the packages already installed in your user's .nuget directory. The package restore step is dependent on operation of a whole lot of stuff under the hood (MSBuild, .NET Core, Nuget, network, etc), so there are situations it can fail.

If you see this again, try creating a simple project that references the missing packages in Visual Studio. This will trigger VS to restore them to your user profile where NCrunch can find them.
1 user thanked Remco for this useful post.
David Arno on 10/14/2021(UTC)
Paramethod
#4 Posted : Tuesday, August 13, 2024 12:26:57 AM(UTC)
Rank: Member

Groups: Registered
Joined: 10/28/2021(UTC)
Posts: 10
Location: Canada

Thanks: 5 times
Was thanked: 3 time(s) in 3 post(s)
Not too sure where to write this, but I had a very similar error (NCrunch was unable to restore Nuget packages required to build a test environment for this solution) in Ncrunch for Rider v5.9.0.1. The solution that worked for me was to exit Rider, delete the `C:\Users\<UserName\AppData\Local\NCrunch\<SomeInt>` folder and restart Rider.
1 user thanked Paramethod for this useful post.
Remco on 8/13/2024(UTC)
Fresa
#5 Posted : Sunday, January 18, 2026 3:47:19 PM(UTC)
Rank: Member

Groups: Registered
Joined: 7/7/2018(UTC)
Posts: 16
Location: Sweden

Thanks: 3 times
Was thanked: 5 time(s) in 4 post(s)
I'm pretty sure this happens when building source generators that are missing transient dependencies which Roslyn doesn't load automatically.

The "worst" part is that NCrunch seems to solve this for Roslyn, creating false positives. This "error" is the only thing hinting that something is not right. I'd like to see NCrunch fail when reporting this error, is there a configuration option for that perhaps?

More background: https://github.com/dotnet/sdk/issues/17775
Remco
#6 Posted : Sunday, January 18, 2026 10:41:22 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,478

Thanks: 1016 times
Was thanked: 1361 time(s) in 1264 post(s)
Fresa;18574 wrote:
I'm pretty sure this happens when building source generators that are missing transient dependencies which Roslyn doesn't load automatically.

The "worst" part is that NCrunch seems to solve this for Roslyn, creating false positives. This "error" is the only thing hinting that something is not right. I'd like to see NCrunch fail when reporting this error, is there a configuration option for that perhaps?

More background: https://github.com/dotnet/sdk/issues/17775


I'm not sure entirely which issue you've been hit with under the hood, but the above warning is quite narrow in its scope and I don't see a way for it to relate to false positives from the build system.

When NCrunch first starts, it has a list of packages that it needs to have installed on your machine for NCrunch to work correctly. This list of packages is actually hard-coded into NCrunch (or at least, it's derived by the NCrunch build system when the installers are built). It's basically a list of a number of platform dependencies that NCrunch and its adapters need internally to be able to run without errors. In theory, it would be possible to just roll these dependencies into the NCrunch installer and install them with the rest of the proprietary binaries. We don't do this because it bloats the installer, and in almost all cases these dependencies are already installed on the user's machine.

The error is a warning because at the point the package restore fails, we don't actually know 100% whether the package is required by NCrunch's internal code. This is because platform resolution logic is extremely complex and changes between versions of the platform, and there's a high chance that the likely older binary being referenced by NCrunch has a newer version already installed on the machine which can resolve without problems. Some of the packages are also used by niche adapters that might not be needed to crunch your code (i.e. they might be for a test framework or toolset you're not using).

If you see this warning and your code runs fine under NCrunch, then there's actually no action required unless you want to get rid of the warning. If the warning shows and something fails, then restoring the packages is the first thing you should do.

I suspect the issue you've encountered with transient dependencies is unrelated to the above. Most likely this is caused by NCrunch's runtime resolution overrides that are needed to allow dependencies to be properly found by code running in its workspaces, in which case it will sadly be hard for us to replicate the exact behaviour you're experiencing inside the IDE. We try to keep the build results consistent between NCrunch and the IDE, but there are fundamental differences that can't be designed around.
Fresa
#7 Posted : Monday, January 19, 2026 6:32:35 PM(UTC)
Rank: Member

Groups: Registered
Joined: 7/7/2018(UTC)
Posts: 16
Location: Sweden

Thanks: 3 times
Was thanked: 5 time(s) in 4 post(s)
Here's an example repo: https://github.com/Fresa...entDependenciesExamples

NCrunch 5.20.0.2 for JetBrains Rider
JetBrains Rider 2025.3.1 (Build #RD-253.29346.144, built on December 18, 2025)
Remco
#8 Posted : Monday, January 19, 2026 11:46:55 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,478

Thanks: 1016 times
Was thanked: 1361 time(s) in 1264 post(s)
Thanks for sharing the sample solution.

On my side, both of these solutions build in the IDE and NCrunch does a full pass on them without errors or the resolution warning. This seems to be the same for both VS and Rider.

Right now it's not clear to me why you see the NCrunch error on one solution and not the other, but other than circumstance I don't see a way that it is connected to the transient dependency issue you've described. I do expect, however, that if you manually restore the missing package mentioned in the error, it will disappear while the false positive will likely continue to show.

Something I'll flag up is that your project does contain a build customisation in the form of your additional build target (GetDependencyTargetPaths) which injects dependencies into the build. Right now I have no specific issue with this customisation, but you should be aware that we can't test NCrunch to cater for customisations like this as they can have a significant effect on the build system and we have no way to plan for them up front. In this case everything seems to be fine, but if weird stuff starts happening in the build, there won't be much I can do to help.

Appreciating that you haven't had a good experience here with a build issue that NCrunch should have caught for you, but right now I don't see a way to reasonably modify the product in a way that will catch this kind of problem without risking introducing much bigger ones (i.e. causing it to not work at all). Every time we break abstractions to reach down into the build system to change something, we introduce further risks of breaking things unintentionally for configuration sets or environments that we aren't aware of. There needs to be a very good reason to rewire things down there. If NCrunch can build your solution and run tests, I am reluctant to mess with things.
Fresa
#9 Posted : Tuesday, January 20, 2026 4:37:13 PM(UTC)
Rank: Member

Groups: Registered
Joined: 7/7/2018(UTC)
Posts: 16
Location: Sweden

Thanks: 3 times
Was thanked: 5 time(s) in 4 post(s)
The referenced issue in dotnet/sdk (and dotnet/roslyn) describes the current behavior of the compiler using private dependencies in analyzers.

The only difference between the two solutions in the example repo is the lack of the required transient dependencies defined in:

https://github.com/Fresa...Dependencies.csproj#L15
vs
https://github.com/Fresa...Dependencies.csproj#L15

You can see the test failing (dotnet test) for the missing transient dependencies here: https://github.com/Fresa...b/60817530068#step:4:21

Maybe adding a configuration option to fail when detecting that error?
Fresa
#10 Posted : Tuesday, January 20, 2026 5:08:44 PM(UTC)
Rank: Member

Groups: Registered
Joined: 7/7/2018(UTC)
Posts: 16
Location: Sweden

Thanks: 3 times
Was thanked: 5 time(s) in 4 post(s)
You were right, it seems to be a coincidence, I can't reproduce that error anymore. Sorry for hijacking this thread :)
1 user thanked Fresa for this useful post.
Remco on 1/20/2026(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.083 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download