@@ -25,11 +25,13 @@ public class ExtensionsManager : IExtensionsManager
25
25
{
26
26
private readonly string _scriptRootPath ;
27
27
private readonly ILogger _logger ;
28
+ private string _nugetFallbackPath ;
28
29
29
- public ExtensionsManager ( string scriptRootPath , ILogger logger )
30
+ public ExtensionsManager ( string scriptRootPath , ILogger logger , string nugetFallbackPath = null )
30
31
{
31
32
_scriptRootPath = scriptRootPath ;
32
33
_logger = logger ;
34
+ _nugetFallbackPath = nugetFallbackPath ;
33
35
}
34
36
35
37
internal string ProjectPath => Path . Combine ( _scriptRootPath , ExtensionsProjectFileName ) ;
@@ -130,6 +132,7 @@ internal virtual Task ProcessExtensionsProject(string projectFolder)
130
132
}
131
133
132
134
SetupProcessEnvironment ( startInfo ) ;
135
+ ApplyNugetFallbackFolderConfiguration ( startInfo ) ;
133
136
134
137
var process = new Process { StartInfo = startInfo } ;
135
138
process . ErrorDataReceived += ( s , e ) => logBuilder . Append ( e . Data ) ;
@@ -185,6 +188,30 @@ private void SetupProcessEnvironment(ProcessStartInfo startInfo)
185
188
}
186
189
187
190
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
+ }
188
215
}
189
216
190
217
private Exception CreateRestoreException ( StringBuilder logBuilder , Exception innerException = null )
0 commit comments