@@ -649,36 +649,52 @@ private Hashtable GetMetadataFromNupkg(string packageName, string packagePath, s
649
649
_cmdletPassedIn . WriteVerbose ( $ "Extracting '{ zipFilePath } ' to '{ tempDiscoveryPath } '") ;
650
650
System . IO . Compression . ZipFile . ExtractToDirectory ( zipFilePath , tempDiscoveryPath ) ;
651
651
652
- string psd1FilePath = Path . Combine ( tempDiscoveryPath , $ "{ packageName } .psd1") ;
653
- string ps1FilePath = Path . Combine ( tempDiscoveryPath , $ "{ packageName } .ps1") ;
654
- string nuspecFilePath = Path . Combine ( tempDiscoveryPath , $ "{ packageName } .nuspec") ;
652
+ var currentFiles = Directory . GetFiles ( tempDiscoveryPath ) ;
655
653
656
- List < string > pkgTags = new List < string > ( ) ;
657
- _cmdletPassedIn . WriteVerbose ( $ "nuspecFilePath: { nuspecFilePath } ") ;
658
- string path = tempDiscoveryPath ;
659
- try {
660
- // Get the files in the directory
661
- string [ ] files = Directory . GetFiles ( path ) ;
662
- // Get the directories in the directory
663
- string [ ] directories = Directory . GetDirectories ( path ) ;
664
- // Output the files
665
- _cmdletPassedIn . WriteVerbose ( "Files:" ) ;
666
- foreach ( string file in files )
667
- {
668
- _cmdletPassedIn . WriteVerbose ( file ) ;
669
- }
670
- // Output the directories
671
- _cmdletPassedIn . WriteVerbose ( "\n Directories:" ) ;
672
- foreach ( string directory in directories )
654
+ string psd1FilePath = String . Empty ;
655
+ string nuspecFilePath = String . Empty ;
656
+ string pkgNamePattern = $ "{ packageName } *";
657
+ Regex rgx = new ( pkgNamePattern , RegexOptions . IgnoreCase ) ;
658
+ foreach ( var x in currentFiles )
659
+ {
660
+ if ( rgx . IsMatch ( x ) )
673
661
{
674
- _cmdletPassedIn . WriteVerbose ( directory ) ;
675
- }
676
- } catch ( Exception e )
662
+ if ( x . EndsWith ( "psd1" ) )
663
+ {
664
+ psd1FilePath = x ;
665
+ }
666
+ else if ( x . EndsWith ( "nuspec" ) )
667
+ {
668
+ nuspecFilePath = x ;
669
+ }
670
+ }
671
+ _cmdletPassedIn . WriteVerbose ( $ "file found: " + x ) ;
672
+
673
+ }
674
+
675
+ foreach ( var x in currentFiles )
677
676
{
678
- _cmdletPassedIn . WriteVerbose ( "An error occurred: " + e . Message ) ;
677
+ _cmdletPassedIn . WriteVerbose ( $ "file found: " + x ) ;
678
+
679
+ }
680
+
681
+ var files = Directory . EnumerateFiles ( tempDiscoveryPath , "*.*" , SearchOption . AllDirectories ) . Where (
682
+ s => s . Equals ( $ "{ packageName } .nuspec", StringComparison . InvariantCultureIgnoreCase ) ) ;
683
+
684
+ _cmdletPassedIn . WriteVerbose ( $ "files len: { files . Count ( ) } ") ;
685
+
686
+ foreach ( var x in files ) {
687
+ _cmdletPassedIn . WriteVerbose ( $ "file : { x } ") ;
679
688
}
680
689
681
- if ( File . Exists ( psd1FilePath ) )
690
+ // string psd1FilePath = Path.Combine(tempDiscoveryPath, $"{packageName}.psd1");
691
+ string ps1FilePath = Path . Combine ( tempDiscoveryPath , $ "{ packageName } .ps1") ;
692
+ // string nuspecFilePath = Path.Combine(tempDiscoveryPath, $"{packageName}.nuspec");
693
+
694
+ List < string > pkgTags = new List < string > ( ) ;
695
+ _cmdletPassedIn . WriteVerbose ( $ "nuspecFilePath: { nuspecFilePath } ") ;
696
+
697
+ if ( files . Contains ( psd1FilePath ) )
682
698
{
683
699
_cmdletPassedIn . WriteDebug ( $ "Attempting to read module manifest file '{ psd1FilePath } '") ;
684
700
if ( ! Utils . TryReadManifestFile ( psd1FilePath , out pkgMetadata , out Exception readManifestError ) )
0 commit comments