Open phil-warner opened 2 months ago
That failing props line is from msbuild so transferring: https://github.com/dotnet/msbuild/blob/vs17.10/src/Tasks/Microsoft.NETFramework.CurrentVersion.props
Microsoft.NETFramework.CurrentVersion.props compares $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '4.0'))
.
Microsoft.NET.TargetFrameworkInference.targets would set <TargetFrameworkVersion>v$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)', 2))</TargetFrameworkVersion>
, which should evaluate to v7.0
when $(TargetFramework)
is net7.0
.
Either something else sets the TargetFrameworkVersion property incorrectly, or the GetTargetFrameworkVersion intrinsic function returns the wrong value.
To check whether GetTargetFrameworkVersion works correctly in your environment, can you try to build this project:
<Project>
<Target Name="Evaluate">
<!-- Made this an error so that Terminal Logger won't hide it. -->
<Error Text="Result: $([MSBuild]::GetTargetFrameworkVersion('net7.0', 2))" />
</Target>
</Project>
On Windows, I see output like:
MSBuild version 17.10.4+10fbfbf2e for .NET
C:\TEMP\target.proj(4,5): error : Result: 7.0
If you get "Result: net7.0" instead, then it seems a NuGet problem, as GetTargetFrameworkVersion is implemented there.
If you get the correct "Result: 7.0", then perhaps something in your project or in a referenced NuGet package sets TargetFrameworkVersion wrong. https://github.com/dotnet/msbuild/issues/2711#issuecomment-1176263310 may help locate the cause.
Hi. Thank you. I get the following from terminal on MacOS:
Build FAILED.
/Users/***/Documents/GitHub/test.csproj(4,5): error : Result: 7.0
0 Warning(s)
1 Error(s
How do I use 'export MsBuildLogPropertyTracking=3'?
That project file looks like a weird hybrid between a modern .NET SDK project (which you'd need to target net7.0
) and an older .NET Framework-targeting project. OpenAPI generator 3.0.1 is very old (.NET Core 2.1 timeframe)--are you sure it supports this type of output?
Hi @rainersigwald. The generator version being used is 5.4.0, which is downloaded by the generator when we set the targetFramework parameter. The version of the OpenAPI spec is 3.0.1 - sorry for any confusion.
@phil-warner Ok, but that project is still pretty nonsensical. I would recommend pursuing that aspect of things.
Which aspects look wrong to you @rainersigwald ?
The project has <TargetFramework>net7.0</TargetFramework>
but not <Project Sdk="Microsoft.NET.Sdk">
.
@phil-warner any luck looking at the generator side? And just to confirm, you were using -g csharp-netcore
?
@phil-warner any luck looking at the generator side? And just to confirm, you were using
-g csharp-netcore
?
No luck, seemingly. This is my command to generate the client (I can't seem to find a reference to 'csharp-netcore'):
openapi-generator-cli generate -i https://api.thesmsworks.co.uk/docs/openapi.json -g csharp --additional-properties=targetFramework=net6.0 --additional-properties=optionalAssemblyInfo -o smsw-csharp-netcore6
Describe the bug
When running dotnet build I get the following error:
/usr/local/share/dotnet/sdk/8.0.302/Microsoft.NETFramework.CurrentVersion.props(117,25): error MSB4184: The expression "[MSBuild]::VersionGreaterThanOrEquals(net7.0, 4.0)" cannot be evaluated.
To Reproduce
csproj file (truncated for brevity) as follows:
Further technical details
The output of
dotnet --info
is as follows: