@@ -646,44 +646,15 @@ private Hashtable GetMetadataFromNupkg(string packageName, string packagePath, s
646646 File . Move ( destNupkgPath , zipFilePath ) ;
647647
648648 // extract from .zip
649- _cmdletPassedIn . WriteVerbose ( $ "Extracting '{ zipFilePath } ' to '{ tempDiscoveryPath } '") ;
649+ _cmdletPassedIn . WriteDebug ( $ "Extracting '{ zipFilePath } ' to '{ tempDiscoveryPath } '") ;
650650 System . IO . Compression . ZipFile . ExtractToDirectory ( zipFilePath , tempDiscoveryPath ) ;
651651
652- var currentFiles = Directory . GetFiles ( tempDiscoveryPath ) ;
653-
654652 string psd1FilePath = String . Empty ;
655653 string ps1FilePath = String . Empty ;
656654 string nuspecFilePath = String . Empty ;
657- string pkgNamePattern = $ "{ packageName } *";
658- Regex rgx = new ( pkgNamePattern , RegexOptions . IgnoreCase ) ;
659- foreach ( var x in currentFiles )
660- {
661- if ( rgx . IsMatch ( x ) )
662- {
663- _cmdletPassedIn . WriteVerbose ( "file is a match: " + x ) ;
664- if ( x . EndsWith ( "psd1" ) )
665- {
666- psd1FilePath = x ;
667- }
668- else if ( x . EndsWith ( "nuspec" ) )
669- {
670- nuspecFilePath = x ;
671- }
672- else if ( x . EndsWith ( "ps1" ) )
673- {
674- ps1FilePath = x ;
675- }
676- }
677-
678- _cmdletPassedIn . WriteVerbose ( $ "file found: " + x ) ;
679- }
680-
681- // string psd1FilePath = Path.Combine(tempDiscoveryPath, $"{packageName}.psd1");
682- // string ps1FilePath = Path.Combine(tempDiscoveryPath, $"{packageName}.ps1");
683- // string nuspecFilePath = Path.Combine(tempDiscoveryPath, $"{packageName}.nuspec");
655+ GetMetadataFilesFromPath ( tempDiscoveryPath , packageName , out psd1FilePath , out ps1FilePath , out nuspecFilePath )
684656
685657 List < string > pkgTags = new List < string > ( ) ;
686- _cmdletPassedIn . WriteVerbose ( $ "nuspecFilePath: { nuspecFilePath } ") ;
687658
688659 if ( File . Exists ( psd1FilePath ) )
689660 {
@@ -1113,6 +1084,35 @@ private string[] GetCmdsOrDSCTags(string[] tags, bool isSearchingForCommands)
11131084 return cmdDSCTags . ToArray ( ) ;
11141085 }
11151086
1087+ private void GetMetadataFilesFromPath ( string dirPath , string packageName , out string psd1FilePath , out string ps1FilePath , out string nuspecFilePath )
1088+ {
1089+ psd1FilePath = String . Empty ;
1090+ ps1FilePath = String . Empty ;
1091+ nuspecFilePath = String . Empty ;
1092+
1093+ var discoveredFiles = Directory . GetFiles ( tempDiscoveryPath , "*.*" , SearchOption . AllDirectories ) ;
1094+ string pkgNamePattern = $ "{ packageName } *";
1095+ Regex rgx = new ( pkgNamePattern , RegexOptions . IgnoreCase ) ;
1096+ foreach ( var file in foundFiles )
1097+ {
1098+ if ( rgx . IsMatch ( discoveredFiles ) )
1099+ {
1100+ if ( file . EndsWith ( "psd1" ) )
1101+ {
1102+ psd1FilePath = file ;
1103+ }
1104+ else if ( file . EndsWith ( "nuspec" ) )
1105+ {
1106+ nuspecFilePath = file ;
1107+ }
1108+ else if ( file . EndsWith ( "ps1" ) )
1109+ {
1110+ ps1FilePath = file ;
1111+ }
1112+ }
1113+ }
1114+ }
1115+
11161116 #endregion
11171117 }
11181118}
0 commit comments