@@ -131,14 +131,10 @@ public async Task<string> DownloadPackageAsync(PackageId packageId,
131131 string . Format ( LocalizableStrings . IsNotFoundInNuGetFeeds , packageId , source . Source ) ) ;
132132 }
133133
134- string nupkgPath = downloadFolder == null || ! downloadFolder . HasValue
135- ? Path . Combine ( _packageInstallDir . Value , packageId . ToString ( ) ,
136- resolvedPackageVersion . ToNormalizedString ( ) . ToLowerInvariant ( ) ,
137- $ "{ packageId } .{ resolvedPackageVersion . ToNormalizedString ( ) . ToLowerInvariant ( ) } .nupkg")
138- : Path . Combine ( downloadFolder . Value . Value ,
139- $ "{ packageId } .{ resolvedPackageVersion . ToNormalizedString ( ) . ToLowerInvariant ( ) } .nupkg") ;
140-
134+ var pathResolver = new VersionFolderPathResolver ( downloadFolder == null || ! downloadFolder . HasValue ? _packageInstallDir . Value : downloadFolder . Value . Value ) ;
135+ string nupkgPath = pathResolver . GetPackageFilePath ( packageId . ToString ( ) , resolvedPackageVersion ) ;
141136 Directory . CreateDirectory ( Path . GetDirectoryName ( nupkgPath ) ) ;
137+
142138 using FileStream destinationStream = File . Create ( nupkgPath ) ;
143139 bool success = await ExponentialRetry . ExecuteWithRetryOnFailure ( async ( ) => await resource . CopyNupkgToStreamAsync (
144140 packageId . ToString ( ) ,
@@ -218,7 +214,10 @@ public async Task<string> GetPackageUrl(PackageId packageId,
218214 SourceRepository repository = GetSourceRepository ( source ) ;
219215 if ( repository . PackageSource . IsLocal )
220216 {
221- return Path . Combine ( repository . PackageSource . Source , $ "{ packageId } .{ resolvedPackageVersion } .nupkg") ;
217+ return Path . Combine (
218+ repository . PackageSource . Source ,
219+ new VersionFolderPathResolver ( repository . PackageSource . Source ) . GetPackageFileName ( packageId . ToString ( ) , resolvedPackageVersion )
220+ ) ;
222221 }
223222
224223 ServiceIndexResourceV3 serviceIndexResource = repository . GetResourceAsync < ServiceIndexResourceV3 > ( ) . Result ;
@@ -307,9 +306,7 @@ await GetPackageMetadataAsync(packageId.ToString(), packageVersion, packagesSour
307306 return ( source , packageVersion ) ;
308307 }
309308
310- private string GetNupkgUrl ( string baseUri , PackageId id , NuGetVersion version ) =>
311- baseUri + id . ToString ( ) + "/" + version . ToNormalizedString ( ) . ToLowerInvariant ( ) + "/" + id . ToString ( ) +
312- "." + version . ToNormalizedString ( ) . ToLowerInvariant ( ) + ".nupkg" ;
309+ private string GetNupkgUrl ( string baseUri , PackageId id , NuGetVersion version ) => new VersionFolderPathResolver ( baseUri ) . GetPackageFilePath ( id . ToString ( ) , version ) ;
313310
314311 internal IEnumerable < FilePath > FindAllFilesNeedExecutablePermission ( IEnumerable < string > files ,
315312 string targetPath )
0 commit comments