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

Notification

Icon
Error

"Sequence contains no matching element" exception in Visual Studio Preview
garyp01
#1 Posted : Wednesday, May 7, 2025 9:10:12 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 10/3/2024(UTC)
Posts: 8
Location: United Kingdom

Thanks: 5 times
Was thanked: 2 time(s) in 2 post(s)
With Visual Studio Preview (current version: 17.14.0 Preview 6.0) and NCrunch 5.14.0.5, all projects show this error in NCrunch:

Quote:

System.InvalidOperationException: Sequence contains no matching element
at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
at nCrunch.Core.BuildManagement.ClientDotNetCoreSdkVersionSelector.OverrideDotNetCoreSdkForProcess(DotNetCoreSdkVersion dotNetCoreSdkVersion, ProcessLoadParameters parameters, IDEVersion vsVersion)
at nCrunch.Core.BuildManagement.BuildProcessLauncher.(EffectiveProcessorArchitecture , BuildSystemParameters , IList`1 , FilePath , DotNetCoreSdkVersion )
at nCrunch.Core.BuildManagement.BuildProcessLauncher..()
at nCrunch.Core.BuildManagement.BuildProcessLauncher.(Action`1 , EffectiveProcessorArchitecture , GridClientId , BuildSystemParameters , IList`1 , Nullable`1 , GridClientDescription , 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, IDEVersion ideVersion, BuildEngineId buildEngineId, ComponentUniqueName componentName, TaskSettings componentTaskSettings, Exception parseException, String targetFrameworkForMsbuild, String visibleTargetFramework)


17.14.0 Preview 6.0 comes with .NET SDK 9.0.300-preview.0.25177.5.

I appreciate that you may not support preview versions, but this used to work and I've seen this error for the last few preview releases, so thought it worth raising in case the same problem may affect the release branch at some point.

Do you know what might be causing this?
Remco
#2 Posted : Wednesday, May 7, 2025 10:15:05 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 987 times
Was thanked: 1325 time(s) in 1228 post(s)
Hi, thanks for sharing this issue.

I think this is an edge case in the SDK selection, related to the build's 'preview' status (unfortunately this is a thing, we need special handling for when VS is in a preview state, which isn't required when it goes RTM).

Could you confirm if you have any non preview SDKs installed on your machine? Or whether adjusting the 'Build SDK' NCrunch configuration setting makes any difference?
garyp01
#3 Posted : Wednesday, May 7, 2025 10:48:39 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 10/3/2024(UTC)
Posts: 8
Location: United Kingdom

Thanks: 5 times
Was thanked: 2 time(s) in 2 post(s)
Thanks for the prompt reply.

Querying 'dotnet sdk check' advises that I only have the 9.0.300-preview.0.25177.5 SDK installed, along with several runtime versions.

Setting the 'Build SDK' setting to '9.0.300-preview.0.25177.5' or any other setting, such as 'VS2022', causes NCrunch to re-initialise but then to fail with the same exception as above.
Remco
#4 Posted : Wednesday, May 7, 2025 8:05:14 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 987 times
Was thanked: 1325 time(s) in 1228 post(s)
Thanks for confirming this. I've implemented a fix for this that will be out with the next build. It should be possible to work around this using environment variables.

Under your global NCrunch configuration, find the setting 'Custom environment variables'.

You need to enter two variables into this setting:
DOTNET_MSBUILD_SDK_RESOLVER_SDKS_DIR = C:\Program Files\dotnet\sdk\9.0.300-preview.0.25177.5\Sdks
DOTNET_MSBUILD_SDK_RESOLVER_SDKS_VER = 9.0.300-preview.0.25177.5

Adjust the paths as necessary if I've guessed your install directory incorrectly.

This should force the resolver to use a specific SDK.
1 user thanked Remco for this useful post.
garyp01 on 5/8/2025(UTC)
garyp01
#5 Posted : Thursday, May 8, 2025 7:57:56 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 10/3/2024(UTC)
Posts: 8
Location: United Kingdom

Thanks: 5 times
Was thanked: 2 time(s) in 2 post(s)
That did the trick - thank you! I look forward to the permanent fix.
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.036 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download