Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 31, 2025

Fixes #266. FSC compiler arguments can exceed the 9020 character CLI limit when building projects with many source files or complex configurations, causing build failures.

Changes

CLI (Program.fs)

  • Add --fsc-args-file parameter accepting path to RSP file
  • Implement readFscArgsFromFile: line-by-line parser with comment support (# prefix)
  • Validate mutual exclusivity of --fsc-args and --fsc-args-file

MSBuild Integration (FSharp.Analyzers.Build.targets)

  • Write FscCommandLineArgs to {IntermediateOutputPath}/fsc-analyzers.rsp via WriteLinesToFile task
  • Pass --fsc-args-file with RSP path instead of inline arguments
  • Fallback to --fsc-args when RSP unavailable (backward compatibility)

Usage

Generated RSP files are transparent to users. Manual invocation:

dotnet fsharp-analyzers --fsc-args-file path/to/fsc-analyzers.rsp --analyzers-path ./analyzers

RSP format (one argument per line):

# Comments supported
-o:/path/to/output.dll
--define:DEBUG
--optimize+
Program.fs
Original prompt

This section details on the original issue you should resolve

<issue_title>Add support for passing FSC command-line arguments via RSP file to avoid 9020 CLI arg limit</issue_title>
<issue_description>## Context
This is a sub-issue for #266 (Running Analyzers During Build Gets 9020 Response), which is caused by exceeding the command-line argument limit when invoking FSC with very large sets of arguments during build.

Tasks

  • Update src/FSharp.Analyzers.Build/build/FSharp.Analyzers.Build.targets to take the output from FscCommandLineArgs and write those arguments into an .rsp file inside the IntermediateOutputPath.
  • Add a new CLI argument to src/FSharp.Analyzers.Cli/Program.fs to accept the path to this RSP file, and update the logic so that it reads in the file and uses the arguments as if they were passed via the existing FSC_Args parameter (same logical flow).
  • Update _FSharpAnalyzersProjectOptions to use this new parameter and pass in the filepath to the generated RSP file during build.

Acceptance Criteria

  • When invoked during build, the analyzers use the arguments from the RSP file rather than direct CLI args.
  • It should be possible to run the CLI tool manually using the new RSP argument.
  • This should prevent the 9020 error (argument limit exceeded) when running analyzers as part of the build process.

Related to: #266</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits October 31, 2025 15:04
Co-authored-by: TheAngryByrd <[email protected]>
- Add new --fsc-args-file CLI parameter to accept RSP file path
- Implement readFscArgsFromFile function to parse RSP files
- Update MSBuild targets to write FscCommandLineArgs to RSP file in IntermediateOutputPath
- Use RSP file in build to avoid CLI argument limit issues
- Add validation to prevent using both --fsc-args and --fsc-args-file together

Co-authored-by: TheAngryByrd <[email protected]>
- Update documentation to accurately reflect line-by-line parsing
- Use Array.choose instead of filter + map to avoid duplicate trimming
- Optimize by trimming once and reusing the result

Co-authored-by: TheAngryByrd <[email protected]>
Copilot AI changed the title [WIP] Add support for passing FSC command-line arguments via RSP file Add RSP file support for FSC arguments to bypass CLI length limits Oct 31, 2025
Copilot AI requested a review from TheAngryByrd October 31, 2025 15:24
@nojaf
Copy link
Contributor

nojaf commented Oct 31, 2025

😋 gotta love a good rsp file, love it 🥰

@TheAngryByrd TheAngryByrd marked this pull request as ready for review November 1, 2025 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for passing FSC command-line arguments via RSP file to avoid 9020 CLI arg limit Running Analyzers During Build Gets 9020 Response

3 participants