@@ -895,8 +895,9 @@ public bool RetainFolderStructureOverride
895
895
/// <summary>
896
896
/// The root directory of the package
897
897
/// </summary>
898
- private string CurrentPackageDirectory { get ; set ; }
898
+ private IEnumerable < string > CurrentPackageRootDirectories { get ; set ; }
899
899
private static MetadataLoadContext sharedMetaDataLoadContext = null ;
900
+
900
901
/// <summary>
901
902
/// A shared MetaDataLoadContext that is used for assembly inspection during package publishing.
902
903
/// This member is shared so the behavior is similar to the ReflectionOnlyLoadContext this is replacing.
@@ -1073,34 +1074,30 @@ internal List<PackageItemRootViewModel> BindParentToChild(Dictionary<string, Pac
1073
1074
}
1074
1075
1075
1076
// Only add the folder items, they contain the files
1076
- var updatedItems = GetRootItems ( items ) ;
1077
+ var updatedItems = OrganizePackageRootItems ( items ) ;
1077
1078
return updatedItems ;
1078
1079
}
1079
1080
1080
1081
/// <summary>
1081
- /// Gets the list PackageItemRootViewModel items which will be at the root directory of the package with all the child items.
1082
+ /// Organizes package items into root items based on common paths and hierarchical structure.
1083
+ /// This includes determining root items, establishing parent-child relationships, and collecting all child items.
1082
1084
/// </summary>
1083
- /// <param name="items"></param>
1084
- /// <returns></returns>
1085
- private List < PackageItemRootViewModel > GetRootItems ( Dictionary < string , PackageItemRootViewModel > items )
1085
+ /// <param name="items">A dictionary of package item keys and their corresponding PackageItemRootViewModel objects. </param>
1086
+ /// <returns>A list of PackageItemRootViewModel items representing the organized root items and their child items. </returns>
1087
+ private List < PackageItemRootViewModel > OrganizePackageRootItems ( Dictionary < string , PackageItemRootViewModel > items )
1086
1088
{
1087
1089
var rootItems = items . Values . Where ( x => ! x . isChild ) . ToList ( ) ;
1088
1090
if ( ! rootItems . Any ( ) ) return rootItems ;
1089
1091
1090
1092
var roots = new List < PackageItemRootViewModel > ( ) ;
1093
+
1094
+ var commonPaths = GetCommonPaths ( items . Keys . ToArray ( ) ) ;
1095
+ if ( commonPaths == null ) return null ;
1091
1096
1092
- if ( CurrentPackageDirectory != null )
1093
- {
1094
- roots . Add ( new PackageItemRootViewModel ( CurrentPackageDirectory ) ) ;
1095
- }
1096
- else
1097
- {
1098
- var commonPaths = GetCommonPaths ( items . Keys . ToArray ( ) ) ;
1099
- if ( commonPaths == null ) return null ;
1097
+ CurrentPackageRootDirectories = commonPaths ;
1100
1098
1101
- // Add a new root item for each common path found
1102
- commonPaths . ForEach ( p => roots . Add ( new PackageItemRootViewModel ( p ) ) ) ;
1103
- }
1099
+ // Add a new root item for each common path found
1100
+ commonPaths . ForEach ( p => roots . Add ( new PackageItemRootViewModel ( p ) ) ) ;
1104
1101
1105
1102
// Check each root item and create any missing connections
1106
1103
foreach ( var item in rootItems )
@@ -1532,7 +1529,7 @@ internal static PublishPackageViewModel FromLocalPackage(DynamoViewModel dynamoV
1532
1529
CopyrightHolder = pkg . CopyrightHolder ,
1533
1530
CopyrightYear = pkg . CopyrightYear ,
1534
1531
IsPublishFromLocalPackage = true ,
1535
- CurrentPackageDirectory = pkg . RootDirectory ,
1532
+ CurrentPackageRootDirectories = new List < string > { pkg . RootDirectory } ,
1536
1533
//default retain folder structure to true when publishing a new version from local.
1537
1534
RetainFolderStructureOverride = retainFolderStructure
1538
1535
} ;
@@ -2270,7 +2267,7 @@ private void Submit()
2270
2267
{
2271
2268
// begin submission
2272
2269
var pmExtension = dynamoViewModel . Model . GetPackageManagerExtension ( ) ;
2273
- var handle = pmExtension . PackageManagerClient . PublishAsync ( Package , RetainFolderStructureOverride ? updatedFiles : contentFiles , MarkdownFiles , IsNewVersion , RetainFolderStructureOverride ) ;
2270
+ var handle = pmExtension . PackageManagerClient . PublishAsync ( Package , RetainFolderStructureOverride ? updatedFiles : contentFiles , MarkdownFiles , IsNewVersion , CurrentPackageRootDirectories , RetainFolderStructureOverride ) ;
2274
2271
2275
2272
// start upload
2276
2273
Uploading = true ;
@@ -2365,11 +2362,7 @@ private void PublishLocally()
2365
2362
var remapper = new CustomNodePathRemapper ( DynamoViewModel . Model . CustomNodeManager ,
2366
2363
DynamoModel . IsTestMode ) ;
2367
2364
var builder = new PackageDirectoryBuilder ( new MutatingFileSystem ( ) , remapper ) ;
2368
- if ( string . IsNullOrEmpty ( Package . RootDirectory ) )
2369
- {
2370
- Package . RootDirectory = CurrentPackageDirectory ;
2371
- }
2372
- builder . BuildRetainDirectory ( Package , publishPath , updatedFiles , MarkdownFiles ) ;
2365
+ builder . BuildRetainDirectory ( Package , publishPath , CurrentPackageRootDirectories , updatedFiles , MarkdownFiles ) ;
2373
2366
UploadState = PackageUploadHandle . State . Uploaded ;
2374
2367
}
2375
2368
else
@@ -2770,11 +2763,11 @@ internal PackageItemRootViewModel GetExistingRootItemViewModel(string publishPat
2770
2763
{
2771
2764
if ( ! PackageContents . Any ( ) ) return null ;
2772
2765
if ( PackageContents . Count ( x => x . DependencyType . Equals ( DependencyType . Folder ) ) == 1 ) {
2773
- // If there is only one root item, nest it under the new root package folder
2766
+ // If there is only one root item, this root item becomes the new folder
2774
2767
var item = PackageContents . First ( x => x . DependencyType . Equals ( DependencyType . Folder ) ) ;
2775
2768
2776
2769
item = new PackageItemRootViewModel ( Path . Combine ( publishPath , packageName ) ) ;
2777
- item . AddChildren ( new List < PackageItemRootViewModel > { PackageContents . First ( ) } ) ;
2770
+ item . AddChildren ( PackageContents . First ( ) . ChildItems . ToList ( ) ) ;
2778
2771
2779
2772
return item ;
2780
2773
}
@@ -2783,6 +2776,9 @@ internal PackageItemRootViewModel GetExistingRootItemViewModel(string publishPat
2783
2776
var rootItem = new PackageItemRootViewModel ( Path . Combine ( publishPath , packageName ) ) ;
2784
2777
foreach ( var item in PackageContents )
2785
2778
{
2779
+ // Skip 'bare' custom nodes, they will be represented by their CustomNodePreview counterparts
2780
+ if ( item . DependencyType . Equals ( DependencyType . CustomNode ) ) { continue ; }
2781
+
2786
2782
item . isChild = true ;
2787
2783
rootItem . AddChildren ( item ) ;
2788
2784
}
0 commit comments