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

Notification

Icon
Error

TeamCity NCrunch console run still fails with Nuget restore error
DeltaEngine
#1 Posted : Wednesday, April 8, 2020 5:07:18 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 11/23/2012(UTC)
Posts: 31
Location: Germany

Thanks: 8 times
Was thanked: 3 time(s) in 3 post(s)
Sadly for one of our simple test project this still happens and causes the NCrunch build step on TeamCity to fail:

ERROR: Unable to restore required Nuget packages for .NET Core test environment - NCrunch was unable to restore Nuget packages required to build a test environment for this solution, 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.

System.Runtime.Loader v4.3.0
System.Runtime.Serialization.Formatters v4.3.0
System.Runtime.Serialization.Primitives v4.3.0
System.Diagnostics.TraceSource v4.3.0
[...]

We tried all the other solutions provided here in the forum (copy .nuget folder, get it all working via VS2019, in the console it works, no problem with msbuild /t:restore, etc.) and also the /TeamCityDisableTestNotRunFailureReporting doesn't help one bit, the error still pops up and causes the build step to fail :(

Strange thing is we had this same problem a week ago on a different bigger project and there the above fixes helped, no idea why this one is still failing, if you want to try yourself I can send the solution (but any Hello World one line .netcoreapp3.1 project currently fails for us the same way). We used the exact steps as described here: https://www.ncrunch.net/...ides_console-tool-usage

TeamCity can ignore the Error if the checkbox "an error message is logged by build runner Reset" under Failure Conditions (teamcity project configuration) is disabled, for some reason TeamCity still fails (maybe a bug on their side .. dunno). Better would be if NCrunch doesn't report this an an error because everything after that still works fine (and yes we have all those .nuget packages even though they are not used at all).
Remco
#2 Posted : Wednesday, April 8, 2020 11:53:02 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
NCrunch kicks up this message after it performs the 'msbuild /t:restore' step for the packages involved and is unable to find the packages in the user's .nuget directory after the restore step has completed. This is considered to be an issue between NCrunch and the infrastructure rather than the codebase, so it probably won't be reproduceable on another machine unless it has exactly the same configuration.

My guess here would be that the .nuget packages directory is being stored in a less obvious place on the machine due to the build being run under a different user account. Note that if the build runs under the local system account, the nuget packages may be stored in an unexpected place (the local system user profile is usually under C:\Windows\System32\config\systemprofile). If you're able to copy the correct versions of these packages to the .nuget packages directory stored for the user account under which your build runs, the problem should go away. It may be easier to set your build to run under a named account with sufficient access privileges on the system. If your build is already set to run under a special profile/account, this could actually be the source of the problem if the account doesn't have the correct privileges to be able to run the restore step and download the packages.
DeltaEngine
#3 Posted : Thursday, April 9, 2020 11:13:21 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 11/23/2012(UTC)
Posts: 31
Location: Germany

Thanks: 8 times
Was thanked: 3 time(s) in 3 post(s)
Thanks for the reply, it wasn't easy to fix, for more testing we did all of the following:
- execute the exact same command TeamCity executes in the command line, there it succeeds, no errors or warnings
- run msbuild /t:restore, also no problem here
- run the TeamCity agent with the admin account and give all rights to all kinds of folders, same problem
- set all kinds of extra .nuget paths and folders, which doesn't help
- tried a different fresh TeamCity agent installed yesterday running on different vms, all have the exact same problem (no difference if running under the agent account or admin or system)
- got all nuget packages (our folder from the old build server was 1gb, were NCrunch from the agent still works, all copied) to the usual places %user%/.nuget, packages, C:\Program Files (x86)\Microsoft SDKs\NuGetPackages
- Sadly nothing helped yet and this was very frustrating to debug and fix as it works just fine on all of our pcs and the console, just on teamcity agents it messes up (which helped a bit to figure out it must be a configuration problem after all)
- Maybe it happens only with a fresh installation, but an old system that had many versions of .net, teamcity, ncrunch, lots of .nuget files flying around doesn't have this problem?
- Also I have seen this issue several times in the forum, wouldn't it be good if the NCrunch console runner simply fixes the issue itself when msbuild /t:restore doesn't work and produces that error, just call nuget, grab the missing packages, done.

Anyway, you were right about the rights, just the fix wasn't obvious at all. It seems that while testing we restored nuget packages and those folders and nupkg filepaths where stored in \obj\project.nuget.cache
After cleaning the project (e.g. manually deleting or just using clean before the build or via Clean sources on this agent option in TeamCity) the build step failed already because it couldn't find this nuget.cache file, which we didn't update or regenerate, it was still using some old copy+paste version from manual testing.

After readding our "NuGet Installer" build step first, it all works again

Now it all works, hopefully this helps someone else. Not really a rights issue or msbuild or NCrunch issue, except that it would be really nice if NCrunch would report a better error message or just simple do a nuget restore if that happens (remember that the build after that still works, just the error message caused teamcity to fail, even when it should have ignored the error output).
Remco
#4 Posted : Saturday, April 11, 2020 3:59:37 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
My apologies for the frustration you've experienced here. I've made a task to look into this in more detail on our side to see if we can improve this a bit. At the very least, maybe we can provide a better message.
simongh
#5 Posted : Tuesday, July 7, 2020 3:23:12 PM(UTC)
Rank: Member

Groups: Registered
Joined: 10/20/2017(UTC)
Posts: 26
Location: United Kingdom

I've just been bashing my head against a brick wall with this one & thought I'd add this, in case it helps anyone else.

If you use the nuget installer step in TeamCity, it stores the cached copies of the packages in a different location to that used by dotnet restore or dotnet build.

c:\users\<name of user used by agent>\.nuget
c:\buildagent\system\dotnet\.nuget

We use our own nuget server & it's the only one the agent can reach. NCrunch fails until you manually add the packages to the above locations
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.049 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download