The "ValidateExecutableReferences" task failed unexpectedly

  Uncategorised

I’m using .NET 6.0.100, i created a new ASP.NET Core Web App. I added a new class library for .NET 6.0.100 as well and added the nuget package Microsoft.EntityFrameworkCore version 5.0.11. For some reasons i can’t figure out yet i keep getting this error on build for my web project but only in Visual Studio 2022 (Preview 2.0). If i use the command line "dotnet build" it works but in visual studio i get this error.

Error   MSB4018 The "ValidateExecutableReferences" task failed unexpectedly.
System.InvalidOperationException: Sequence contains no elements
   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
   at Microsoft.NET.Build.Tasks.ValidateExecutableReferences.ExecuteCore()
   at Microsoft.NET.Build.Tasks.TaskBase.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() MyWebAPI    C:Program Filesdotnetsdk.0.100-rc.2.21505.57SdksMicrosoft.NET.SdktargetsMicrosoft.NET.Sdk.targets  1092

The Microsoft.NET.Sdk.targets file referred in this exception contains the following :

<Target Name="ValidateExecutableReferences"
AfterTargets="_GetProjectReferenceTargetFrameworkProperties"
Condition="'$(ValidateExecutableReferencesMatchSelfContained)' != 'false'">

<ValidateExecutableReferences
SelfContained="$(SelfContained)"
IsExecutable="$(_IsExecutable)"
ReferencedProjects="@(_MSBuildProjectReferenceExistent)"
UseAttributeForTargetFrameworkInfoPropertyNames="$(_UseAttributeForTargetFrameworkInfoPropertyNames)"
/>

It’s not a major issue since i can use the command line to build my projects but i would like to be able to build in Visual Studio 2022.

If i remove the reference to my class library the web project is building but as soon as i add the reference it stop.

Any idea on how to fix this issue?

Source: Visual Studio Questions

LEAVE A COMMENT