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

Notification

Icon
Error

NCrunch cannot build dotnet 5 projects
amo11
#1 Posted : Tuesday, November 9, 2021 10:18:01 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 11/9/2021(UTC)
Posts: 6
Location: Denmark

Thanks: 1 times
I am using the latest version of both Visual Studio 2019 (16.11.5) and 2022 (17.0.0) together with the latest version of NCrunch (4.11.0.2).

For solutions/projects targeting .NET Framework 4.8 everything works as expected. For solutions/projects targeting .Net 5 however, NCrunch cannot build any projects, and fails with the message

Quote:
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)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at nCrunch.TaskRunner.Ipc.IpcMessageProcessor.(CallMethodMessage )
at nCrunch.TaskRunner.Ipc.IpcMessageProcessor.ProcessMessageReturningResult(Byte[] data)
at nCrunch.TaskRunner.Ipc.RemoteInstance.(Byte[] )
at nCrunch.TaskRunner.Ipc.RemoteInstance.Invoke(IMessage msg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at nCrunch.Compiler.IRemoteBuildRunner.AnalyseComponentBuild(ComponentLoadParameters parameters)
at nCrunch.Core.BuildManagement.BuildProcessLauncher..(IRemoteBuildRunner )
at nCrunch.Core.BuildManagement.BuildProcessLauncher.(Action`1 , FilePath , String , ExternalProcess )
at nCrunch.Core.BuildManagement.BuildProcessLauncher.(Action`1 , EffectiveProcessorArchitecture , GridClientId , BuildSystemParameters , IList`1 , Nullable`1 , GridAddress , DotNetCoreSdkVersion  )
at nCrunch.Core.BuildManagement.BuildProcessLauncher.AnalyseComponentBuildInExternalProcess(ComponentLoadParameters parameters, IList`1 customEnvironmentVariables)
at nCrunch.Client.ComponentLoader.SnapshotComponentLoader.(EffectiveProcessorArchitecture , String )
at nCrunch.Client.ComponentLoader.SnapshotComponentLoader.CreateComponentFromXml(FilePath projectFilePath, ParsedBuildXml projectXml, FilePath solutionFilePath, String[] additionalFilesToIncludeAtSolutionLevel, Boolean isLoadedFromFile, VisualStudioVersion vsVersion, ComponentUniqueName componentName, TaskSettings componentTaskSettings, Exception parseException, String targetFrameworkForMsbuild, String visibleTargetFramework)



This issue first occurred for me since a couple of months ago, after upgrading Visual Studio 2022 preview (I cannot remember which version unfortunately). Based on similar posts in the forum here I attempted to use global.json files to fix the problem without success.

All our .Net 5 projects build successfully via both Visual Studio (2019 and 2022), as well as via the command line. All tests run without problem from Visual Studio (again both 2019 and 2022) as well.

How can I find more information so this problem can be fixed? I am really missing NCrunch
Remco
#2 Posted : Tuesday, November 9, 2021 10:47:37 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi, thanks for sharing this problem.

This issue usually appears when the project is being pointed at an SDK installation path that is corrupt or doesn't exist. Could you check the installed SDKs inside "C:\Program Files\dotnet\sdk" to make sure they look to be intact? Sometimes we've seen issues like this reported when there is an empty SDK directory.

Can you also confirm whether you've upgraded your VS2022 to the RTM build? (This is relevant because of preview SDK search logic).
amo11
#3 Posted : Wednesday, November 10, 2021 12:35:38 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 11/9/2021(UTC)
Posts: 6
Location: Denmark

Thanks: 1 times
Hi - thanks for your reply.

I can confirm that I have the RTM version of Visual Studio 2022 installed (I did try to update directly from the preview version to the RTM version, but I wasn't sure that worked correctly so I ended up removing the preview version of Visual Studio 2022 and then installing the RTM version).

I took a closer look at the dotnet sdk's and runtimes that I had installed.

I found that one .net core 3 sdk had no files under it's folder (C:\program files\dotnet\sdk\3.1.0.120), and a number of .net 5 sdk's were not found under windows settings app list (i.e. the folder under C:\program files\dotnet\sdk had no corresponding entry in the app list maintained by windows).

I have removed everything except what is required by Visual Studio 2019 and 2022 (so now only .net sdk's 5.0.403 and 6.0.100 are installed).

Unfortunately I am still seeing the same problems with NCrunch - works with .Net framework 4.8, but fails on .Net 5 projects with exactly the same error as before.

What is the next step to try and fix this?



Remco
#4 Posted : Wednesday, November 10, 2021 11:53:58 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Could you try submitting a bug report after you experience the build failure? I might be able to glean some useful info from the log in the report.
Remco
#5 Posted : Thursday, November 11, 2021 10:28:31 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Thanks for submitting the report.

The problem is caused by a couple of custom environment variables you have configured for NCrunch. They are pointing at an SDK install path that most likely doesn't exist:
DOTNET_MSBUILD_SDK_RESOLVER_SDKS_VER = 5.0.302
DOTNET_MSBUILD_SDK_RESOLVER_SDKS_DIR = C:\Program Files\dotnet\sdk\5.0.302\Sdks

Removing these variables from your NCrunch settings should resolve the problem. Most likely you had them in place to work around known issues between NCrunch and the VS2022 preview builds.
1 user thanked Remco for this useful post.
amo11 on 11/11/2021(UTC)
amo11
#6 Posted : Thursday, November 11, 2021 12:00:53 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 11/9/2021(UTC)
Posts: 6
Location: Denmark

Thanks: 1 times
Many thanks - I had completely forgotten about these env variables. Removing these variables fixed the problem.

As you thought, I had originally set them to work around the same issue with preview versions of Visual Studio 2022, and unfortunately they were a bit hard to spot in the NCrunch configuration.

I am so very happy to have NCrunch back now!

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.059 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download