@@ -158,9 +158,22 @@ public async Task<SemanticVersion> ReadToolsDotnetVersionAsync(string repoUri, s
158158 return dotnetVersion ;
159159 }
160160
161- public async Task < XmlDocument > ReadNugetConfigAsync ( string repoUri , string branch )
161+ public async Task < ( string Name , XmlDocument Content ) > ReadNugetConfigAsync ( string repoUri , string branch )
162162 {
163- return await ReadXmlFileAsync ( VersionFiles . NugetConfig , repoUri , branch ) ;
163+ foreach ( var name in VersionFiles . NugetConfigNames )
164+ {
165+ try
166+ {
167+ return ( name , await ReadXmlFileAsync ( name , repoUri , branch ) ) ;
168+ }
169+ catch ( DependencyFileNotFoundException )
170+ {
171+ continue ;
172+ }
173+ }
174+
175+ throw new DependencyFileNotFoundException (
176+ $ "None of the { VersionFiles . NugetConfigNames . First ( ) } variations were found in the repo '{ repoUri } ' and branch '{ branch } '") ;
164177 }
165178
166179 public async Task < VersionDetails > ParseVersionDetailsXmlAsync ( string repoUri , string branch , bool includePinned = true )
@@ -391,7 +404,7 @@ public async Task<GitFileContentContainer> UpdateDependencyFiles(
391404 XmlDocument versionProps = await ReadVersionPropsAsync ( repoUri , branch ) ;
392405 JObject globalJson = await ReadGlobalJsonAsync ( repoUri , branch , repoIsVmr ) ;
393406 JObject toolsConfigurationJson = await ReadDotNetToolsConfigJsonAsync ( repoUri , branch , repoIsVmr ) ;
394- XmlDocument nugetConfig = await ReadNugetConfigAsync ( repoUri , branch ) ;
407+ ( string nugetConfigName , XmlDocument nugetConfig ) = await ReadNugetConfigAsync ( repoUri , branch ) ;
395408
396409 foreach ( DependencyDetail itemToUpdate in itemsToUpdate )
397410 {
@@ -427,7 +440,7 @@ public async Task<GitFileContentContainer> UpdateDependencyFiles(
427440 // At this point we only care about the Maestro managed locations for the assets.
428441 // Flatten the dictionary into a set that has all the managed feeds
429442 Dictionary < string , HashSet < string > > managedFeeds = FlattenLocationsAndSplitIntoGroups ( itemsToUpdateLocations ) ;
430- var updatedNugetConfig = UpdatePackageSources ( nugetConfig , managedFeeds ) ;
443+ nugetConfig = UpdatePackageSources ( nugetConfig , managedFeeds ) ;
431444
432445 // Update the dotnet sdk if necessary
433446 Dictionary < GitFileMetadataName , string > globalJsonMetadata = null ;
@@ -441,7 +454,7 @@ public async Task<GitFileContentContainer> UpdateDependencyFiles(
441454 GlobalJson = new GitFile ( VersionFiles . GlobalJson , globalJson , globalJsonMetadata ) ,
442455 VersionDetailsXml = new GitFile ( VersionFiles . VersionDetailsXml , versionDetails ) ,
443456 VersionProps = new GitFile ( VersionFiles . VersionProps , versionProps ) ,
444- NugetConfig = new GitFile ( VersionFiles . NugetConfig , updatedNugetConfig )
457+ NugetConfig = new GitFile ( nugetConfigName , nugetConfig ) ,
445458 } ;
446459
447460 // dotnet-tools.json is optional, so only include it if it was found.
0 commit comments