Build/Test Issues

Possible error in GetToolPath

Started by NeilMacMullen on 1,575 views

I have a C# test project that uses a managed 32bit C++ dll. As a result, the csproj file contains this...

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>


This worked fine when I was targetting Net5 but under Net6, Ncrunch fails to build the project and reports

[PID:23340 16:41:42.5767 LocalBuildTask-150] ERROR (Internal): System.Exception: dotnet.exe was not found at 'C:\Program Files (x86)\dotnet\dotnet.exe'
at nCrunch.Core.PlatformTypes.DotNetCore.DotNetCoreSdk.(EffectiveProcessorArchitecture )
at nCrunch.Core.PlatformTypes.DotNetCore.DotNetCoreSdk.GetToolPath(EffectiveProcessorArchitecture effectiveProcessorArchitecture)
at nCrunch.Core.PlatformTypes.DotNetCore.DotNetCoreSdk.GetFallbackFolderPath(EffectiveProcessorArchitecture processorArchitecture)
at nCrunch.Core.PlatformTypes.DotNetCore.DotNetCoreBuildExtender.(SnapshotComponent , FilePath , DirectoryPath[] )
at nCrunch.Core.PlatformTypes.DotNetCore.DotNetCoreBuildExtender.(SnapshotComponent , BuildOutput )
at nCrunch.Core.PlatformTypes.DotNetCore.DotNetCoreBuildExtender.ProcessSuccessfulBuildOutput(SnapshotComponent component, BuildOutput buildOutput, IList`1 componentReferences)
at nCrunch.Core.BuildManagement.BuildEnvironment.Build(SnapshotComponent snapshotComponentToBuild, IList`1 referencedComponents, GridClientId gridClientId, IList`1 customEnvironmentVariables, IPlatformBuildExtender extender, Guid taskId, GridAddress clientAddress, Boolean extractCoverageReportStructure)
at nCrunch.Core.Processing.BuildTaskLogic.DoProcessTaskAndReturnSuccessFlag()
at nCrunch.Core.Processing.TaskLogic.ProcessTaskAndReturnSuccessFlag()
at nCrunch.Client.Processing.LocalProcessingTask.ProcessTaskAndReturnSuccessFlag()
at nCrunch.Client.Processing.ProcessingQueue..()


However, I believe that this is the wrong location for dotnet 6...

16:46/Backend>get-command dotnet

CommandType Name Version Source
----------- ---- ------- ------
Application dotnet.exe 6.0.121.5… C:\Program Files\dotnet\dotnet.exe


If I remove the x86 platform target, Ncrunch successfully builds the project but tests fail because the DLL can't be loaded.


Ncrunch is 4.11.02
VS is 17.0.5 (VS2022, stable)
Hi, thanks for sharing this.

I'm not sure how this worked under Net5, as technically I would have thought it shouldn't. Running a test project set to target x86 defaults in the x86 version of Dotnet being used, which isn't installed on your machine.

It might be possible to work around this by setting your use CPU architecture setting to x64. In this way, NCrunch will use the x64 version of Dotnet for your runtime environment while still building the test project to target x86.

If the above doesn't work, then you'll need to install the x86 version of Dotnet.
>I'm not sure how this worked under Net5, as technically I would have thought it shouldn't.

I think I was probably conflating the migration to Net6 with a move to a new dev machine. It turns out that the project did build and test on the old machine because it had an old x86 Net5 SDK installed. (Not sure how since I only ever consciously install x64 versions but nvm...)


>It might be possible to work around this by setting your use CPU architecture setting to x64.

Unfortunately even after setting both (Build Settings) "Build Process CPU Architecture" and (Test Settings) "use CPU Architecture" to x64 Ncruchs still tries to use the version in "Program Files (x86)"

>If the above doesn't work, then you'll need to install the x86 version of Dotnet.


This did work - thanks :-)

Post a reply

Log in to reply.