Skip to content

Update odata-cli to target .NET 8 and .NET 10 - #449

Merged
WanjohiSammy merged 2 commits into
OData:masterfrom
aboryczko:feature/odata-cli-net8-net10
Sep 16, 2026
Merged

WanjohiSammy merged 2 commits into
OData:masterfrom
aboryczko:feature/odata-cli-net8-net10

Conversation

@aboryczko

Copy link
Copy Markdown
Contributor

Fixes #429
Fixes #324
Fixes #428
Fixes #448

odata-cli targets net6.0, which is out of support, so it crashes on startup with "No instances of MSBuild could be detected" when no net6 SDK is installed.

Multi-targets the CLI (and its tests) to net8.0;net10.0 and bumps Microsoft.Build.Locator to 1.11.2 so it locates the installed SDK's MSBuild. Also fixes the test project to register MSBuild — the part #432 missed that failed CI — and bumps the version to 0.4.0.

Tests pass on net8.0 and net10.0, and the packed tool runs generate on a .NET 8/10-only machine without the crash.

@aboryczko

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@aboryczko
aboryczko marked this pull request as ready for review May 31, 2026 14:27
@aboryczko

Copy link
Copy Markdown
Contributor Author

@gathogojr any chance on getting this merged?

@aboryczko

Copy link
Copy Markdown
Contributor Author

@habbes @marabooy any chance on getting this merged?

@xuzhg
xuzhg requested review from WanjohiSammy, Copilot and gathogojr and removed request for Copilot June 22, 2026 21:17

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0</TargetFrameworks>

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.

Targeting on .NET10 is enough?

@aboryczko aboryczko Jun 23, 2026

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.

Your call. Right now .NET 8 and 9 is supported till Nov 10, 2026. I wanted to keep the currently supported LTS versions, but I don't mind making it .NET 10 only

@xuzhg xuzhg mentioned this pull request Jun 22, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the odata-cli .NET tool to avoid startup failures on machines without a .NET 6 SDK by moving off net6.0 and improving MSBuild discovery/registration.

Changes:

  • Multi-target Microsoft.OData.Cli and Microsoft.OData.Cli.Tests to net8.0;net10.0, and bump the CLI package version to 0.4.0.
  • Update MSBuild discovery by bumping Microsoft.Build.Locator to 1.11.2 and guarding registration with IsRegistered.
  • Fix test host MSBuild setup by adding a module initializer to register MSBuild before tests execute MSBuild APIs, and adjust package assets to avoid MSBuildLocator conflicts (MSBL001).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
test/Microsoft.OData.Cli.Tests/MSBuildRegistration.cs Adds early MSBuild registration for tests via module initializer.
test/Microsoft.OData.Cli.Tests/Microsoft.OData.Cli.Tests.csproj Multi-targets tests and aligns MSBuild-related package references for locator compatibility.
src/Microsoft.OData.Cli/Program.cs Avoids double MSBuild registration by checking IsRegistered before RegisterDefaults().
src/Microsoft.OData.Cli/Microsoft.OData.Cli.csproj Multi-targets the CLI, bumps version, updates MSBuild locator, and avoids shipping conflicting runtime MSBuild/NuGet assemblies.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

namespace Microsoft.OData.Cli.Tests
{
/// <summary>
/// Registers the MSBuild assemblies from the running .NET SDK before any test exercises the
@aboryczko

Copy link
Copy Markdown
Contributor Author

@gathogojr @WanjohiSammy need just one more "yes" 🙂

@aboryczko

Copy link
Copy Markdown
Contributor Author

Hi @gathogojr @WanjohiSammy could we please merge this?

@WanjohiSammy

Copy link
Copy Markdown
Member

@aboryczko Please rebase and push

@aboryczko
aboryczko force-pushed the feature/odata-cli-net8-net10 branch from 8bcdfb4 to c5f1eb9 Compare September 14, 2026 14:49
@aboryczko

Copy link
Copy Markdown
Contributor Author

@aboryczko Please rebase and push

@WanjohiSammy done

Artur Boryczko added 2 commits September 15, 2026 20:37
The net6.0 tool failed with "No instances of MSBuild could be detected"
on machines without a .NET 6 SDK (OData#429, OData#324, OData#428, OData#448). Multi-target
net8.0;net10.0 and bump Microsoft.Build.Locator to 1.11.2, which is the
half of the fix that actually locates MSBuild.

The tests evaluate real projects, so register MSBuild from the instance
MSBuildLocator selects via a ModuleInitializer.

NuGet.Frameworks is pinned to 6.3.3 and shipped rather than deferring to
the SDK's copy: the .NET 10 SDK carries 7.x, which drops the public
NuGetFrameworkFullComparer constructor that NuGet.Protocol 6.3.3 calls,
so binding to it throws MethodAccessException at run time. That needs
DisableMSBuildAssemblyCopyCheck; Microsoft.Build* stay runtime-excluded.
The UseDotNet@2 'Use .NET SDK 8.0.x' task added in OData#442 installs 8.0.425
into hostedtoolcache and repoints DOTNET_ROOT/PATH there, hiding the SDKs
the hosted image ships. NuGetCommand@2 and VSBuild@1 both run the agent's
VS 2022 MSBuild (17.14), which could then only see 8.0.425, so restoring
the net10.0 target failed with NETSDK1045.

windows-2025 preinstalls 10.0.111 next to 10.0.204/303/400. The 2xx+
bands need MSBuild 18, but 10.0.111 supports 17.14, so with no pin the
resolver picks it and both target frameworks build.
@aboryczko
aboryczko force-pushed the feature/odata-cli-net8-net10 branch from c5f1eb9 to 2f56ea3 Compare September 15, 2026 19:13
@WanjohiSammy
WanjohiSammy merged commit 86f28d7 into OData:master Sep 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants