在条件“$(MSBuildVersion) >= 16.1.0”) 下,对“$(MSBuildVersion)”进行数值比较,结果为“”而不是数字

Ala*_*ona 10 visual-studio

当我尝试重新加载我已卸载的项目时出现此错误,如下面的屏幕截图所示:

在此处输入图片说明

它说这条线来自我的 Microsoft.Managed.Core.targets

  • 我尝试更新我的 NuGet 包。
  • 我尝试将我的环境变量路径值更改为 msbuild.exe 所在的位置
  • 我尝试寻找一种解决方案来更改 Microsoft.Managed.Core.targets 以忽略该检查,但我认为这不是一个好的解决方案

失败发生在这里。我相信这是失败的线路。以下来自我的microsoft managed.core.targets

 <Import Project="Microsoft.Managed.EditorConfig.targets" Condition="$(MSBuildVersion) >= 16.1.0" /> 
Run Code Online (Sandbox Code Playgroud)

这是来自 micrrosoft.managed.editorconfig.targets

<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright (c)  Microsoft.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information. -->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <PropertyGroup>
    <!-- Default this to false until the ".editorconfig in compiler" feature is no longer experimental.
         At that point this PropertyGroup can simply be deleted. -->
    <DiscoverEditorConfigFiles Condition="'$(DiscoverEditorConfigFiles)' == ''">false</DiscoverEditorConfigFiles>



  </PropertyGroup>

  <ItemGroup>
    <PotentialEditorConfigFiles Include="@(Compile->GetPathsOfAllDirectoriesAbove()->Combine('.editorconfig'))" Condition="'$(DiscoverEditorConfigFiles)' != 'false'" />
    <EditorConfigFiles Include="@(PotentialEditorConfigFiles->Exists())" Condition="'$(DiscoverEditorConfigFiles)' != 'false'" />
  </ItemGroup>


</Project>
Run Code Online (Sandbox Code Playgroud)

kri*_*j88 14

我能够解决这个问题的方法是简单地重新启动 Visual Studio

  • 就这么简单!也为我解决了,谢谢 (2认同)

Shi*_*roy 2

这也是我遇到的错误。

在条件“$(MSBuildVersion) >= 16.1.0”下,尝试对“$(MSBuildVersion)”进行数字比较,结果为“”而不是数字。

我解决此问题的方法是检查 Visual Studio 中的更新并确保我拥有最新版本的 Visual Studio。

微软的安迪·戈克 (Andy Gocke) 在该网站上写道:

The Microsoft.Net.Compilers package requires newer versions of MSBuild as Visual Studio updates, so the 3.1.0 version requires MSBuild version 16.1.
Run Code Online (Sandbox Code Playgroud)

希望这可以帮助!