Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSharpier_FrameworkVersion is unreliable #1027

Closed
Tyrrrz opened this issue Nov 18, 2023 · 2 comments · Fixed by #1034
Closed

CSharpier_FrameworkVersion is unreliable #1027

Tyrrrz opened this issue Nov 18, 2023 · 2 comments · Fixed by #1034
Milestone

Comments

@Tyrrrz
Copy link
Contributor

Tyrrrz commented Nov 18, 2023

I don't have .NET 7.0 SDK installed anymore, since I've moved my projects off to .NET 8.0. CSharpier_FrameworkVersion sometimes incorrectly resolves to .NET 7.0 due to unreliable heuristics:

<CSharpier_FrameworkVersion Condition="'$(CSharpier_FrameworkVersion)' == ''">$(TargetFramework)</CSharpier_FrameworkVersion>
<CSharpier_FrameworkVersion Condition="'$(CSharpier_FrameworkVersion)' != 'net6.0' and '$(CSharpier_FrameworkVersion)' != 'net7.0' and '$(CSharpier_FrameworkVersion)' != 'net8.0'">net7.0</CSharpier_FrameworkVersion>

The two most common scenarios are:

  • The project is a library that targets .NET Standard 2.1, but .NET 8.0 SDK is used to build it.
  • The project is targeting a superset of .NET 8.0, for example net8.0-windows.

In either of these cases, CSharpier resolves to the .NET 7.0 version of the tool, which may not be able to execute (as in my case).

My suggestion is to not rely on the TargetFramework property for this, but instead use the current SDK version, which can be extracted from the NETCoreSdkVersion property, as defined by one of the built-in imports.

image

@domn1995
Copy link
Sponsor Contributor

I believe I'm running into this issue in my source generator project. Here's the build output if it helps:
https://github.com/domn1995/dunet/actions/runs/6900832597/job/18802795139?pr=187

@belav
Copy link
Owner

belav commented Nov 22, 2023

I believe I'm running into this issue in my source generator project. Here's the build output if it helps: https://github.com/domn1995/dunet/actions/runs/6900832597/job/18802795139?pr=187

That sounds like a problem with the nuget package not being restored correctly, I don't think I've seen that. I know one of the net8 RC's had some issues around restoring tools, but it looks like you are on the official release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants