@@ -81,9 +81,7 @@ internal static async Task<int> Run(PackageUpdateArgs args, ILoggerWithColor log
8181 return ExitCodes . Error ;
8282 }
8383
84- PackageSpec projectSpec = dgSpec . Projects . Count == 1
85- ? dgSpec . Projects [ 0 ]
86- : dgSpec . GetProjectSpec ( dgSpec . Restore [ 0 ] ) ;
84+ PackageSpec projectSpec = dgSpec . GetProjectSpec ( dgSpec . Restore [ 0 ] ) ;
8785
8886 // 2. Find suitable version of package(s) to update
8987 // Source provider will be needed to find the package version and to restore, so create it here.
@@ -141,7 +139,7 @@ internal static async Task<int> Run(PackageUpdateArgs args, ILoggerWithColor log
141139 }
142140 }
143141
144- var projectName = Path . GetFileNameWithoutExtension ( dgSpec . Projects [ 0 ] . FilePath ) ;
142+ var projectName = Path . GetFileNameWithoutExtension ( projectSpec . FilePath ) ;
145143 logger . LogInformation ( $ " { projectName } :") ;
146144
147145 foreach ( var packageResult in packagesToUpdateResult )
@@ -154,7 +152,7 @@ internal static async Task<int> Run(PackageUpdateArgs args, ILoggerWithColor log
154152
155153 // 3. Preview restore to validate changes
156154 logger . LogDebug ( Strings . PackageUpdate_PreviewRestore ) ;
157- var updatedDgSpec = GetUpdatedDependencyGraphSpec ( dgSpec , packagesToUpdateResult ) ;
155+ var updatedDgSpec = GetUpdatedDependencyGraphSpec ( projectSpec , dgSpec , packagesToUpdateResult ) ;
158156 var restorePreviewResult = await packageUpdateIO . PreviewUpdatePackageReferenceAsync ( updatedDgSpec , logger , cancellationToken ) ;
159157
160158 if ( ! restorePreviewResult . Success )
@@ -165,7 +163,7 @@ internal static async Task<int> Run(PackageUpdateArgs args, ILoggerWithColor log
165163
166164 // 4. Update MSBuild files
167165
168- var updatedPackageSpec = updatedDgSpec . Projects [ 0 ] ;
166+ var updatedPackageSpec = updatedDgSpec . GetProjectSpec ( projectSpec . FilePath ) ;
169167 int updatedCount = 0 ;
170168
171169 foreach ( var packageResult in packagesToUpdateResult )
@@ -555,9 +553,9 @@ private static (VersionRange? version, List<string> targetFrameworks)
555553 return result ;
556554 }
557555
558- private static DependencyGraphSpec GetUpdatedDependencyGraphSpec ( DependencyGraphSpec currentDgSpec , List < PackageUpdateResult > packagesToUpdate )
556+ private static DependencyGraphSpec GetUpdatedDependencyGraphSpec ( PackageSpec projectSpec , DependencyGraphSpec currentDgSpec , List < PackageUpdateResult > packagesToUpdate )
559557 {
560- var updatedPackageSpec = currentDgSpec . Projects [ 0 ] . Clone ( ) ;
558+ var updatedPackageSpec = projectSpec . Clone ( ) ;
561559
562560 foreach ( var packageResult in packagesToUpdate )
563561 {
0 commit comments