11using System ;
22using System . Collections . Generic ;
3+ using System . IO ;
34using System . Linq ;
45using System . Xml ;
56
@@ -24,6 +25,7 @@ public static clsArgsConfig Instance()
2425 "-projectName" , "-projectDir" } ;
2526 public Boolean _validateCommandKey ( )
2627 {
28+
2729 if ( ProjectFolder == "" )
2830 {
2931 Console . WriteLine ( "The projectFolder is not specified." ) ;
@@ -34,6 +36,11 @@ public Boolean _validateCommandKey()
3436 Console . WriteLine ( "ProjectName is not specified." ) ;
3537 return false ;
3638 }
39+
40+ if ( ProjectName != "" )
41+ {
42+ ProjectName = _getProjectName ( ProjectName ) ;
43+ }
3744
3845 return true ;
3946 }
@@ -53,7 +60,7 @@ public void _setArgs(string[] args)
5360 i ++ ;
5461 continue ;
5562 }
56-
63+
5764 if ( commandKey . _indexOf ( "-projectName" ) != - 1 )
5865 {
5966
@@ -70,7 +77,37 @@ public void _setArgs(string[] args)
7077 }
7178 }
7279
73-
74-
80+ /// <summary>
81+ /// プロジェクトパスを取得する
82+ /// </summary>
83+ /// <param name="path"></param>
84+ /// <returns></returns>
85+ private string _getProjectName ( string path )
86+ {
87+ path = path . TrimEnd ( Path . DirectorySeparatorChar ) ;
88+
89+ var separator = Path . DirectorySeparatorChar ;
90+ string [ ] pathArray = path . Split ( separator ) ;
91+
92+ if ( pathArray . Length == 0 )
93+ {
94+ return path ;
95+ }
96+
97+ for ( int i = pathArray . Length ; i > 0 ; i -- )
98+ {
99+ var pathArray1 = pathArray [ 0 ..i ] ;
100+ string stCsvData = string . Join ( "/" , pathArray1 ) ;
101+ string csprojPath = stCsvData + "/" + pathArray [ i - 1 ] + ".csproj" ;
102+ if ( File . Exists ( csprojPath ) )
103+ {
104+ return pathArray [ i - 1 ] ;
105+ break ;
106+ }
107+ }
108+
109+ return "" ;
110+ }
111+
75112 }
76113}
0 commit comments