Build/Test Issues

NCrunchConsole alternative for global.json?

Started by GreenMoose on 1,872 views

[v3.30.0.1]

Wen building awith dotnet.exe I can have a global.json with content below, and I can easily see in TeamCity output SDK is used, e.g.
global.json:

{
"sdk": {
"version": "2.1.801"
}
}

Output:

.NET Core SDK v2.1.801 dotnet.exe build APIs\Utils\Utils.sln --configuration Release --no-restore -warnAsError @D:\TeamCity\buildAgent\temp\agentTmp\2.rsp


But how can I decide this with NCrunch, i.e. does it also use global.json somehow but not including it output?

Thanks.

Edited

Hi, thanks for posting.

In theory, NCrunch should be using the MSBuild abstractions that allow the global.json to be effective for the projects NCrunch has loaded. I believe we have some code in there to fish out this file and copy it to the workspace too.

Are you receiving an error of some kind? Is NCrunch using the correct SDK version?
I initially had issues with MethodNodFoundException in NCrunch which is why I originally wrote the post (with dotnet test it was "could not find dll"), but that was due to use of different versions of a nuget package but led me to wonder if global.json was used.

Anyhow, I did a quick test and NCrunch does indeed copy the global.json to workspace folders.

However, if using a SDK version in it that does not exist NCrunch throws a pretty cryptic exception, but at least it fails which I would expect :).

dotnet build error:

dotnet : A compatible SDK version for global.json version: [2.0.801] from [D:\TeamCity\buildAgent\work\cd4ee94462cc9ad\global.json] was not found
+ CategoryInfo : NotSpecified: (A compatible SD...] was not found:String) [],


NCrunch error:

Utils.Common.Tests.NUnitTests.csproj: 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: The target "_SplitProjectReferencesByFileExistence" does not exist in the project.
at nCrunch.Compiler.ComponentAnalysisContext.()
at nCrunch.Compiler.ComponentAnalysisContext.AnalyseComponentBuild()
at nCrunch.Compiler.RemoteBuildRunner.AnalyseComponentBuild(ComponentLoadParameters parameters)


Thanks.

Edited

Post a reply

Log in to reply.