OpenSolutionAsync - 找不到字段:.NET Framework 4.8 / 4.7.2 上的“Microsoft.Build.Utilities.ChangeWaves.Wave16

Posted

技术标签:

【中文标题】OpenSolutionAsync - 找不到字段:.NET Framework 4.8 / 4.7.2 上的“Microsoft.Build.Utilities.ChangeWaves.Wave16_8”【英文标题】:OpenSolutionAsync - Field not found: 'Microsoft.Build.Utilities.ChangeWaves.Wave16_8' on .NET Framework 4.8 / 4.7.2 【发布时间】:2022-01-08 00:46:58 【问题描述】:

此代码在 .NET 6 上运行良好,

但是当我想在 .NET Framework 4.8 上运行它时,这就是我收到的

System.MissingFieldException: Field not found: 'Microsoft.Build.Utilities.ChangeWaves.Wave16_8'.
at Microsoft.Build.Evaluation.Expander`2.IsTruncationEnabled(ExpanderOptions options)
at Microsoft.Build.Evaluation.Expander`2.PropertyExpander`1.ExpandPropertiesLeaveTypedAndEscaped(String expression, IPropertyProvider`1 properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties, IFileSystem fileSystem)
at Microsoft.Build.Evaluation.Expander`2.PropertyExpander`1.ExpandPropertiesLeaveEscaped(String expression, IPropertyProvider`1 properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties, IFileSystem fileSystem)
at Microsoft.Build.Evaluation.Expander`2.ExpandIntoStringLeaveEscaped(String expression, ExpanderOptions options, IElementLocation elementLocation)
at Microsoft.Build.Evaluation.ToolsetReader.ExpandPropertyUnescaped(ToolsetPropertyDefinition property, Expander`2 expander)
at Microsoft.Build.Evaluation.ToolsetReader.EvaluateAndSetProperty(ToolsetPropertyDefinition property, PropertyDictionary`1 properties, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties, String& toolsPath, String& binPath, Expander`2& expander)
at Microsoft.Build.Evaluation.ToolsetReader.ReadToolset(ToolsetPropertyDefinition toolsVersion, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties)
at Microsoft.Build.Evaluation.ToolsetReader.ReadEachToolset(Dictionary`2 toolsets, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties)
at Microsoft.Build.Evaluation.ToolsetReader.ReadToolsets(Dictionary`2 toolsets, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties, String& msBuildOverrideTasksPath, String& defaultOverrideToolsVersion)
at Microsoft.Build.Evaluation.ToolsetReader.ReadAllToolsets(Dictionary`2 toolsets, ToolsetRegistryReader registryReader, ToolsetConfigurationReader configurationReader, PropertyDictionary`1 environmentProperties, PropertyDictionary`1 globalProperties, ToolsetDefinitionLocations locations)
at Microsoft.Build.Evaluation.ProjectCollection.InitializeToolsetCollection(ToolsetRegistryReader registryReader, ToolsetConfigurationReader configReader)
at Microsoft.Build.Evaluation.ProjectCollection..ctor(IDictionary`2 globalProperties, IEnumerable`1 loggers, IEnumerable`1 remoteLoggers, ToolsetDefinitionLocations toolsetDefinitionLocations, Int32 maxNodeCount, Boolean onlyLogCriticalEvents, Boolean loadProjectsReadOnly)
at Microsoft.CodeAnalysis.MSBuild.Build.ProjectBuildManager.StartBatchBuild(IDictionary`2 globalProperties) at /_/src/Workspaces/Core/MSBuild/MSBuild/Build/ProjectBuildManager.cs:line 161
at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.Worker.<LoadAsync>d__19.MoveNext() at /_/src/Workspaces/Core/MSBuild/MSBuild/MSBuildProjectLoader.Worker.cs:line 134
--- End of the stack trace from the previous location where the exception occurred  ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.<LoadSolutionInfoAsync>d__22.MoveNext() at /_/src/Workspaces/Core/MSBuild/MSBuild/MSBuildProjectLoader.cs:line 218
--- End of the stack trace from the previous location where the exception occurred  ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.<OpenSolutionAsync>d__24.MoveNext() at /_/src/Workspaces/Core/MSBuild/MSBuild/MSBuildWorkspace.cs:line 204
--- End of the stack trace from the previous location where the exception occurred  ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()

这是代码

using System;
using System.Linq;
using Microsoft.CodeAnalysis;
using System.Threading.Tasks;
using Microsoft.Build.Locator;
using System.Collections.Generic;
using Microsoft.CodeAnalysis.MSBuild;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using System.IO;

...
MSBuildLocator.RegisterDefaults();
var msWorkspace = MSBuildWorkspace.Create();

var solution = await msWorkspace.OpenSolutionAsync(pathToSln); <--- fails here
...

我当然有:

这是我的其他 nugets:

有人知道我可能缺少什么吗?

【问题讨论】:

【参考方案1】:

我需要添加Microsoft.Buildnuget

【讨论】:

以上是关于OpenSolutionAsync - 找不到字段:.NET Framework 4.8 / 4.7.2 上的“Microsoft.Build.Utilities.ChangeWaves.Wave16的主要内容,如果未能解决你的问题,请参考以下文章

找不到字段的映射

EF Core 5 - 支持字段:找不到属性的指定字段

错误:找不到字段的设置器 - 房间

PHP表单找不到空字段

在“...”字段中找不到名称为“...”的参数

Android Studio:房间:错误:找不到字段的吸气剂