Skip to content

Conversation

@kzu
Copy link
Member

@kzu kzu commented Aug 21, 2025

Since we are building with latest&greatest .NET to get the extension class syntax, consumers need to use a matching SDK in order for that to work.

Provide a compile-time error instead of the inscrutable alternative (unsupported language feature or what-not).

This will turn off itself when we ship with a stable SDK.

Since we are building with latest&greatest .NET to get the extension class syntax, consumers need to use a matching SDK in order for that to work.

Provide a compile-time error instead of the inscrutable alternative (unsupported language feature or what-not).

This will turn off itself when we ship with a stable SDK.
@kzu kzu added the enhancement New feature or request label Aug 21, 2025
@kzu kzu enabled auto-merge (rebase) August 21, 2025 21:51
@kzu kzu requested a review from Copilot August 21, 2025 21:51
Copy link
Contributor

Copilot AI left a comment

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 implements a compile-time check to ensure consumers use a matching SDK version when the package is built with a preview .NET SDK. The change prevents cryptic compilation errors by providing a clear error message when an incompatible SDK is detected.

Key changes:

  • Adds MSBuild targets to validate SDK version compatibility at build time
  • Dynamically updates SDK version information during package creation
  • Provides user-friendly error messaging for SDK mismatches

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/AI/Devlooped.Extensions.AI.targets Adds build-time validation target with SDK version check and error message
src/AI/AI.csproj Implements dynamic update of SDK version properties during packaging

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

<BuiltSdkPreviewVersion>10.0.100-preview.7.25380.108</BuiltSdkPreviewVersion>
</PropertyGroup>
<Target Name="EnsureSamePreviewSdkVersion" BeforeTargets="Build" Condition="'$(BuiltWithSdkPreview)' == 'true'">
<Error Condition="'$(_NETCoreSdkIsPreview)' == 'false' or '$(NETCoreSdkVersion)' != '$(BuiltSdkPreviewVersion)'" Text="This version was built with a preview SDK and requires a matching one. Please install SDK version $(BuiltSdkPreviewVersion) or update to a newer package version." />
Copy link

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

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

[nitpick] The condition logic could be clearer by separating the two error cases. Consider using separate Error elements for when SDK is not preview vs when versions don't match, as these are different problems requiring different solutions.

Suggested change
<Error Condition="'$(_NETCoreSdkIsPreview)' == 'false' or '$(NETCoreSdkVersion)' != '$(BuiltSdkPreviewVersion)'" Text="This version was built with a preview SDK and requires a matching one. Please install SDK version $(BuiltSdkPreviewVersion) or update to a newer package version." />
<Error Condition="'$(_NETCoreSdkIsPreview)' == 'false'" Text="This version was built with a preview SDK. Please use a preview .NET SDK (version $(BuiltSdkPreviewVersion) or newer)." />
<Error Condition="'$(_NETCoreSdkIsPreview)' == 'true' and '$(NETCoreSdkVersion)' != '$(BuiltSdkPreviewVersion)'" Text="This version was built with .NET SDK version $(BuiltSdkPreviewVersion). Please install and use this SDK version, or update to a newer package version." />

Copilot uses AI. Check for mistakes.
@kzu
Copy link
Member Author

kzu commented Aug 21, 2025

1 passed 1 passed 17 skipped

🧪 Details on Ubuntu 24.04.2 LTS

from dotnet-retest v0.7.2 on .NET 9.0.8 with 💜 by @devlooped

@kzu kzu merged commit 7e6ba70 into main Aug 21, 2025
7 checks passed
@kzu kzu deleted the dev/previews branch August 21, 2025 21:53
@devlooped devlooped locked and limited conversation to collaborators Sep 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants