Skip to content

Friendly error when non-matching SDK is used - #101

Merged
kzu merged 1 commit into
mainfrom
dev/previews
Aug 21, 2025
Merged

Friendly error when non-matching SDK is used#101
kzu merged 1 commit into
mainfrom
dev/previews

Conversation

@kzu

@kzukzu commented Aug 21, 2025

Copy link
Copy Markdown
Member

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.
@kzukzu 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 CopilotAugust 21, 2025 21:51

CopilotAI 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.

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.

FileDescription
src/AI/Devlooped.Extensions.AI.targetsAdds build-time validation target with SDK version check and error message
src/AI/AI.csprojImplements 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." />

CopilotAIAug 21, 2025

Copy link

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
<ErrorCondition="'$(_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." />
<ErrorCondition="'$(_NETCoreSdkIsPreview)' == 'false'"Text="This version was built with a preview SDK. Please use a preview .NET SDK (version $(BuiltSdkPreviewVersion) or newer)." />
<ErrorCondition="'$(_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.
Comment threadsrc/AI/AI.csproj
@kzu

kzu commented Aug 21, 2025

Copy link
Copy Markdown
MemberAuthor

1 passed1 passed17 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 mainAug 21, 2025
7 checks passed
@kzu
kzu deleted the dev/previews branch August 21, 2025 21:53
@devloopeddevlooped locked and limited conversation to collaborators Sep 21, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancementNew feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@kzu