@@ -304,28 +304,39 @@ async function getResultsWithoutPublish(
304304 const parser = PARSERS [ 'dotnet-core-v3' ] ;
305305
306306 const projectFolder = projectPath ? path . dirname ( projectPath ) : safeRoot ;
307- const { sdkVersion, sdkPath } = await extractSdkInfo ( projectFolder ) ;
308- const localRuntimes = await dotnet . execute (
309- [ '--list-runtimes' ] ,
310- projectFolder ,
307+
308+ // Check if any target frameworks need runtime assembly overrides
309+ const needsRuntimeOverrides = decidedTargetFrameworks . some (
310+ ( framework ) =>
311+ ! framework . includes ( 'netstandard' ) && ! framework . includes ( 'netcoreapp' ) ,
311312 ) ;
312- const runtimeVersion = findLatestMatchingVersion ( localRuntimes , sdkVersion ) ;
313+
313314 const overridesAssemblies : AssemblyVersions = { } ;
314315
315- try {
316- const overridesPath : string = `${ path . dirname ( sdkPath ) } ${ PACKS_PATH } ${ runtimeVersion } /${ PACKAGE_OVERRIDES_FILE } ` ;
317- const overridesText : string = fs . readFileSync ( overridesPath , 'utf-8' ) ;
318- for ( const pkg of overridesText . split ( '\n' ) ) {
319- if ( pkg ) {
320- const [ name , version ] = pkg . split ( '|' ) ;
321- // Trim any carriage return
322- overridesAssemblies [ name ] = version . trim ( ) ;
316+ // Only load runtime overrides if we have frameworks that need them (exclude netstandard and netcoreapp)
317+ if ( needsRuntimeOverrides ) {
318+ const { sdkVersion, sdkPath } = await extractSdkInfo ( projectFolder ) ;
319+ const localRuntimes = await dotnet . execute (
320+ [ '--list-runtimes' ] ,
321+ projectFolder ,
322+ ) ;
323+ const runtimeVersion = findLatestMatchingVersion ( localRuntimes , sdkVersion ) ;
324+
325+ try {
326+ const overridesPath : string = `${ path . dirname ( sdkPath ) } ${ PACKS_PATH } ${ runtimeVersion } /${ PACKAGE_OVERRIDES_FILE } ` ;
327+ const overridesText : string = fs . readFileSync ( overridesPath , 'utf-8' ) ;
328+ for ( const pkg of overridesText . split ( '\n' ) ) {
329+ if ( pkg ) {
330+ const [ name , version ] = pkg . split ( '|' ) ;
331+ // Trim any carriage return
332+ overridesAssemblies [ name ] = version . trim ( ) ;
333+ }
323334 }
335+ } catch ( err ) {
336+ throw new FileNotProcessableError (
337+ `Failed to read PackageOverrides.txt, error: ${ err } ` ,
338+ ) ;
324339 }
325- } catch ( err ) {
326- throw new FileNotProcessableError (
327- `Failed to read PackageOverrides.txt, error: ${ err } ` ,
328- ) ;
329340 }
330341
331342 // Loop through all TargetFrameworks supplied and generate a dependency graph for each.
@@ -345,9 +356,14 @@ async function getResultsWithoutPublish(
345356
346357 const overrides : Overrides = {
347358 overridesAssemblies,
348- overrideVersion : targetFrameworkInfo . Version . split ( '.' )
349- . slice ( 0 , - 1 )
350- . join ( '.' ) ,
359+ // .NET Standard and .NET Core App frameworks don't need runtime assembly overrides
360+ // as they don't provide specific runtime assembly information that can be read more precisely
361+ // than what's available in the project.assets.json file.
362+ overrideVersion :
363+ decidedTargetFramework . includes ( 'netstandard' ) ||
364+ decidedTargetFramework . includes ( 'netcoreapp' )
365+ ? undefined
366+ : targetFrameworkInfo . Version . split ( '.' ) . slice ( 0 , - 1 ) . join ( '.' ) ,
351367 } ;
352368
353369 let targetFramework = decidedTargetFramework ;
0 commit comments