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

THIS001 warning on F# project #259

Closed
svdijk opened this issue Feb 28, 2023 · 3 comments · Fixed by devlooped/ThisAssembly#216
Closed

THIS001 warning on F# project #259

svdijk opened this issue Feb 28, 2023 · 3 comments · Fixed by devlooped/ThisAssembly#216
Labels
bydesign The feature works as designed

Comments

@svdijk
Copy link

svdijk commented Feb 28, 2023

Describe the Bug

When GitInfo is installed in an F# project, the following warning is emitted when the project is built:

C:\Users\<username>\.nuget\packages\thisassembly.prerequisites\1.2.9\build\netstandard2.0\ThisAssembly.Prerequisites.targets(16,5): warning THIS001: ThisAssembly requires Compiler API (Roslyn) version 4.0 or greater.

Steps to Reproduce

  • Create a new directory
  • Create an empty git repository in it
  • In Visual Studio, create a new F# Class Library project in this directory
  • Create an initial commit
  • Install GitInfo in the project
  • Build the project

Expected Behavior

Build without any warnings.

Version Info

  • Visual Studio 2022 (Version 17.4.5)
  • GitInfo 3.0.4

Additional Info

This seems to be specific to F# projects. When following the "Steps to Reproduce", but creating a C# Class Library project instead, this warning is not emitted.

Edit: I've added some debug messages to the file from which the THIS001 warning originates. For the C# project RoslynVersion is 4.4, but for the F# project RoslynVersion ends up at 0.0.

@svdijk svdijk added the bug label Feb 28, 2023
@kzu
Copy link
Member

kzu commented Mar 7, 2023

Yes, this is a C# only warning, but unfortunately, NuGet does not allow you to selectively take dependencies pivoting on the consuming project language.

So I'd suggest just adding a <NoWarn>THIS001</NoWarn> to your project, which should take care of it.

@kzu kzu added bydesign The feature works as designed and removed bug labels Mar 7, 2023
@svdijk
Copy link
Author

svdijk commented Mar 7, 2023

Thanks, I already did that as a test, but it's good to have it confirmed as the "official" solution/workaround.

I now have

<PropertyGroup Condition="'$(MSBuildProjectExtension)' == '.fsproj'">
  <NoWarn>THIS001</NoWarn>
</PropertyGroup>

in my Directory.Build.props (as there are both C# and F# projects in my solution). Perhaps something along these lines (probably a bit more fancy) could be considered for GitInfo? I think ThisAssembly should indeed emit this warning for an F# project, but for GitInfo it could be nice to prevent the warning from being emitted in this case.

@kzu
Copy link
Member

kzu commented Mar 10, 2023

Yeah, in thinking that perhaps the warning could check the language too and just skip it for F#...

kzu added a commit to devlooped/ThisAssembly that referenced this issue Mar 20, 2023
kzu added a commit to devlooped/ThisAssembly that referenced this issue Mar 20, 2023
kzu added a commit to devlooped/ThisAssembly that referenced this issue Mar 21, 2023
@devlooped devlooped locked and limited conversation to collaborators Sep 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bydesign The feature works as designed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants