@@ -175,5 +175,40 @@ public async Task ConfigWithNoDisabledSources_StillAddsInternalFeeds()
175175 "https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet6-internal-transport/nuget/v3/index.json" ,
176176 "should add dotnet6-internal-transport feed" ) ;
177177 }
178+
179+ [ Fact ]
180+ public async Task ConfigWithCommentedOutDisabledDarcIntFeeds_RemovesEntriesAndProducesValidXml ( )
181+ {
182+ // Arrange - this test covers the issue where commented-out disabled entries would create invalid XML
183+ var originalConfig = @"<?xml version=""1.0"" encoding=""utf-8""?>
184+ <configuration>
185+ <packageSources>
186+ <add key=""dotnet-public"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json"" />
187+ <add key=""darc-int-dotnet-roslyn-12345"" value=""https://pkgs.dev.azure.com/dnceng/internal/_packaging/darc-int-dotnet-roslyn-12345/nuget/v3/index.json"" />
188+ </packageSources>
189+ <disabledPackageSources>
190+ <!-- <add key=""darc-int-dotnet-roslyn-12345"" value=""true"" /> -->
191+ </disabledPackageSources>
192+ </configuration>" ;
193+ var configPath = Path . Combine ( _testOutputDirectory , "nuget.config" ) ;
194+ await Task . Run ( ( ) => File . WriteAllText ( configPath , originalConfig ) ) ;
195+
196+ // Act
197+ var result = await _scriptRunner . RunScript ( configPath ) ;
198+
199+ // Assert
200+ result . exitCode . Should ( ) . Be ( 0 , "Script should succeed, but got error: {result.error}" ) ;
201+ var modifiedConfig = await Task . Run ( ( ) => File . ReadAllText ( configPath ) ) ;
202+
203+ // The modified config should be valid XML (this would fail if nested comments were created)
204+ Action parseXml = ( ) => System . Xml . Linq . XDocument . Parse ( modifiedConfig ) ;
205+ parseXml . Should ( ) . NotThrow ( "modified config should be valid XML without nested comments" ) ;
206+
207+ // The darc-int feed should not be disabled
208+ modifiedConfig . ShouldNotBeDisabled ( "darc-int-dotnet-roslyn-12345" , "darc-int feed should be enabled" ) ;
209+
210+ // The commented-out line should be removed entirely (no comment remnants)
211+ modifiedConfig . Should ( ) . NotContain ( "Reenabled for build" , "should not add comments when removing disabled entries" ) ;
212+ }
178213 }
179214}
0 commit comments