You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2017/05/09 18:51:34 UTC

lucenenet git commit: build.bat + build\build.ps1: updated build process so not passing a version number makes it use the version from Verson.proj. Also fixed the generated build.bat file so it includes the ability to test through a -t or --test switch.

Repository: lucenenet
Updated Branches:
  refs/heads/master 483611579 -> 0ff95608b


build.bat + build\build.ps1: updated build process so not passing a version number makes it use the version from Verson.proj. Also fixed the generated build.bat file so it includes the ability to test through a -t or --test switch. Changed all switches to follow standard conventions - for short form, -- for long form.


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/0ff95608
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/0ff95608
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/0ff95608

Branch: refs/heads/master
Commit: 0ff95608b8b17ea7bd386c91a99828f468ff8a12
Parents: 4836115
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Wed May 10 01:20:44 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Wed May 10 01:20:44 2017 +0700

----------------------------------------------------------------------
 build.bat       | 43 +++++++++++++++++++++++--------------------
 build/build.ps1 | 44 +++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 62 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/0ff95608/build.bat
----------------------------------------------------------------------
diff --git a/build.bat b/build.bat
index 3bdc8f1..318c836 100644
--- a/build.bat
+++ b/build.bat
@@ -1,5 +1,7 @@
 @echo off
 GOTO endcommentblock
+:: -----------------------------------------------------------------------------------
+::
 ::  Licensed to the Apache Software Foundation (ASF) under one or more
 ::  contributor license agreements.  See the NOTICE file distributed with
 ::  this work for additional information regarding copyright ownership.
@@ -24,17 +26,17 @@ GOTO endcommentblock
 ::
 :: Available Options:
 ::
-::   -Version:<Version>
+::   --Version:<Version>
 ::   -v:<Version> - Assembly version number. If not supplied, the version will be the same 
 ::                  as PackageVersion (excluding any pre-release tag).
 ::
-::   -PackageVersion:<PackageVersion>
+::   --PackageVersion:<PackageVersion>
 ::   -pv:<PackageVersion> - Nuget package version. Default is 0.0.0, which instructs the script to use the value in Version.proj.
 ::
-::   -Configuration:<Configuration>
+::   --Configuration:<Configuration>
 ::   -config:<Configuration> - MSBuild configuration for the build.
 ::
-::   -Test
+::   --Test
 ::   -t - Run the tests.
 ::
 ::   All options are case insensitive.
@@ -51,14 +53,14 @@ IF "%version%" == "" (
 	REM  If version is not supplied, our build script should parse it
 	REM  from the %PackageVersion% variable. We determine this by checking
 	REM  whether it is 0.0.0 (uninitialized).
-	set version=0.0.0
+ 	set version=0.0.0
 )
 IF "%PackageVersion%" == "" (
     set PackageVersion=0.0.0
 )
 set configuration=Release
 IF NOT "%config%" == "" (
-	set configuration=%config%
+ 	set configuration=%config%
 )
 set runtests=false
 
@@ -71,9 +73,9 @@ FOR %%a IN (%*) DO (
 			set version=!value:~3!
 		)
 
-		set test=!value:~0,9!
-		IF /I !test! EQU -version: (
-			set version=!value:~9!
+		set test=!value:~0,10!
+		IF /I !test! EQU --version: (
+			set version=!value:~10!
 		)
 		
 		set test=!value:~0,4!
@@ -81,9 +83,9 @@ FOR %%a IN (%*) DO (
 			set packageversion=!value:~4!
 		)
 
-		set test=!value:~0,16!
-		IF /I !test!==-packageversion: (
-			set packageversion=!value:~16!
+		set test=!value:~0,17!
+		IF /I !test!==--packageversion: (
+			set packageversion=!value:~17!
 		)
 
 		set test=!value:~0,8!
@@ -91,9 +93,9 @@ FOR %%a IN (%*) DO (
 			set configuration=!value:~8!
 		)
 
-		set test=!value:~0,15!
-		IF /I !test!==-configuration: (
-			set configuration=!value:~15!
+		set test=!value:~0,16!
+		IF /I !test!==--configuration: (
+			set configuration=!value:~16!
 		)
 		
 		set test=!value:~0,2!
@@ -101,17 +103,18 @@ FOR %%a IN (%*) DO (
 			set runtests=true
 		)
 
-		set test=!value:~0,5!
-		IF /I !test!==-test: (
+		set test=!value:~0,6!
+		IF /I !test!==--test: (
 			set runtests=true
 		)
 	)
 )
 
-powershell -ExecutionPolicy Bypass -Command "& { Import-Module .\build\psake.psm1; Invoke-Psake .\build\build.ps1 -properties @{\"version\"=\"%version%\";\"configuration\"=\"%configuration%"\";\"packageVersion\"=\"%PackageVersion%"\"} }"
-
+set tasks="Default"
 if "!runtests!"=="true" (
-	powershell -ExecutionPolicy Bypass -Command "& { Import-Module .\build\psake.psm1; Invoke-Psake .\build\build.ps1 -task Test -properties @{\"version\"=\"%version%\";\"configuration\"=\"%configuration%"\";\"packageVersion\"=\"%PackageVersion%"\"} }"
+	set tasks="Default,Test"
 )
 
+powershell -ExecutionPolicy Bypass -Command "& { Import-Module .\build\psake.psm1; Invoke-Psake .\build\build.ps1 %tasks% -properties @{configuration='%configuration%'} -parameters @{ packageVersion='%PackageVersion%';version='%version%' } }"
+
 endlocal

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/0ff95608/build/build.ps1
----------------------------------------------------------------------
diff --git a/build/build.ps1 b/build/build.ps1
index c894966..0db9bc1 100644
--- a/build/build.ps1
+++ b/build/build.ps1
@@ -199,9 +199,9 @@ function Get-Package-Version() {
 	Write-Host $parameters.packageVersion -ForegroundColor Red
 
 	#If $packageVersion is not passed in (as a parameter or environment variable), get it from Version.proj
-	if (![string]::IsNullOrWhiteSpace($parameters.packageVersion) -and $packageVersion -ne "0.0.0") {
-		return $packageVersion
-	} elseif (![string]::IsNullOrWhiteSpace($env:PackageVersion)) {
+	if (![string]::IsNullOrWhiteSpace($parameters.packageVersion) -and $parameters.packageVersion -ne "0.0.0") {
+		return $parameters.packageVersion
+	} elseif (![string]::IsNullOrWhiteSpace($env:PackageVersion) -and $env:PackageVersion -ne "0.0.0") {
 		return $env:PackageVersion
 	} else {
 		#Get the version info
@@ -212,6 +212,9 @@ function Get-Package-Version() {
 
 		if ([string]::IsNullOrWhiteSpace($versionSuffix)) {
 			# this is a production release - use 4 segment version number 0.0.0.0
+			if ([string]::IsNullOrWhiteSpace($buildCounter)) {
+				$buildCounter = "0"
+			}
 			$packageVersion = "$versionPrefix.$buildCounter"
 		} else {
 			if (![string]::IsNullOrWhiteSpace($buildCounter)) {
@@ -370,12 +373,43 @@ GOTO endcommentblock
 :: This file will build Lucene.Net and create the NuGet packages.
 ::
 :: Syntax:
-::   build[.bat]
+::   build[.bat] [<options>]
+::
+:: Available Options:
+::
+::   --Test
+::   -t - Run the tests.
 ::
 :: -----------------------------------------------------------------------------------
 :endcommentblock
+setlocal enabledelayedexpansion enableextensions
+
+set runtests=false
+
+FOR %%a IN (%*) DO (
+	FOR /f ""useback tokens=*"" %%a in ('%%a') do (
+		set value=%%~a
+		
+		set test=!value:~0,2!
+		IF /I !test!==-t (
+			set runtests=true
+		)
+
+		set test=!value:~0,6!
+		IF /I !test!==--test: (
+			set runtests=true
+		)
+	)
+)
+
+set tasks=""Default""
+if ""!runtests!""==""true"" (
+	set tasks=""Default,Test""
+)
+
+powershell -ExecutionPolicy Bypass -Command ""& { Import-Module .\build\psake.psm1; Invoke-Psake .\build\build.ps1 -Task %tasks% -properties @{prepareForBuild='false';backup_files='false'} }""
 
-powershell -ExecutionPolicy Bypass -Command ""& { Import-Module .\build\psake.psm1; Invoke-Psake .\build\build.ps1 -properties @{prepareForBuild='false';backup_files='false'} }""
+endlocal
 "
 	$dir = [System.IO.Path]::GetDirectoryName($file)
 	Ensure-Directory-Exists $dir