Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A numeric comparison was attmepted on "$(MSBuildVersion)" that evaluates to "" instead of a number, in condition "$(MSBuildVersion) >= 16.1.0")"

I get this error when I try to reload my project that I had unloaded as shown in the screenshot below:

enter image description here

It says this line is from my Microsoft.Managed.Core.targets

  • I tried updating my NuGet packages.
  • I tried changing my Environment Variable path value to where msbuild.exe is located
  • I tried looking for a solution to change the Microsoft.Managed.Core.targets to ignore that check, but I don't think that is a good solution

Failure happens here. I believe this is the line that fails. Below is from my microsoft managed.core.targets

 <Import Project="Microsoft.Managed.EditorConfig.targets" Condition="$(MSBuildVersion) >= 16.1.0" /> 

This is from microsoft.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>
like image 386
Alajay Varona Avatar asked Jul 29 '19 20:07

Alajay Varona


3 Answers

The way I was able to fix this was by simply restarting Visual Studio

like image 61
kristofvdj88 Avatar answered Oct 23 '22 19:10

kristofvdj88


This is the same error that I'm getting as well.

A numeric comparison was attempted on "$(MSBuildVersion)" that evaluates to "" instead of a number, in condition "$(MSBuildVersion) >= 16.1.0".

The way I resolved this was by going and checking for updates in Visual Studio and ensuring I had the latest version of visual studio.

From this site, Andy Gocke of Microsoft writes:

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.

Hope this helps!

like image 2
Shiroy Avatar answered Oct 23 '22 18:10

Shiroy


Microsoft (MS) Build tool on your machine is not up-to-date. The Visual Studio (VS) 2017 Integrated Development Environment (IDE) on your machine is looking for MS build tool version 16.1.0. It is evident from the version number 16.1.0 in your error message. You should update VS 2017 to latest revision to update MS build tool to latest version. When you open VS Installer EXE on your machine then you'll see an Update button in the VS 2017 section if your Visual Studio install is not up-to-date as shown in the screenshot below:

enter image description here

Click on the Update button to update VS which will internally update MS build tool as well. Start Visual Studio after the completion of update setup. Open your solution again and reload the project which is currently unloaded. It should load fine now.

like image 2
RBT Avatar answered Oct 23 '22 19:10

RBT