@@ -90,8 +90,8 @@ Class.Define('BaseBuild', {
9090 var dirFullPath = '' ;
9191 for ( var i = 0 , l = this . modulesInfo . length ; i < l ; i += 1 ) {
9292 dirFullPath = this . modulesInfo [ i ] . dirFullPath ;
93- this . cleanDirectory ( dirFullPath + '/bin/Debug' ) ;
94- this . cleanDirectory ( dirFullPath + '/bin/Release' ) ;
93+ this . cleanDirectory ( dirFullPath + '/bin/Debug' , [ 'nupkg' ] ) ;
94+ this . cleanDirectory ( dirFullPath + '/bin/Release' , [ 'nupkg' ] ) ;
9595 }
9696 } ,
9797 setUpVersionToAssemblyInfos : function ( ) {
@@ -149,14 +149,15 @@ Class.Define('BaseBuild', {
149149 readStream = Wsh . Fso . OpenTextFile ( nugetCfgFullPath , 1 , false ) ;
150150 nugetCfgContent = readStream . ReadAll ( ) ;
151151 readStream . Close ( ) ;
152- nugetCfgContent = this . _setUpVersionToNugspecCfgContent ( nugetCfgContent ) ;
152+ nugetCfgContent = this . _setUpVersionToNugspecCfgContentVersionNode ( nugetCfgContent ) ;
153+ nugetCfgContent = this . _setUpVersionToNugspecCfgContentDependencyNode ( nugetCfgContent ) ;
153154 // for overwriting, not as Unicode
154155 writeStream = Wsh . Fso . CreateTextFile ( nugetCfgFullPath , true , false ) ;
155156 writeStream . Write ( nugetCfgContent ) ;
156157 writeStream . Close ( ) ;
157158 }
158159 } ,
159- _setUpVersionToNugspecCfgContent : function ( nugetCfgContent ) {
160+ _setUpVersionToNugspecCfgContentVersionNode : function ( nugetCfgContent ) {
160161 var index = 0 ,
161162 openingNode = '<version>' ,
162163 closingNode = '</version>' ,
@@ -182,6 +183,35 @@ Class.Define('BaseBuild', {
182183 }
183184 return nugetCfgContent ;
184185 } ,
186+ _setUpVersionToNugspecCfgContentDependencyNode : function ( nugetCfgContent ) {
187+ var index = 0 ,
188+ openingNode = '<dependency id="Databasic' ,
189+ closingNode = '/>' ,
190+ valueBegin = 0 ,
191+ valueEnd = 0 ,
192+ versionStr = '' ,
193+ versionsJoined = this . versions . join ( '.' ) ;
194+ while ( true ) {
195+ valueBegin = nugetCfgContent . indexOf ( openingNode , index ) ;
196+ if ( valueBegin == - 1 ) break ;
197+ valueBegin += openingNode . length ;
198+ valueEnd = nugetCfgContent . indexOf ( closingNode , valueBegin ) ;
199+ if ( valueEnd == - 1 ) break ;
200+ versionStr = nugetCfgContent . substring ( valueBegin , valueEnd ) ;
201+ if ( ! / v e r s i o n = " ( [ 0 - 9 \. ] * ) " / gi. test ( versionStr ) ) {
202+ index = valueEnd ;
203+ continue ;
204+ }
205+ versionStr = versionStr . replace ( / v e r s i o n = " ( [ 0 - 9 \. ] * ) " / gi, function ( m ) {
206+ return 'version="' + versionsJoined + '"' ;
207+ } ) ;
208+ nugetCfgContent = nugetCfgContent . substr ( 0 , valueBegin )
209+ + versionStr
210+ + nugetCfgContent . substr ( valueEnd ) ;
211+ index = valueBegin + versionStr . length ;
212+ }
213+ return nugetCfgContent ;
214+ } ,
185215 setUpVersionToReadmes : function ( ) {
186216 var readStream = null ,
187217 writeStream = null ,
@@ -210,15 +240,15 @@ Class.Define('BaseBuild', {
210240 //log(nugetCfgContent);
211241 return nugetCfgContent ;
212242 } ,
213- cleanDirectory : function ( relativeOrAbsolutePath , allFiles ) {
243+ cleanDirectory : function ( relativeOrAbsolutePath , extensions ) {
214244 var folder = Wsh . Fso . GetFolder ( relativeOrAbsolutePath ) ,
215245 filesEnum = new Enumerator ( folder . files ) ,
216- allFiles = ! ! allFiles ,
246+ allFiles = extensions == '*' ,
217247 fileExt = '' ;
218248 for ( ; ! filesEnum . atEnd ( ) ; filesEnum . moveNext ( ) ) {
219249 file = Wsh . Fso . GetFile ( String ( filesEnum . item ( ) ) ) ;
220250 fileExt = String ( Wsh . Fso . GetExtensionName ( file . Path ) ) . toLowerCase ( ) ;
221- if ( allFiles || ( ! allFiles && fileExt == 'nupkg' ) ) {
251+ if ( allFiles || ( ! allFiles && extensions . indexOf ( fileExt ) > - 1 ) ) {
222252 try {
223253 Wsh . Fso . DeleteFile ( file . Path ) ;
224254 } catch ( e ) { }
0 commit comments