@@ -443,7 +443,7 @@ void TryAddLinkingFile(string key, string linkingFile)
443443 }
444444
445445 /// <summary>
446- /// Pulls docset information, including URL base path, from the OPS config and docfx.json files.
446+ /// Pulls docset information from the OPS config and docfx.json files.
447447 /// </summary>
448448 internal Dictionary < string , string > ? GetDocsetInfo ( )
449449 {
@@ -464,7 +464,14 @@ void TryAddLinkingFile(string key, string linkingFile)
464464 if ( sourceFolder . build_source_folder is null )
465465 continue ;
466466
467- string docfxFilePath = Path . Combine ( OpsConfigFile . DirectoryName ! , sourceFolder . build_source_folder , "docfx.json" ) ;
467+ string docfxFilePath = Path . GetFullPath ( Path . Combine ( OpsConfigFile . DirectoryName ! , sourceFolder . build_source_folder , "docfx.json" ) ) ;
468+
469+ if ( ! string . Equals ( docfxFilePath , Path . Combine ( DocFxDirectory ! . FullName , "docfx.json" ) , StringComparison . InvariantCultureIgnoreCase ) )
470+ {
471+ // This is a different docset in the same repo. Ignore it.
472+ continue ;
473+ }
474+
468475 DocFx ? docfx = LoadDocfxFile ( docfxFilePath ) ;
469476 if ( docfx == null )
470477 continue ;
@@ -497,10 +504,10 @@ void TryAddLinkingFile(string key, string linkingFile)
497504 docsetFilePath = string . Concat ( docsetFilePath , "/" , item . src ) ;
498505 }
499506 }
500-
501- if ( ! mappingInfo . ContainsKey ( docsetFilePath ) )
502- mappingInfo . Add ( docsetFilePath , UrlBasePath ) ;
503507 }
508+
509+ if ( ! mappingInfo . ContainsKey ( docsetFilePath ) )
510+ mappingInfo . Add ( docsetFilePath , UrlBasePath ) ;
504511 }
505512 }
506513 }
@@ -641,18 +648,28 @@ private static void RemoveRedirectHopsFromFile(FileInfo redirectsFile, Dictionar
641648 if ( redirect . source_path != null )
642649 {
643650 // Construct the full path to the redirected file
644- fullPath = Path . Combine ( redirectsFile . DirectoryName ! , redirect . source_path ) ;
651+ fullPath = Path . GetFullPath ( Path . Combine ( redirectsFile . DirectoryName ! , redirect . source_path ) ) ;
645652 }
646653 else if ( redirect . source_path_from_root != null )
647654 {
648655 // Construct the full path to the redirected file
649- fullPath = Path . Combine ( rootPath , redirect . source_path_from_root . Substring ( 1 ) ) ;
656+ fullPath = Path . GetFullPath ( Path . Combine ( rootPath , redirect . source_path_from_root . Substring ( 1 ) ) ) ;
650657 }
651658
652659 // Path.GetFullPath doesn't require the file or directory to exist,
653660 // so this works on case-sensitive file systems too.
654661 if ( redirect . redirect_url is not null )
655- redirectsLookup . Add ( Path . GetFullPath ( fullPath ! ) , redirect . redirect_url ) ;
662+ {
663+ try
664+ {
665+ redirectsLookup . Add ( fullPath ! , redirect . redirect_url ) ;
666+ }
667+ catch ( ArgumentException )
668+ {
669+ Console . WriteLine ( $ "WARNING: The source path '{ fullPath } ' appears more than once in the redirection file. " +
670+ $ "Please remove duplicates to ensure that all hops are removed.\n ") ;
671+ }
672+ }
656673 }
657674
658675 foreach ( KeyValuePair < string , string > redirectPair in redirectsLookup )
0 commit comments