@@ -60,32 +60,38 @@ private string GetRestoreArgs(string projectOrSolutionFile, string packageDirect
6060 return args ;
6161 }
6262
63- public bool RestoreProjectToDirectory ( string projectFile , string packageDirectory , bool forceDotnetRefAssemblyFetching , string ? pathToNugetConfig = null )
63+ private static IEnumerable < string > GetFirstGroupOnMatch ( Regex regex , IEnumerable < string > lines ) =>
64+ lines
65+ . Select ( line => regex . Match ( line ) )
66+ . Where ( match => match . Success )
67+ . Select ( match => match . Groups [ 1 ] . Value ) ;
68+
69+ private static IEnumerable < string > GetAssetsFilePaths ( IEnumerable < string > lines ) =>
70+ GetFirstGroupOnMatch ( AssetsFileRegex ( ) , lines ) ;
71+
72+ private static IEnumerable < string > GetRestoredProjects ( IEnumerable < string > lines ) =>
73+ GetFirstGroupOnMatch ( RestoredProjectRegex ( ) , lines ) ;
74+
75+ public bool RestoreProjectToDirectory ( string projectFile , string packageDirectory , bool forceDotnetRefAssemblyFetching , out IEnumerable < string > assets , string ? pathToNugetConfig = null )
6476 {
6577 var args = GetRestoreArgs ( projectFile , packageDirectory , forceDotnetRefAssemblyFetching ) ;
6678 if ( pathToNugetConfig != null )
6779 {
6880 args += $ " --configfile \" { pathToNugetConfig } \" ";
6981 }
7082
71- return dotnetCliInvoker . RunCommand ( args ) ;
83+ var success = dotnetCliInvoker . RunCommand ( args , out var output ) ;
84+ assets = success ? GetAssetsFilePaths ( output ) : Array . Empty < string > ( ) ;
85+ return success ;
7286 }
7387
74- public bool RestoreSolutionToDirectory ( string solutionFile , string packageDirectory , bool forceDotnetRefAssemblyFetching , out IEnumerable < string > projects )
88+ public bool RestoreSolutionToDirectory ( string solutionFile , string packageDirectory , bool forceDotnetRefAssemblyFetching , out IEnumerable < string > projects , out IEnumerable < string > assets )
7589 {
7690 var args = GetRestoreArgs ( solutionFile , packageDirectory , forceDotnetRefAssemblyFetching ) ;
77- if ( dotnetCliInvoker . RunCommand ( args , out var output ) )
78- {
79- var regex = RestoreProjectRegex ( ) ;
80- projects = output
81- . Select ( line => regex . Match ( line ) )
82- . Where ( match => match . Success )
83- . Select ( match => match . Groups [ 1 ] . Value ) ;
84- return true ;
85- }
86-
87- projects = Array . Empty < string > ( ) ;
88- return false ;
91+ var success = dotnetCliInvoker . RunCommand ( args , out var output ) ;
92+ projects = success ? GetRestoredProjects ( output ) : Array . Empty < string > ( ) ;
93+ assets = success ? GetAssetsFilePaths ( output ) : Array . Empty < string > ( ) ;
94+ return success ;
8995 }
9096
9197 public bool New ( string folder )
@@ -120,6 +126,9 @@ public bool Exec(string execArgs)
120126 }
121127
122128 [ GeneratedRegex ( "Restored\\ s+(.+\\ .csproj)" , RegexOptions . Compiled ) ]
123- private static partial Regex RestoreProjectRegex ( ) ;
129+ private static partial Regex RestoredProjectRegex ( ) ;
130+
131+ [ GeneratedRegex ( "[Assets\\ sfile\\ shas\\ snot\\ schanged.\\ sSkipping\\ sassets\\ sfile\\ swriting.|Writing\\ sassets\\ sfile\\ sto\\ sdisk.]\\ sPath:\\ s(.*)" , RegexOptions . Compiled ) ]
132+ private static partial Regex AssetsFileRegex ( ) ;
124133 }
125134}
0 commit comments