1
- using System ;
1
+ using System ;
2
2
using System . Collections . Generic ;
3
3
using System . IO ;
4
4
using System . Linq ;
@@ -79,7 +79,7 @@ private void Fix(BuildData buildInfo, List<Module> modules, HashSet<string> proc
79
79
processedFiles . Add ( file ) ;
80
80
fixReferenceResult . NotFound [ file ] = new List < string > ( ) ;
81
81
fixReferenceResult . Replaced [ file ] = new List < string > ( ) ;
82
- var refs = vsParser . GetReferencesFromCsproj ( file , fixExternal ) ;
82
+ var refs = vsParser . GetReferencesFromCsproj ( file , buildInfo . Configuration , fixExternal ) ;
83
83
foreach ( var r in refs )
84
84
Fix ( file , r ) ;
85
85
}
@@ -88,6 +88,9 @@ private void Fix(BuildData buildInfo, List<Module> modules, HashSet<string> proc
88
88
private void Fix ( string project , string reference )
89
89
{
90
90
var moduleName = Helper . GetRootFolder ( reference ) ;
91
+ if ( moduleName == rootModuleName && reference . ToLower ( ) . Contains ( "\\ packages\\ " ) )
92
+ return ;
93
+
91
94
if ( ! Directory . Exists ( Path . Combine ( Helper . CurrentWorkspace , moduleName ) ) )
92
95
{
93
96
if ( ! missingModules . Contains ( moduleName ) )
@@ -103,10 +106,10 @@ private void Fix(string project, string reference)
103
106
return ;
104
107
}
105
108
106
- var installFiles = GetAllInstallFiles ( moduleName ) . ToList ( ) ;
109
+ var installFiles = InstallHelper . GetAllInstallFiles ( moduleName ) . ToList ( ) ;
107
110
var withSameName = installFiles . Where ( file => Path . GetFileName ( file ) . Equals ( Path . GetFileName ( reference ) ) ) . ToList ( ) ;
108
111
if ( ! withSameName . Any ( ) )
109
- withSameName = GetAllInstallFilesFromTree ( ) . Where ( file => Path . GetFileName ( file ) . Equals ( Path . GetFileName ( reference ) ) ) . ToList ( ) ;
112
+ withSameName = InstallHelper . GetAllInstallFiles ( ) . Where ( file => Path . GetFileName ( file ) . Equals ( Path . GetFileName ( reference ) ) ) . ToList ( ) ;
110
113
if ( withSameName . Any ( r => Path . GetFullPath ( r ) == Path . GetFullPath ( reference ) ) )
111
114
{
112
115
TryAddToDeps ( reference , project ) ;
@@ -151,26 +154,7 @@ private string UserChoseReplace(string project, string oldReference, List<string
151
154
return answer ;
152
155
}
153
156
154
- private List < string > allInstallFilesFromTree ;
155
-
156
- private List < string > GetAllInstallFilesFromTree ( )
157
- {
158
- if ( allInstallFilesFromTree != null )
159
- return allInstallFilesFromTree ;
160
- var deps = BuildPreparer . BuildConfigsGraph ( rootModuleName , "full-build" ) ;
161
- var usedModules = deps . Select ( dep => dep . Key . Name ) . Distinct ( ) . ToList ( ) ;
162
- allInstallFilesFromTree = usedModules . SelectMany ( GetAllInstallFiles ) . ToList ( ) ;
163
- return allInstallFilesFromTree ;
164
- }
165
-
166
- private List < string > GetAllInstallFiles ( string module )
167
- {
168
- if ( ! File . Exists ( Path . Combine ( Helper . CurrentWorkspace , module , Helper . YamlSpecFile ) ) )
169
- return new List < string > ( ) ;
170
- var configs = Yaml . ConfigurationParser ( module ) . GetConfigurations ( ) ;
171
- var result = configs . Select ( config => Yaml . InstallParser ( module ) . Get ( config ) ) . SelectMany ( parser => parser . Artifacts ) ;
172
- return result . Distinct ( ) . Select ( file => Path . Combine ( module , file ) ) . ToList ( ) ;
173
- }
157
+
174
158
175
159
private void UpdateReference ( string reference , string project )
176
160
{
@@ -194,6 +178,8 @@ private void UpdateReference(string reference, string project)
194
178
private void TryAddToDeps ( string reference , string project )
195
179
{
196
180
var moduleDep = Helper . GetRootFolder ( reference ) ;
181
+ if ( moduleDep == rootModuleName )
182
+ return ;
197
183
198
184
var configs = Yaml . ConfigurationParser ( moduleDep ) . GetConfigurations ( ) ;
199
185
var configsWithArtifact =
@@ -225,9 +211,9 @@ private string GetHintPath(XmlNode xmlNode)
225
211
226
212
class FixReferenceResult
227
213
{
228
- public Dictionary < string , List < string > > NotFound = new Dictionary < string , List < string > > ( ) ;
229
- public Dictionary < string , List < string > > Replaced = new Dictionary < string , List < string > > ( ) ;
230
- public HashSet < string > NoYamlModules = new HashSet < string > ( ) ;
214
+ public readonly Dictionary < string , List < string > > NotFound = new Dictionary < string , List < string > > ( ) ;
215
+ public readonly Dictionary < string , List < string > > Replaced = new Dictionary < string , List < string > > ( ) ;
216
+ public readonly HashSet < string > NoYamlModules = new HashSet < string > ( ) ;
231
217
232
218
public void Print ( )
233
219
{
@@ -251,7 +237,7 @@ public void Print()
251
237
{
252
238
if ( ! NotFound [ key ] . Any ( ) )
253
239
continue ;
254
- ConsoleWriter . WriteError ( key + "\n \t not found references in install/artifacts section of any dep module:" ) ;
240
+ ConsoleWriter . WriteError ( key + "\n \t not found references in install/artifacts section of any module:" ) ;
255
241
foreach ( var value in NotFound [ key ] )
256
242
ConsoleWriter . WriteLine ( "\t " + value ) ;
257
243
}
0 commit comments