How to set GodotProjectDir for Nunit Project

Godot Version

v4.4.1.stable.mono.official [49a5bc7b6]

JetBrains Rider 2025.1.4
Framework net9.0, C# LangVersion 12.0

Question

How do I remove this warning when building my NUnit test project (poco tests – no Godot tests)?

Warning CS8785 : Generator 'ScriptPathAttributeGenerator' failed to generate source.
It will not contribute to the output and compilation errors may occur as a result.
Exception was of type 'InvalidOperationException' with message 'Property 'GodotProjectDir' is null or empty.'.

the csproj file starts with:
<Project Sdk="Microsoft.NET.Sdk">
and has no Godot project settings – I assume it’s the
<Using Include="NUnit.Framework"/>
causing the Godot.SourceGenerators analyzer to get included.

I’ve tried the PropertyGroup <IsTestProject>true</IsTestProject>, but the warning persists.
I’ve tried setting GodotProjectDir a number of ways in the csproj file.
I’ve blocked all analyzers, this removes warning but then the test cases are not available in the Test Viewer.

<Using Include="NUnit.Framework"/> only adds the NUnit.Framework as a global using and would have no effect in packages or analyzers included in a compilation.

Perhaps there is something else in your .csproj adding the dependency, or maybe in your Directory.Build.props. It may help to share your project, so we can take a look.