@@ -30,30 +30,13 @@ function listFilesExcludingGitignored(root: string): string[] {
3030 . filter ( fn => gitignoreEvaluator . accepts ( fn ) ) ;
3131}
3232
33- function applyContentReplacements ( sourceContent : Buffer , contentReplacements : { from : RegExp , to : string } [ ] ) {
34- let sourceText = sourceContent . toString ( 'utf8' ) ;
35- contentReplacements . forEach ( replacement => {
36- sourceText = sourceText . replace ( replacement . from , replacement . to ) ;
37- } ) ;
38-
39- return new Buffer ( sourceText , 'utf8' ) ;
40- }
41-
4233function writeTemplate ( sourceRoot : string , destRoot : string ) {
4334 listFilesExcludingGitignored ( sourceRoot ) . forEach ( fn => {
4435 let sourceContent = fs . readFileSync ( path . join ( sourceRoot , fn ) ) ;
4536 writeFileEnsuringDirExists ( destRoot , fn , sourceContent ) ;
4637 } ) ;
4738}
4839
49- function copyRecursive ( sourceRoot : string , destRoot : string , matchGlob : string ) {
50- glob . sync ( matchGlob , { cwd : sourceRoot , dot : true , nodir : true } )
51- . forEach ( fn => {
52- const sourceContent = fs . readFileSync ( path . join ( sourceRoot , fn ) ) ;
53- writeFileEnsuringDirExists ( destRoot , fn , sourceContent ) ;
54- } ) ;
55- }
56-
5740function getBuildNumber ( ) : string {
5841 if ( process . env . APPVEYOR_BUILD_NUMBER ) {
5942 return process . env . APPVEYOR_BUILD_NUMBER ;
@@ -88,23 +71,25 @@ function buildDotNetNewNuGetPackage(packageId: string) {
8871 } ) ;
8972
9073 // Create the .nuspec file
91- const nuspecContentTemplate = fs . readFileSync ( path . join ( packageSourceRootDir , `${ packageId } .nuspec` ) ) ;
74+ const nuspecFilename = `${ packageId } .nuspec` ;
75+ const nuspecContentTemplate = fs . readFileSync ( path . join ( packageSourceRootDir , nuspecFilename ) ) ;
9276 writeFileEnsuringDirExists ( outputRoot ,
93- `${ packageId } .nuspec` ,
94- applyContentReplacements ( nuspecContentTemplate , [
95- { from : / \{ b u i l d n u m b e r \} / g, to : getBuildNumber ( ) } ,
96- ] )
77+ nuspecFilename ,
78+ nuspecContentTemplate
9779 ) ;
9880
9981 // Invoke NuGet to create the final package
10082 const nugetExe = path . join ( process . cwd ( ) , './bin/NuGet.exe' ) ;
10183 const nugetStartInfo = { cwd : outputRoot , stdio : 'inherit' } ;
84+ const packageVersion = `1.0.${ getBuildNumber ( ) } ` ;
85+ const nugetArgs = [ 'pack' , nuspecFilename , '-Version' , packageVersion ] ;
10286 if ( isWindows ) {
10387 // Invoke NuGet.exe directly
104- childProcess . spawnSync ( nugetExe , [ 'pack' ] , nugetStartInfo ) ;
88+ childProcess . spawnSync ( nugetExe , nugetArgs , nugetStartInfo ) ;
10589 } else {
10690 // Invoke via Mono (relying on that being available)
107- childProcess . spawnSync ( 'mono' , [ nugetExe , 'pack' ] , nugetStartInfo ) ;
91+ nugetArgs . unshift ( nugetExe ) ;
92+ childProcess . spawnSync ( 'mono' , nugetArgs , nugetStartInfo ) ;
10893 }
10994
11095 // Clean up
0 commit comments