@@ -18,8 +18,8 @@ static AcceptanceTestBase()
1818 var cpmPropFileDoc = XDocument . Load ( Path . Combine ( RootFinder . Find ( ) , "Directory.Packages.props" ) ) ;
1919 MicrosoftNETTestSdkVersion = cpmPropFileDoc . Descendants ( "MicrosoftNETTestSdkVersion" ) . Single ( ) . Value ;
2020 MicrosoftNETCoreUniversalWindowsPlatformVersion = cpmPropFileDoc . Descendants ( "MicrosoftNETCoreUniversalWindowsPlatformVersion" ) . Single ( ) . Value ;
21- MicrosoftExtensionsHostingVersion = GetPackageVersion ( cpmPropFileDoc , "Microsoft.Extensions.Logging " ) ;
22- OpenTelemetryVersion = GetPackageVersion ( cpmPropFileDoc , "OpenTelemetry" ) ;
21+ MicrosoftExtensionsHostingVersion = GetPackageVersion ( "Microsoft.Extensions.Hosting " ) ;
22+ OpenTelemetryVersion = GetPackageVersion ( "OpenTelemetry" ) ;
2323
2424 using var globalJson = JsonDocument . Parse ( File . ReadAllText ( Path . Combine ( RootFinder . Find ( ) , "global.json" ) ) ) ;
2525 MSBuildSdkExtrasVersion = globalJson . RootElement
@@ -171,12 +171,14 @@ .. matches
171171 return packageFullName . Substring ( packagePrefixName . Length , packageFullName . Length - packagePrefixName . Length - NuGetPackageExtensionName . Length ) ;
172172 }
173173
174- private static string GetPackageVersion ( XDocument centralPackageManagementDocument , string packageName )
175- => centralPackageManagementDocument
176- . Descendants ( "PackageVersion" )
177- . Single ( element => string . Equals ( element . Attribute ( "Include" ) ? . Value , packageName , StringComparison . Ordinal ) )
178- . Attribute ( "Version" ) ? . Value
179- ?? throw new InvalidOperationException ( $ "Directory.Packages.props does not define a version for '{ packageName } '.") ;
174+ private static string GetPackageVersion ( string packageName )
175+ {
176+ string ? version = typeof ( Constants ) . Assembly . GetCustomAttributes < AssemblyMetadataAttribute > ( )
177+ . SingleOrDefault ( attribute => string . Equals ( attribute . Key , packageName , StringComparison . Ordinal ) ) ? . Value ;
178+ return ! string . IsNullOrEmpty ( version )
179+ ? version
180+ : throw new InvalidOperationException ( $ "The test infrastructure does not define an evaluated version for '{ packageName } '.") ;
181+ }
180182
181183 internal static IEnumerable < ( string Tfm , BuildConfiguration BuildConfiguration ) > GetBuildMatrixTfmBuildConfiguration ( )
182184 {
0 commit comments