FSharp.Analyzers.SDK icon indicating copy to clipboard operation
FSharp.Analyzers.SDK copied to clipboard

Utilize Fsc args in msbuild analyze if available

Open TheAngryByrd opened this issue 4 months ago • 4 comments

This kind of revitalizes https://github.com/ionide/FSharp.Analyzers.SDK/pull/164, but this takes a slightly different approach.

  • Instead of trying to do a DesignTimeBuild within msbuild, it will try to run after a CoreCompile/AfterBuild target actually runs.
  • This uses the RunAnalyzer or RunAnalyzersDuringBuild (see Roslyn variables) to determine if it should run or not.
  • This will skip the FsharpAnalyzerAfterBuild target if CoreCompile does not produce FscArgs. However someone can use FSharpAnalyzers_AlwaysRunAfterBuild to always run after a build, still using Ionide.ProjInfo as before to do design time builds.

TheAngryByrd avatar Jul 27 '25 19:07 TheAngryByrd

Wow, this looks amazing! Will play with this when I can!

nojaf avatar Aug 02 '25 19:08 nojaf

This follows incremental builds so it won't run unless CoreCompile produces FscArgs.

I'm hearing you say that the output Property/Item isn't being set on purely-incremental builds. I'm not sure that is expected behavior - I'd expect that an incrementally-skipped Target would emit its outputs.

baronfel avatar Aug 02 '25 19:08 baronfel

I'd expect that an incrementally-skipped Target would emit its outputs.

Yeah it's not really incremental usingg the Inputs/Outputs semantics, only running conditionally when FscCommandLineArgs gets set from a CoreCompile.

TheAngryByrd avatar Aug 02 '25 19:08 TheAngryByrd

Ok updated my comment on incremental builds, since following Inputs/Outputs would probably be too much effort.

TheAngryByrd avatar Aug 03 '25 20:08 TheAngryByrd