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?
Build/Test Issues
Teamcity integration Object reference not set to an instance of an object at nCrunch.Compiler.DotNet
Started by GurdipS on 3,746 views
Remco NCrunch Developer
#15877
15 Dec 2021 23:28 UTC
Hi, thanks for posting.
Can you confirm if you have any version of the .NET Core (or .NET5/6) SDK installed on this machine?
Can you confirm if you have any version of the .NET Core (or .NET5/6) SDK installed on this machine?
Yeah, I have version 5.0.404 on the build server.
And vs2019 installed, which provides msbuild.
And vs2019 installed, which provides msbuild.
Edited 15 Dec 2021 23:35 UTC
Remco NCrunch Developer
#15880
15 Dec 2021 23:38 UTC
Thanks! Can you confirm if you have the dotnet.exe file in your system PATH environment variable?
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?
I ran dotnet --list-sdks.
This brings back 5.0.404 and 5.0.401. Should/would this matter?
hmm i checked env cars on the dev machine, they dont match the build server. I am missing c:\program files (x86)\dotnet
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.
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.
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.
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 NCrunch Developer
#15885
16 Dec 2021 03:12 UTC
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.
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.
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?
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 NCrunch Developer
#15887
16 Dec 2021 09:43 UTC
GurdipS 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.
Post a reply
Log in to reply.