简体   繁体   English

“ValidateExecutableReferences”任务意外失败

[英]The "ValidateExecutableReferences" task failed unexpectedly

I'm using .NET 6.0.100, i created a new ASP.NET Core Web App.我正在使用 .NET 6.0.100,我创建了一个新的 ASP.NET Core Web 应用程序。 I added a new class library for .NET 6.0.100 as well and added the nuget package Microsoft.EntityFrameworkCore version 5.0.11.我还为 .NET 6.0.100 添加了一个新类库,并添加了 nuget 包 Microsoft.EntityFrameworkCore 版本 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).由于某些原因,我无法弄清楚,但我一直在为我的 Web 项目构建时遇到此错误,但仅在 Visual Studio 2022(预览版 2.0)中。 If i use the command line "dotnet build" it works but in visual studio i get this error.如果我使用命令行“dotnet build”,它可以工作,但在 Visual Studio 中我收到此错误。

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 Files\dotnet\sdk\6.0.100-rc.2.21505.57\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets  1092

The Microsoft.NET.Sdk.targets file referred in this exception contains the following :此异常中引用的 Microsoft.NET.Sdk.targets 文件包含以下内容:

<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.这不是主要问题,因为我可以使用命令行来构建我的项目,但我希望能够在 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.如果我删除对我的类库的引用,Web 项目正在构建,但只要我添加引用它就会停止。

Any idea on how to fix this issue?关于如何解决这个问题的任何想法?

我将 Visual Studio 2022 更新到最新版本(预览版 5.0)并且错误停止了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM