@@ -47,7 +47,7 @@ public void Migrate(MigrationSettings rootSettings, bool skipProjectReferences =
4747 return ;
4848 }
4949
50- var projectDependencies = ResolveTransitiveClosureProjectDependencies ( rootSettings . ProjectDirectory ) ;
50+ var projectDependencies = ResolveTransitiveClosureProjectDependencies ( rootSettings . ProjectDirectory , rootSettings . ProjectXProjFilePath ) ;
5151
5252 foreach ( var project in projectDependencies )
5353 {
@@ -60,11 +60,10 @@ public void Migrate(MigrationSettings rootSettings, bool skipProjectReferences =
6060 }
6161 }
6262
63- private IEnumerable < ProjectDependency > ResolveTransitiveClosureProjectDependencies ( string rootProject )
63+ private IEnumerable < ProjectDependency > ResolveTransitiveClosureProjectDependencies ( string rootProject , string xprojFile )
6464 {
6565 HashSet < ProjectDependency > projectsMap = new HashSet < ProjectDependency > ( new ProjectDependencyComparer ( ) ) ;
66- var projectContexts = ProjectContext . CreateContextForEachFramework ( rootProject ) ;
67- var projectDependencies = _projectDependencyFinder . ResolveProjectDependencies ( projectContexts ) ;
66+ var projectDependencies = _projectDependencyFinder . ResolveProjectDependencies ( rootProject , xprojFile ) ;
6867 Queue < ProjectDependency > projectsQueue = new Queue < ProjectDependency > ( projectDependencies ) ;
6968
7069 while ( projectsQueue . Count ( ) != 0 )
@@ -78,8 +77,8 @@ private IEnumerable<ProjectDependency> ResolveTransitiveClosureProjectDependenci
7877
7978 projectsMap . Add ( projectDependency ) ;
8079
81- projectContexts = ProjectContext . CreateContextForEachFramework ( projectDependency . ProjectFilePath ) ;
82- projectDependencies = _projectDependencyFinder . ResolveProjectDependencies ( projectContexts ) ;
80+ var projectDir = Path . GetDirectoryName ( projectDependency . ProjectFilePath ) ;
81+ projectDependencies = _projectDependencyFinder . ResolveProjectDependencies ( projectDir ) ;
8382
8483 foreach ( var project in projectDependencies )
8584 {
@@ -110,7 +109,7 @@ private void MigrateHelper(MigrationSettings migrationSettings)
110109 private MigrationRuleInputs ComputeMigrationRuleInputs ( MigrationSettings migrationSettings )
111110 {
112111 var projectContexts = ProjectContext . CreateContextForEachFramework ( migrationSettings . ProjectDirectory ) ;
113- var xprojFile = migrationSettings . ProjectXProjFilePath ?? FindXprojFile ( migrationSettings . ProjectDirectory ) ;
112+ var xprojFile = migrationSettings . ProjectXProjFilePath ?? _projectDependencyFinder . FindXprojFile ( migrationSettings . ProjectDirectory ) ;
114113
115114 ProjectRootElement xproj = null ;
116115 if ( xprojFile != null )
@@ -130,20 +129,6 @@ private MigrationRuleInputs ComputeMigrationRuleInputs(MigrationSettings migrati
130129 return new MigrationRuleInputs ( projectContexts , templateMSBuildProject , itemGroup , propertyGroup , xproj ) ;
131130 }
132131
133- private string FindXprojFile ( string projectDirectory )
134- {
135- var allXprojFiles = Directory . EnumerateFiles ( projectDirectory , "*.xproj" , SearchOption . TopDirectoryOnly ) ;
136-
137- if ( allXprojFiles . Count ( ) > 1 )
138- {
139- MigrationErrorCodes
140- . MIGRATE1017 ( $ "Multiple xproj files found in { projectDirectory } , please specify which to use")
141- . Throw ( ) ;
142- }
143-
144- return allXprojFiles . FirstOrDefault ( ) ;
145- }
146-
147132 private void VerifyInputs ( MigrationRuleInputs migrationRuleInputs , MigrationSettings migrationSettings )
148133 {
149134 VerifyProject ( migrationRuleInputs . ProjectContexts , migrationSettings . ProjectDirectory ) ;
0 commit comments