@@ -60,32 +60,38 @@ private string GetRestoreArgs(string projectOrSolutionFile, string packageDirect
60
60
return args ;
61
61
}
62
62
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 )
64
76
{
65
77
var args = GetRestoreArgs ( projectFile , packageDirectory , forceDotnetRefAssemblyFetching ) ;
66
78
if ( pathToNugetConfig != null )
67
79
{
68
80
args += $ " --configfile \" { pathToNugetConfig } \" ";
69
81
}
70
82
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 ;
72
86
}
73
87
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 )
75
89
{
76
90
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 ;
89
95
}
90
96
91
97
public bool New ( string folder )
@@ -120,6 +126,9 @@ public bool Exec(string execArgs)
120
126
}
121
127
122
128
[ 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 ( ) ;
124
133
}
125
134
}
0 commit comments