Skip to content

build: drop the .NET Framework target#2365

Open
mjcheetham wants to merge 4 commits into
git-ecosystem:vnextfrom
mjcheetham:netfx-drop
Open

build: drop the .NET Framework target#2365
mjcheetham wants to merge 4 commits into
git-ecosystem:vnextfrom
mjcheetham:netfx-drop

Conversation

@mjcheetham

Copy link
Copy Markdown
Contributor

Summary

Git Credential Manager no longer targets .NET Framework. This drops the net472 TFM everywhere, leaving net10.0 as the single target on all platforms (Windows included), then deletes the code that only existed to support the old runtime and tightens our OS-platform guarantees.

Why

The product builds against the CoreCLR on every platform now. The .NET Framework target only added a second build pivot, a pile of conditional code, and Windows-only baggage. Collapsing to one modern TFM simplifies the build, the source, and everything downstream (packaging, CI, trimming/AOT work that follows).

What changes

  • Drop net472 from all projects and build scripts. Windows now builds the single net10.0 TFM like every other platform.
  • Remove dead #if NETFRAMEWORK code. With only the CoreCLR left, this code was unreachable.
  • Add [SupportedOSPlatform] attributes to OS-specific types so use of platform-specific behaviour is gated at compile time.
  • Suppress CA1416 in test projects. Our xUnit attributes ([WindowsFact], [PosixFact], …) skip OS-specific tests at runtime; the analyzer can't see that, so the warning is noise in tests.

Caveat

Removing the .NET Framework target also removes the embedded web view for Microsoft authentication — a netfx-only, Windows-only feature. The goal will be to move to the Windows "WAM" broker by default before release to replace the UX offered by embedded wv.

Drop the .NET Framework target (net472) from all projects and build
scripts. Windows builds will now target the, only, TFM of `net10.0`.

Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
Remove all code that was conditional on a .NET Framework target. Now
that we're only building against the CoreCLR, this code was dead.

Note that we now lose the ability to use the embedded web view for
Microsoft authentication, which was a .NET Framework-only feature (and
therefore Windows only). Support for embedded web view flows will be
restored at a later date via Avalonia WebView.

Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
Add the SupportedOSPlatform attributes to types that only run on the
relevant specific OS platform. This will help ensure we're always gating
use of OS-specific behaviour to that specific OS.

Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
Suppress the "This call site is reachable on all platforms" warning
for all test projects - we use custom Xunit attributes to dynamically
skip OS-specific tests unless the test is running on the appropriate OS.
The analyzer for CA1416 does not know how to handle this.

Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
@mjcheetham mjcheetham requested review from a team as code owners June 29, 2026 13:39
@mjcheetham mjcheetham added engineering Refactoring or build changes gcm3.0 Targets the next major release of Git Credential Manager - v3.0 platform:windows Specific to the Windows platform labels Jun 29, 2026

@derrickstolee derrickstolee left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I expected the framework version of the code to be deleted with the removal of the #if NETFRAMEWORK macros, but some chunks are keeping the framework version.

I suspect that the project dependencies that changed to match the core version make the framework-specific code now work in the core version, but I'm not able to connect the dots myself.

Thus, I only commented on the places where I saw the code stick instead of a deletion, just as a way for you to confirm that these are all intentianal.

Comment thread src/shared/Core/Authentication/MicrosoftAuthentication.cs
Comment thread src/shared/Core/Authentication/MicrosoftAuthentication.cs
Comment thread src/shared/Core/Authentication/MicrosoftAuthentication.cs
Comment on lines -961 to -964
#else
// OS broker requires .NET Framework right now until we migrate to .NET 5.0 (net5.0-windows10.x.y.z)
return false;
#endif

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ah, so since we have migrated we now have a different broker? Interesting.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is a stale comment. The MSAL team moved to a different model (MSAL Runtime + native broker interop library) since this was written. We will still be using the same broker access model on Windows as before.

// {
// throw new Trace2InvalidOperationException(Context.Trace2,
// "Embedded web view is not available without a desktop session.");
// }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Intentional commented-out-code?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes. There is a larger story behind this, sadly. If we wish to drop .NET Framework but also keep the embedded webview on Windows we'd need to bring along the Chromium-based WebView2 component, which is huge.

Instead we are going to look at one of two options:

  • Avalonia WebView (which uses the OS-bundled webview component, or the IE fallback on Windows),
  • dropping embedded entirely, and rely on Broker.

Comment thread src/shared/Core/UI/AvaloniaUi.cs
Comment thread src/shared/Core/PlatformUtils.cs
Comment thread src/shared/Core/PlatformUtils.cs
Comment thread src/shared/Core/UI/AvaloniaUi.cs
Comment thread src/shared/Core/Interop/Windows/WindowsSettings.cs
@mjcheetham

mjcheetham commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

I expected the framework version of the code to be deleted with the removal of the #if NETFRAMEWORK macros, but some chunks are keeping the framework version.

I understand the confusion. There are two cases where we had done #if NETFRAMEWORK conditional compilation:

  1. where we needed to use a different API for .NET Framework, or
  2. we wanted to compile-away something that was Windows-specific.

Many of these you are rightly confused by are the latter. Since we knew Windows was .NET Framework, and Mac/Linux was .NET Core, we could optimise at compile-time to strip extra code and dependencies from the Core (and therefore Mac/Linux) builds.

Now every OS is using .NET Core, we must keep the Windows-only functionality in all builds, but gated behind a IsWindows runtime check.

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

Labels

engineering Refactoring or build changes gcm3.0 Targets the next major release of Git Credential Manager - v3.0 platform:windows Specific to the Windows platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants