@@ -103,12 +103,20 @@ Set-StrictMode -Version Latest
103103Highlight ' Installing .NET, preparing the tooling..'
104104. .\eng\common\tools.ps1
105105$dotnetRoot = InitializeDotNetCli - install:$true
106+ $env: DOTNET_ROOT = $dotnetRoot
106107$darc = Get-Darc
107- $dotnet = " $dotnetRoot \dotnet.exe"
108108
109109Highlight " Starting the synchronization of VMR.."
110110
111111# Synchronize the VMR
112+ $versionDetailsPath = Resolve-Path (Join-Path $PSScriptRoot ' ..\Version.Details.xml' ) | Select-Object - ExpandProperty Path
113+ [xml ]$versionDetails = Get-Content - Path $versionDetailsPath
114+ $repoName = $versionDetails.SelectSingleNode (' //Source' ).Mapping
115+ if (-not $repoName ) {
116+ Fail " Failed to resolve repo mapping from $versionDetailsPath "
117+ exit 1
118+ }
119+
112120$darcArgs = (
113121 " vmr" , " forwardflow" ,
114122 " --tmp" , $tmpDir ,
@@ -130,9 +138,27 @@ if ($LASTEXITCODE -eq 0) {
130138 Highlight " Synchronization succeeded"
131139}
132140else {
133- Fail " Synchronization of repo to VMR failed!"
134- Fail " '$vmrDir ' is left in its last state (re-run of this script will reset it)."
135- Fail " Please inspect the logs which contain path to the failing patch file (use -debugOutput to get all the details)."
136- Fail " Once you make changes to the conflicting VMR patch, commit it locally and re-run this script."
137- exit 1
141+ Highlight " Failed to flow code into the local VMR. Falling back to resetting the VMR to match repo contents..."
142+ git - C $vmrDir reset -- hard
143+
144+ $resetArgs = (
145+ " vmr" , " reset" ,
146+ " ${repoName} :HEAD" ,
147+ " --vmr" , $vmrDir ,
148+ " --tmp" , $tmpDir ,
149+ " --additional-remotes" , " ${repoName} :${repoRoot} "
150+ )
151+
152+ & " $darc " $resetArgs
153+
154+ if ($LASTEXITCODE -eq 0 ) {
155+ Highlight " Successfully reset the VMR using 'darc vmr reset'"
156+ }
157+ else {
158+ Fail " Synchronization of repo to VMR failed!"
159+ Fail " '$vmrDir ' is left in its last state (re-run of this script will reset it)."
160+ Fail " Please inspect the logs which contain path to the failing patch file (use -debugOutput to get all the details)."
161+ Fail " Once you make changes to the conflicting VMR patch, commit it locally and re-run this script."
162+ exit 1
163+ }
138164}
0 commit comments