Skip to content

adds support for .NET 8.0#629

Open
prathikr wants to merge 53 commits intomainfrom
prathikrao/net8-support
Open

adds support for .NET 8.0#629
prathikr wants to merge 53 commits intomainfrom
prathikrao/net8-support

Conversation

@prathikr
Copy link
Copy Markdown
Contributor

@prathikr prathikr commented Apr 14, 2026

Comment thread sdk/cs/src/Microsoft.AI.Foundry.Local.csproj Outdated
Comment thread sdk/cs/src/Microsoft.AI.Foundry.Local.csproj Outdated
<Version>0.5.0-dev.local.$(BuildTimestamp)</Version>
</PropertyGroup>

<PropertyGroup>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If your intent is to use the constants that are being defined in the code to determine what platform you're running on, this approach isn't going to work. This will tell you the build-time platform only. You may want to consider removing these and using a runtime check.

For example, this will cover all supported platforms:

 using System.Runtime.InteropServices;
 
 public static class PlatformHelper
 {
     public static bool IsWindows =>
 #if NET5_0_OR_GREATER
         OperatingSystem.IsWindows();
 #else
         RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
 #endif
 
     public static bool IsLinux =>
 #if NET5_0_OR_GREATER
         OperatingSystem.IsLinux();
 #else
         RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
 #endif
 
     public static bool IsMacOS =>
 #if NET5_0_OR_GREATER
         OperatingSystem.IsMacOS();
 #else
         RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
 #endif
 
     public static string OSDescription =>
         RuntimeInformation.OSDescription;
 
     // Version-gated check (only precise on .NET 5+)
     public static bool IsWindowsVersionAtLeast(int major, int minor = 0, int build = 0) =>
 #if NET5_0_OR_GREATER
         OperatingSystem.IsWindowsVersionAtLeast(major, minor, build);
 #else
         RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
             && Environment.OSVersion.Version >= new Version(major, minor, build);
 #endif
 }

The .NET Framework targets would need the System.Runtime.InteropServices.RuntimeInformation polyfill package from NuGet.

Comment thread sdk/cs/src/Microsoft.AI.Foundry.Local.csproj Outdated

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd assume you would want to run your tests on net462 as well, since it's the lowest supported .NET Framework version.

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.

We do not want to support lower than net8.0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We do not want to support lower than net8.0

@prathikr Does that imply you don't want .NET Framework customers using the library? For clarity, TFM net462 corresponds to .NET Framework 4.6.2.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We do not want to support lower than net8.0

It's a valid decision, but it runs counter to the common developer experience and guidelines for both Azure Foundry and Azure itself. Was this limitation discussed with leadership or made in isolation?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In this context, since you've added netstandard2.0 to your project targets, not running a .NET Framework leg in your tests does not remove support for it from the product - it simply leaves all .NET Framework runtimes untested. Since there is a divergence between runtimes, this exposes you to a nasty class of bugs that is hard to root cause in isolation.

I'd very, very strongly suggest that you align your test runs with the frameworks that your product supports.

<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.9" />
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: There's no benefit to using 9.x here. I'd suggest aligning them to your 8.x dependency.

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.

Is there a downside to using 9.x?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For this specific set, not that I see. Generally, yes. Many of the BCL packages are polyfills on modern runtimes and those on your version line would be able to elide the package entirely and use the built-in version.

<PackageReference Condition="'$(UseWinML)' != 'true'"
Include="Microsoft.AI.Foundry.Local.Core" Version="$(FoundryLocalCoreVersion)" />

<PackageReference Include="Betalgo.Ranul.OpenAI" Version="9.1.0" />
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Foundry is aligned on the official OpenAI library for its developer experience. Why is a random third-party package used here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I created #632 to track that problem.

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, we are in the process of moving off this dependency

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there a target date for completion of that work? Let us know if you have questions. Jesse and I represent the team that ships the official OpenAI library.

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.

It is still under discussion, will update when I have a timeline.

Comment thread sdk/cs/src/Microsoft.AI.Foundry.Local.csproj Outdated
<RepositoryType>git</RepositoryType>

<TargetFramework>net9.0</TargetFramework>
<TargetFrameworks>netstandard2.0;net8.0</TargetFrameworks>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Expanding on my comment in the tests project - there's a misalignment here between what runtimes your product supports (this list) and what you're actively testing.

Your statement about not wanting to support runtimes earlier than 8.0 is in opposition to the target list here, as netstandard2.0 will allow running on the supported .NET Framework runtimes (4.26 - 4.81).

Note that doing so is compliant with the Azure developer experience guidelines and the Azure Foundry developer experience across products.

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.

ok, will add netstandard2.0 for cross-platform and net462 for winml. is that the correct setup to be compliant with Azure Foundry developer experience?

Comment thread .pipelines/templates/build-cs-steps.yml Outdated
Comment thread .pipelines/templates/build-cs-steps.yml Outdated

<TargetFramework>net9.0</TargetFramework>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<RuntimeIdentifiers>win-x64;win-arm64;linux-x64;linux-arm64;osx-arm64</RuntimeIdentifiers>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there a reason why you need to explicitly state the RuntimeIdentifiers in the general case? Do you have a native dependency bound to these?

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, we have a Foundry Local Core dependency which is a native AOT c# application.

Comment thread sdk/cs/src/Microsoft.AI.Foundry.Local.csproj Outdated
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.

4 participants