@@ -25,11 +25,13 @@ public class ExtensionsManager : IExtensionsManager
2525 {
2626 private readonly string _scriptRootPath ;
2727 private readonly ILogger _logger ;
28+ private string _nugetFallbackPath ;
2829
29- public ExtensionsManager ( string scriptRootPath , ILogger logger )
30+ public ExtensionsManager ( string scriptRootPath , ILogger logger , string nugetFallbackPath = null )
3031 {
3132 _scriptRootPath = scriptRootPath ;
3233 _logger = logger ;
34+ _nugetFallbackPath = nugetFallbackPath ;
3335 }
3436
3537 internal string ProjectPath => Path . Combine ( _scriptRootPath , ExtensionsProjectFileName ) ;
@@ -130,6 +132,7 @@ internal virtual Task ProcessExtensionsProject(string projectFolder)
130132 }
131133
132134 SetupProcessEnvironment ( startInfo ) ;
135+ ApplyNugetFallbackFolderConfiguration ( startInfo ) ;
133136
134137 var process = new Process { StartInfo = startInfo } ;
135138 process . ErrorDataReceived += ( s , e ) => logBuilder . Append ( e . Data ) ;
@@ -185,6 +188,30 @@ private void SetupProcessEnvironment(ProcessStartInfo startInfo)
185188 }
186189
187190 startInfo . EnvironmentVariables . Add ( "DOTNET_SKIP_FIRST_TIME_EXPERIENCE" , "true" ) ;
191+ startInfo . EnvironmentVariables . Add ( NugetXmlDocModeSettingName , NugetXmlDocSkipMode ) ;
192+ }
193+
194+ private void ApplyNugetFallbackFolderConfiguration ( ProcessStartInfo startInfo )
195+ {
196+ string nugetFallbackFolderRootPath = Path . Combine ( Environment . ExpandEnvironmentVariables ( "%programfiles(x86)%" ) , NugetFallbackFolderRootName ) ;
197+ if ( string . IsNullOrEmpty ( _nugetFallbackPath ) && FileUtility . DirectoryExists ( nugetFallbackFolderRootPath ) )
198+ {
199+ _nugetFallbackPath = FileUtility . EnumerateDirectories ( nugetFallbackFolderRootPath )
200+ . Select ( directoryPath =>
201+ {
202+ var directoryName = FileUtility . DirectoryInfoFromDirectoryName ( directoryPath ) . Name ;
203+ Version . TryParse ( directoryName , out Version version ) ;
204+ return new Tuple < string , Version > ( directoryPath , version ) ;
205+ } )
206+ . Where ( p => p . Item2 != null )
207+ . OrderByDescending ( p => p . Item2 )
208+ . FirstOrDefault ( ) . Item1 ? . ToString ( ) ;
209+ }
210+
211+ if ( FileUtility . DirectoryExists ( _nugetFallbackPath ) )
212+ {
213+ startInfo . Arguments += $ " /p:RestoreFallbackFolders=\" { _nugetFallbackPath } \" ";
214+ }
188215 }
189216
190217 private Exception CreateRestoreException ( StringBuilder logBuilder , Exception innerException = null )
0 commit comments