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

Notification

Icon
Error

Teamcity integration Object reference not set to an instance of an object at nCrunch.Compiler.DotNet
GurdipS
#1 Posted : Wednesday, December 15, 2021 11:18:40 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/14/2021(UTC)
Posts: 9
Location: United Kingdom

Hi,
I want to use NCrunch with TeamCity, and followed the console tool guide.

I've had various issues with MSBuild in trying to get this to work.

However, my latest attempt is to have the build server config match my local dev machine, at least for .NET tooling.

Object reference not set to an instance of an object at
nCrunch.Compiler.DotNetCoreSdkDirectory.GetInstalledDirectories


Could you assist?
Remco
#2 Posted : Wednesday, December 15, 2021 11:28:01 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 929 times
Was thanked: 1256 time(s) in 1169 post(s)
Hi, thanks for posting.

Can you confirm if you have any version of the .NET Core (or .NET5/6) SDK installed on this machine?
GurdipS
#3 Posted : Wednesday, December 15, 2021 11:30:52 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/14/2021(UTC)
Posts: 9
Location: United Kingdom

Yeah, I have version 5.0.404 on the build server.

And vs2019 installed, which provides msbuild.
Remco
#4 Posted : Wednesday, December 15, 2021 11:38:59 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 929 times
Was thanked: 1256 time(s) in 1169 post(s)
Thanks! Can you confirm if you have the dotnet.exe file in your system PATH environment variable?
GurdipS
#5 Posted : Wednesday, December 15, 2021 11:42:32 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/14/2021(UTC)
Posts: 9
Location: United Kingdom

I have DOTNET_HOME, which goes to C:\Program Files\dotnet.

I ran dotnet --list-sdks.

This brings back 5.0.404 and 5.0.401. Should/would this matter?
GurdipS
#6 Posted : Wednesday, December 15, 2021 11:51:23 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/14/2021(UTC)
Posts: 9
Location: United Kingdom

hmm i checked env cars on the dev machine, they dont match the build server. I am missing c:\program files (x86)\dotnet
GurdipS
#7 Posted : Thursday, December 16, 2021 12:13:34 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/14/2021(UTC)
Posts: 9
Location: United Kingdom

I added the two env vars:


DOTNET_MSBUILD_SDK_RESOLVER_SDKS_DIR C:\Program Files\dotnet\sdk\5.0.404\Sdks
DOTNET_MSBUILD_SDK_RESOLVER_SDKS_VER 5.0.404


Now I get this error:

System.Exception: An exception was thrown in the remote environment: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.Build.Exceptions.InvalidProjectFileException: The default XML namespace of the project must be the MSBuild XML namespace.


What would the correct config of the build server be? I'm a little confused.
GurdipS
#8 Posted : Thursday, December 16, 2021 12:38:00 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/14/2021(UTC)
Posts: 9
Location: United Kingdom

Ok that is fixed. Now I get this issue:

System.Exception: An exception was thrown in the remote environment: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> nCrunch.Common.UserException: Errors occurred while trying to load the project file:
Package FluentValidation, version 10.3.5 was not found. It might have been deleted since NuGet restore. Otherwise, NuGet restore might have only partially completed, which might have been due to maximum path length restrictions.
Remco
#9 Posted : Thursday, December 16, 2021 3:12:41 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 929 times
Was thanked: 1256 time(s) in 1169 post(s)
Do you have the build server configured to perform a restore step before running NCrunch? I suspect this package may not exist in the restore paths prior to the NCrunch console tool being invoked.

When trying to find the installation of Dotnet, NCrunch will first check the DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR environment variable, which can be set to point to the path containing dotnet.exe. If this isn't set, it checks the contents of the PATH environment variable to try and find any specified directory that contains dotnet.exe.

By setting the DOTNET_MSBUILD_SDK_RESOLVER_SDKS_DIR environment variable you force the system to use a specific version of Dotnet, which overrides the above logic but will need to be updated if you install a newer version of the SDK on this system.
GurdipS
#10 Posted : Thursday, December 16, 2021 9:37:29 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/14/2021(UTC)
Posts: 9
Location: United Kingdom

Hi,
So I am on the right track.

The package does exist. It's under system32/config, as TeamCity agent runs under local system.

Is NCrunch expecting these packages in a certain path?
Remco
#11 Posted : Thursday, December 16, 2021 9:43:32 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 929 times
Was thanked: 1256 time(s) in 1169 post(s)
GurdipS;15886 wrote:
Hi,
The package does exist. It's under system32/config, as TeamCity agent runs under local system.

Is NCrunch expecting these packages in a certain path?


These packages will need to be in one of the package paths specified in the obj\*.nuget.g.props while which is created by the Nuget restore step. Even if the packages are already installed on this system, you'll still need to run a restore step on your solution before building it with NCrunch, as the bindings to the package directories are specific to the machine you're building on and they will be likely be incorrect if pulled down directly from a VCS.
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.050 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download