Skip to content

Fix startup crash on .NET 11+ (#710) - #715

Open
nil4 wants to merge 1 commit into
Fallout-build:developfrom
nil4:develop
Open

nil4 wants to merge 1 commit into
Fallout-build:developfrom
nil4:develop

Conversation

@nil4

@nil4 nil4 commented Oct 15, 2026 •

Copy link
Copy Markdown

Fixes #710

When targeting net11.0 or running on .NET 11 (e.g. via RollForward=Major), Fallout projects crash on startup with:

System.TypeInitializationException: The type initializer for 'Fallout.Common.FalloutBuild' threw an exception.
---> System.ArgumentException: Expected condition to be true (Parameter 'assemblyLocation == string.Empty || assemblyLocation == invokedLocation')

Testing .NET 11 RC1 and RC2 on macOS and Windows, the clause assemblyLocation == invokedLocation no longer holds.

On macOS:

  • assemblyLocation = "Fallout/build/bin/Debug/_build.dll"
  • invokedLocation = "Fallout/build/bin/Debug/_build"

On Windows:

  • assemblyLocation = "Fallout\build\bin\Debug\_build.dll"
  • invokedLocation = "Fallout\build\bin\Debug\_build.exe"

Update the assertion to canonicalize extensions to .dll before comparing.

Fixes Fallout-build#710

When targeting `net11.0` or running on .NET 11, Fallout projects crashed on startup with:

> System.TypeInitializationException: The type initializer for 'Fallout.Common.FalloutBuild' threw an exception.
> ---> System.ArgumentException: Expected condition to be true (Parameter 'assemblyLocation == string.Empty || assemblyLocation == invokedLocation')

Testing .NET 11 RC1 and RC2 on macOS and Windows, the clause `assemblyLocation == invokedLocation` no longer holds.

On macOS:
- assemblyLocation = "Fallout/build/bin/Debug/_build.dll"
- invokedLocation  = "Fallout/build/bin/Debug/_build"

On Windows:
- assemblyLocation = "Fallout\build\bin\Debug\_build.dll"
- invokedLocation  = "Fallout\build\bin\Debug\_build.exe"

Update the assertion to canonicalize extensions to `.dll` before comparing.
@nil4
nil4 requested a review from a team as a code owner October 15, 2026 11:28
@ChrisonSimtian ChrisonSimtian added needs-triage wontfix This will not be worked on and removed wontfix This will not be worked on labels Oct 15, 2026

@ChrisonSimtian ChrisonSimtian left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we please come up with some unit tests / specs for this as well?

@ChrisonSimtian ChrisonSimtian added the bug Something isn't working label Oct 15, 2026
@nil4

nil4 commented Oct 16, 2026 •

Copy link
Copy Markdown
Author

I am not sure this can be unit tested. The problem I see is that the FalloutBuild static constructor invokes this code path here:

static FalloutBuild()
{
RootDirectory = GetRootDirectory();
TemporaryDirectory = GetTemporaryDirectory(RootDirectory).CreateDirectory();
BuildAssemblyFile = GetBuildAssemblyFile();

Which means that, as soon as any member (static or instance) of FalloutBuild is accessed, the static constructor kicks in, calls GetBuildAssemblyFile, the assertion runs, and the TypeInitializationException can be thrown.

But since reproducing this requires either targeting net11.0, or running on .NET 11, I think that only a runtime/CI test would confirm it.

Would you be able to help with, for instance:

I think doing something like that should reproduce the issue as reported in #710 without this change, and confirm the fix with it. I don't think I can add such a test but I would appreciate it if a maintainer would be willing to try it.

@nil4

nil4 commented Oct 16, 2026

Copy link
Copy Markdown
Author

Perhaps the better fix would be to simply remove this assertion:

Assert.True(assemblyLocation == string.Empty || assemblyLocation == invokedLocation);

It worked up to and including .NET 10, but stops working as of .NET 11. It is now, and will likely continue to be, very impactful because it failing throws from the static constructor, making the FalloutBuild type effectively unusable.

Removing the assertion would at least give builds a chance of starting on .NET 11 and later. I can update the PR if you prefer this instead.

@ITaluone

Copy link
Copy Markdown
Contributor

Or you add some sort of a env var switch.. default behavior matches this behavior right now. If you know what you are doing, turn this assertion off.

like: FALLOUT_RUN_BUILD_ON_NET11 or similar

@nil4

nil4 commented Oct 16, 2026 •

Copy link
Copy Markdown
Author

I'll defer to the maintainers to decide, but I don't think adding an env var or any configurable knob is needed.

In my testing, builds worked once this assertion was removed or fixed to pass. assemblyLocation is returned from GetBuildAssemblyFile and invokedLocation never gets used.

Thus I see it as a matter of deciding whether the assertion is worth keeping; I'm not sure what value it provides, or what it is supposed to guard against. The downside of it failing, bringing everything down with it if/when that happens, seems disproportionate to any utility it might have had once.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working needs-triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET11-rc: Fails to run

3 participants