Repository navigation
AOT 1: Validate installed SqlClient family versions from Logging packages #4815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
+344
−0
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...t.Data.SqlClient.Internal/Logging/build/Microsoft.Data.SqlClient.Internal.Logging.targets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| <Project> | ||
|
|
||
| <!-- Logging owns the consumer check and ships it in build/ and buildTransitive/. | ||
| Only installed members of the lockstep family are checked. SqlServer.Server and native | ||
| SNI are independently versioned. Project references are not package-version evidence. --> | ||
| <PropertyGroup> | ||
| <SqlClientEnforceFamilyVersions Condition="'$(SqlClientEnforceFamilyVersions)' == ''">true</SqlClientEnforceFamilyVersions> | ||
| </PropertyGroup> | ||
|
|
||
| <Target Name="ValidateSqlClientFamilyPackageVersions" | ||
| AfterTargets="ResolvePackageAssets;ResolveReferences" | ||
| Condition="'$(SqlClientEnforceFamilyVersions)' == 'true' And '$(DesignTimeBuild)' != 'true'"> | ||
| <ItemGroup> | ||
| <!-- Collect first, then use qualified metadata so framework/project references without | ||
| NuGet metadata cannot cause MSB4096. Include RID-specific runtime-only assets. --> | ||
| <_SqlClientResolvedAsset Include="@(ResolvedCompileFileDefinitions);@(ReferencePath);@(RuntimeCopyLocalItems);@(RuntimeTargetsCopyLocalItems)" /> | ||
| <_SqlClientFamilyAsset Include="@(_SqlClientResolvedAsset)" | ||
| Condition="'%(_SqlClientResolvedAsset.NuGetPackageId)' == 'Microsoft.Data.SqlClient' Or | ||
| '%(_SqlClientResolvedAsset.NuGetPackageId)' == 'Microsoft.Data.SqlClient.Extensions.Abstractions' Or | ||
| '%(_SqlClientResolvedAsset.NuGetPackageId)' == 'Microsoft.Data.SqlClient.Extensions.Azure' Or | ||
| '%(_SqlClientResolvedAsset.NuGetPackageId)' == 'Microsoft.Data.SqlClient.Internal.Logging' Or | ||
| '%(_SqlClientResolvedAsset.NuGetPackageId)' == 'Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider'"> | ||
| <FamilyVersion>%(_SqlClientResolvedAsset.NuGetPackageVersion)</FamilyVersion> | ||
| <FamilyId>%(_SqlClientResolvedAsset.NuGetPackageId)</FamilyId> | ||
| </_SqlClientFamilyAsset> | ||
| <_SqlClientLoggingVersion Include="@(_SqlClientFamilyAsset)" | ||
| Condition="'%(_SqlClientFamilyAsset.FamilyId)' == 'Microsoft.Data.SqlClient.Internal.Logging' And '%(_SqlClientFamilyAsset.FamilyVersion)' != ''" /> | ||
| </ItemGroup> | ||
| <PropertyGroup> | ||
| <!-- Compare resolved version strings, including prerelease labels, not ranges or assembly | ||
| versions. Missing package metadata is not assigned a guessed version. --> | ||
| <_SqlClientExpectedFamilyVersion>@(_SqlClientLoggingVersion->'%(FamilyVersion)'->Distinct())</_SqlClientExpectedFamilyVersion> | ||
| </PropertyGroup> | ||
| <Error Code="SQLCLIENT001" | ||
| Condition="'%(_SqlClientFamilyAsset.FamilyVersion)' != '' And '$(_SqlClientExpectedFamilyVersion)' != '' And '%(_SqlClientFamilyAsset.FamilyVersion)' != '$(_SqlClientExpectedFamilyVersion)'" | ||
| Text="SqlClient family version mismatch: %(_SqlClientFamilyAsset.FamilyId) is %(_SqlClientFamilyAsset.FamilyVersion), but Logging is $(_SqlClientExpectedFamilyVersion). Upgrade all installed family packages together, including prerelease labels. Emergency opt-out: SqlClientEnforceFamilyVersions=false." /> | ||
|
|
||
| <!-- Legacy packages.config consumers import build/ explicitly through NuGet installation. | ||
| Read installed versions from the manifest, independently of assembly reference metadata. --> | ||
| <XmlPeek XmlInputPath="$(MSBuildProjectDirectory)/packages.config" | ||
| Query="/packages/package[@id='Microsoft.Data.SqlClient.Internal.Logging']/@version" | ||
| Condition="Exists('$(MSBuildProjectDirectory)/packages.config')"> | ||
|
Comment on lines
+39
to
+41
|
||
| <Output TaskParameter="Result" PropertyName="_SqlClientConfigExpectedVersion" /> | ||
| </XmlPeek> | ||
| <XmlPeek XmlInputPath="$(MSBuildProjectDirectory)/packages.config" | ||
| Query="/packages/package[(@id='Microsoft.Data.SqlClient.Internal.Logging' or @id='Microsoft.Data.SqlClient.Extensions.Abstractions' or @id='Microsoft.Data.SqlClient' or @id='Microsoft.Data.SqlClient.Extensions.Azure' or @id='Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider') and @version!='$(_SqlClientConfigExpectedVersion)']" | ||
| Condition="'$(_SqlClientConfigExpectedVersion)' != ''"> | ||
| <Output TaskParameter="Result" ItemName="_SqlClientConfigMismatch" /> | ||
| </XmlPeek> | ||
| <Error Code="SQLCLIENT001" | ||
| Condition="'@(_SqlClientConfigMismatch)' != ''" | ||
| Text="SqlClient family version mismatch in packages.config: %(_SqlClientConfigMismatch.Identity), but Logging is $(_SqlClientConfigExpectedVersion). Upgrade all installed family packages together, including prerelease labels. Emergency opt-out: SqlClientEnforceFamilyVersions=false." /> | ||
| </Target> | ||
| </Project> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@paulmedynski - Use
dotnet tool run pwshto ensure correct tooling.