Framework targeting incorrect
See original GitHub issueHello,
There seems to be an issue with the framework targeting for the NuGet package. If you look at the package on NuGet then it appears that there are no dependencies listed. This is strange, I expected to see System.Memory somewhere.
Also, the performance improvements (that use Span) do not seem to be part of the NuGet package.
The netstandard2.1
assembly in the package still has the ‘old’ signatures that use arrays, as seen below in the ILdasm screenshot.
I believe the error is in the way the HAS_SPAN
compile time constant is defined.
Currently it is:
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0|net452|net462|net472'">
<PackageReference Include="System.Memory" Version="4.5.3" />
</ItemGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1|netstandard2.1|netstandard2.0|net452|net462|net472'">
<DefineConstants>$(DefineConstants);HAS_SPAN</DefineConstants>
</PropertyGroup>
As far as I know the MSBuild ‘==’ operator performs an exact string match.
I believe that this is the correct way to define the dependency and constant:
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'
or '$(TargetFramework)' == 'net452'
or '$(TargetFramework)' == 'net462'
or '$(TargetFramework)' == 'net472'">
<PackageReference Include="System.Memory" Version="4.5.3" />
</ItemGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'
or '$(TargetFramework)' == 'netstandard2.1'
or '$(TargetFramework)' == 'netstandard2.0'
or '$(TargetFramework)' == 'net452'
or '$(TargetFramework)' == 'net462'
or '$(TargetFramework)' == 'net472'">
<DefineConstants>$(DefineConstants);HAS_SPAN</DefineConstants>
</PropertyGroup>
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Troubleshoot .NET Framework targeting errors
To resolve the error, make sure that your application targets a .NET version that's compatible with the version that's targeted by the ...
Read more >Targeted .NET Frameworks - Visual Studio (Windows)
Framework targeting helps guarantee that the application uses only functionality that is available in the specified framework version. For .NET ...
Read more >Cannot Change Target Framework?
I came across this problem this morning that I can't change the target framework of an open source project. The Target framework option...
Read more >Confusing error message when invalid target frameworks ...
In that case, the SDKs seems to be able to parse the TFMs and the build fails with an error that indicates missing...
Read more >Incorrect Target framework in .csproj file after changing ...
NET 8 for WinUI project. Incorrect Target framework in .csproj file after changing Target framework from .NET 6.0 to.NET 7.0 in Properties.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Awesome, thanks for the quick fix 😄
from .net 4.8 project