diff --git a/tools/UpdateDotnetRuntime.ps1 b/tools/UpdateDotnetRuntime.ps1
index 044fe993f..5126d1099 100644
--- a/tools/UpdateDotnetRuntime.ps1
+++ b/tools/UpdateDotnetRuntime.ps1
@@ -278,8 +278,15 @@ if ($dotnetUpdate.ShouldUpdate) {
if ($feedname -eq 'dotnet-internal') {
# This NuGet feed is for internal to Microsoft use only.
$dotnetInternalFeed = $dotnetMetadataJson.internalfeed.url
- $updatedNugetFile = $nugetFileContent -replace "", " `r`n "
+
+ $updatedNugetFile = if ($nugetFileContent.Contains('dotnet-internal')) {
+ $nugetFileContent -replace ".`r`n "
+ } else {
+ $nugetFileContent -replace "", " `r`n "
+ }
+
$updatedNugetFile | Out-File "$PSScriptRoot/../nuget.config" -Force
+
Register-PackageSource -Name 'dotnet-internal' -Location $dotnetInternalFeed -ProviderName NuGet
Write-Verbose -Message "Register new package source 'dotnet-internal'" -verbose
}