File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -255,12 +255,24 @@ public void Dispose()
255255
256256 try
257257 {
258- File . Delete ( nugetConfigPath ) ;
258+ if ( backupNugetConfig is null )
259+ {
260+ logger . LogInfo ( "Removing nuget.config file" ) ;
261+ File . Delete ( nugetConfigPath ) ;
262+ return ;
263+ }
259264
260- if ( backupNugetConfig is not null )
265+ logger . LogInfo ( "Reverting nuget.config file content" ) ;
266+ // The content of the original nuget.config file is reverted without changing the file's attributes or casing:
267+ using ( var backup = File . OpenRead ( backupNugetConfig ) )
268+ using ( var current = File . OpenWrite ( nugetConfigPath ) )
261269 {
262- File . Move ( backupNugetConfig , nugetConfigPath ) ;
270+ current . SetLength ( 0 ) ;
271+ backup . CopyTo ( current ) ;
263272 }
273+
274+ logger . LogInfo ( "Deleting backup nuget.config file" ) ;
275+ File . Delete ( backupNugetConfig ) ;
264276 }
265277 catch ( Exception exc )
266278 {
You can’t perform that action at this time.
0 commit comments