refit
refit copied to clipboard
[BUG] Unable to build Refit with MSBuild >= 17.x
Describe the bug Unable to build Refit with MSBuild 17.x.
Steps To Reproduce
- Install MSBuild >= 17
- run dotnet build.
- See error
refit/Refit/targets/refit.targets(45,11): error MSB4086: A numeric comparison was attempted on "$([System.Version]::Parse($(_RefitMSBuildMinVersion)).CompareTo($([System.Version]::Parse($(MSBuildVersion)))))" that evaluates to "−1" instead of a number, in condition " '$([System.Version]::Parse($(_RefitMSBuildMinVersion)).CompareTo($([System.Version]::Parse($(MSBuildVersion)))))' > '0' ". [/refit/Refit.Tests/Refit.Tests.csproj]
Expected behavior I expect to be able to build the project without errors.
If I remove the following condition from the targets file it builds as expected
<Target Name="_RefitMSBuildVersionCheck" Condition=" '$([System.Version]::Parse($(_RefitMSBuildMinVersion)).CompareTo($([System.Version]::Parse($(MSBuildVersion)))))' > '0' " BeforeTargets="ResolveAssemblyReferences;Build;Rebuild" > <Error Text = "Projects using Refit cannot build using MSBuild '$(MSBuildVersion)'. MSBuild '$(_RefitMSBuildMinVersion)' or later is required." /> </Target>
Environment .NET SDK (reflecting any global.json): Version: 6.0.400-preview.22330.6 Commit: da7c9ccceb
Runtime Environment: OS Name: Mac OS X OS Version: 12.4 OS Platform: Darwin RID: osx.12-arm64 Base Path: /usr/local/share/dotnet/sdk/6.0.400-preview.22330.6/
global.json file: Not found
Host: Version: 6.0.7 Architecture: arm64 Commit: 0ec02c8c96
.NET SDKs installed: 6.0.302 [/usr/local/share/dotnet/sdk] 6.0.400-preview.22330.6 [/usr/local/share/dotnet/sdk]
.NET runtimes installed: Microsoft.AspNetCore.App 6.0.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.7 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.7 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
MSBuild version 17.3.0-preview-22329-01+77c72dd0f for .NET
Any updates on this? I get this in Rider for Mac. Visual Studio for Mac seem to work, at least there is no error on build
@modplug I created a PR: Changed the condition of _RefitMSBuildVersionCheck
Not sure if this is the way, but it seems to work.
Hopefully this PR will be accepted in some near future....
I figured out what was causing the issue.
My computer was set to Norwegian locale and once I switched to English I got Refit to build again. https://github.com/dotnet/msbuild/issues/5502
This is not an acceptable fix
I agree, but the error is in MSBuild and not Refit. Refit make use of a version comparison which fails within MSBuild
I had the exact same problem (MacOS, norwegian system).
You can disable internationalization in MSBuild: https://learn.microsoft.com/en-us/dotnet/core/runtime-config/globalization
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1 dotnet build
Learn about run-time settings that configure globalization aspects of a .NET Core app, for example, how it parses Japanese dates.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.