@@ -63,7 +63,7 @@ internal override void InternalExecute()
6363 // Deside on WIT
6464 if ( me . WorkItemTypeDefinitions . ContainsKey ( sourceWI . Type . Name ) )
6565 {
66- newwit = CreateAndPopulateWorkItem ( sourceWI , destProject , me . WorkItemTypeDefinitions [ sourceWI . Type . Name ] . Map ( sourceWI ) ) ;
66+ newwit = CreateAndPopulateWorkItem ( _config , sourceWI , destProject , me . WorkItemTypeDefinitions [ sourceWI . Type . Name ] . Map ( sourceWI ) ) ;
6767 if ( newwit . Fields . Contains ( me . ReflectedWorkItemIdFieldName ) )
6868 {
6969 newwit . Fields [ me . ReflectedWorkItemIdFieldName ] . Value = sourceStore . CreateReflectedWorkItemId ( sourceWI ) ;
@@ -135,7 +135,7 @@ private static bool HasChildPBI(WorkItem sourceWI)
135135 return sourceWI . Title . ToLower ( ) . StartsWith ( "epic" ) || sourceWI . Title . ToLower ( ) . StartsWith ( "theme" ) ;
136136 }
137137
138- private static WorkItem CreateAndPopulateWorkItem ( WorkItem oldWi , Project destProject , String destType )
138+ private static WorkItem CreateAndPopulateWorkItem ( WorkItemMigrationConfig config , WorkItem oldWi , Project destProject , String destType )
139139 {
140140 var fieldMappingStartTime = DateTime . UtcNow ;
141141 Stopwatch fieldMappingTimer = new Stopwatch ( ) ;
@@ -198,8 +198,17 @@ private static WorkItem CreateAndPopulateWorkItem(WorkItem oldWi, Project destPr
198198 newwit . Fields [ f . ReferenceName ] . Value = oldWi . Fields [ f . ReferenceName ] . Value ;
199199 }
200200 }
201- newwit . AreaPath = string . Format ( @"{0}\{1}" , newwit . Project . Name , oldWi . AreaPath ) ;
202- newwit . IterationPath = string . Format ( @"{0}\{1}" , newwit . Project . Name , oldWi . IterationPath ) ;
201+ if ( config . PrefixProjectToNodes )
202+ {
203+ newwit . AreaPath = string . Format ( @"{0}\{1}" , newwit . Project . Name , oldWi . AreaPath ) ;
204+ newwit . IterationPath = string . Format ( @"{0}\{1}" , newwit . Project . Name , oldWi . IterationPath ) ;
205+ } else
206+ {
207+ var regex = new Regex ( Regex . Escape ( oldWi . Project . Name ) ) ;
208+ newwit . AreaPath = regex . Replace ( oldWi . AreaPath , "newwit.Project.Name" , 1 ) ;
209+ newwit . IterationPath = regex . Replace ( oldWi . IterationPath , "newwit.Project.Name" , 1 ) ;
210+ }
211+
203212 newwit . Fields [ "System.ChangedDate" ] . Value = oldWi . Fields [ "System.ChangedDate" ] . Value ;
204213
205214 switch ( destType )
0 commit comments