Files
Umbraco-CMS/build/Build.bat

230 lines
6.4 KiB
Batchfile
Raw Normal View History

2016-10-05 14:28:05 +02:00
@ECHO OFF
2016-07-20 15:10:33 +02:00
2017-03-14 19:13:08 +01:00
:: UMBRACO CORE BUILD FILE
::
:: usage:
:: build [-release:release] [-comment:comment] [-build:number] [-integration]
:: [-nugetpkg] [-nugetfolder:folder] [-tests]
:: release: the release version eg -release:1.2.0
:: comment: the release comment eg -comment:alpha002
:: build: the build number (for continuous integration) eg -build:6689
:: nugetfolder: the folder where to restore packages eg -nugetpkg:"path\to\packages"
:: integration: don't pause on errors eg -integration
:: nugetpkg: create nuget package eg -nugetpkg
:: tests: build the tests eg -tests
::
:: the script tries to read from UmbracoVersion.txt
:: but release and comment can be overriden by args
:: and in any case, the script updates UmbracoVersion.txt
::
2016-07-20 15:10:33 +02:00
SET RELEASE=
SET COMMENT=
2017-03-14 19:13:08 +01:00
SET BUILD=
2016-07-20 15:10:33 +02:00
2017-03-14 19:13:08 +01:00
:: Try to get the version and comment from UmbracoVersion.txt lines 2 and 3
IF EXIST UmbracoVersion.txt (
FOR /F "skip=1 delims=" %%i IN (UmbracoVersion.txt) DO IF NOT DEFINED RELEASE SET RELEASE=%%i
FOR /F "skip=2 delims=" %%i IN (UmbracoVersion.txt) DO IF NOT DEFINED COMMENT SET COMMENT=%%i
)
:: process args
2016-07-20 15:10:33 +02:00
SET INTEGRATION=0
2016-11-05 15:33:27 +01:00
SET nuGetFolder=%CD%\..\src\packages
2017-03-14 19:13:08 +01:00
SET NUPKG=0
SET BUILD=
SET TESTS=
2016-07-20 15:10:33 +02:00
:processArgs
:: grab the first parameter as a whole eg "/action:start"
:: end if no more parameter
SET SWITCHPARSE=%1
IF [%SWITCHPARSE%] == [] goto endProcessArgs
:: get switch and value
SET SWITCH=
SET VALUE=
FOR /F "tokens=1,* delims=: " %%a IN ("%SWITCHPARSE%") DO SET SWITCH=%%a& SET VALUE=%%b
2016-07-20 15:10:33 +02:00
:: route arg
IF '%SWITCH%'=='/release' GOTO argRelease
2016-07-20 15:37:14 +02:00
IF '%SWITCH%'=='-release' GOTO argRelease
2016-07-20 15:10:33 +02:00
IF '%SWITCH%'=='/comment' GOTO argComment
2016-07-20 15:37:14 +02:00
IF '%SWITCH%'=='-comment' GOTO argComment
2017-03-14 19:13:08 +01:00
IF '%SWITCH%'=='/build' GOTO argBuild
IF '%SWITCH%'=='-build' GOTO argBuild
2016-07-20 15:10:33 +02:00
IF '%SWITCH%'=='/integration' GOTO argIntegration
2016-07-20 15:37:14 +02:00
IF '%SWITCH%'=='-integration' GOTO argIntegration
2016-07-20 15:10:33 +02:00
IF '%SWITCH%'=='/nugetfolder' GOTO argNugetFolder
2016-07-20 15:37:14 +02:00
IF '%SWITCH%'=='-nugetfolder' GOTO argNugetFolder
2017-03-14 19:13:08 +01:00
IF '%SWITCH%'=='/nugetpkg' GOTO argNugetPkg
IF '%SWITCH%'=='-nugetpkg' GOTO argNugetPkg
IF '%SWITCH%'=='/tests' GOTO argTests
IF '%SWITCH%'=='-tests' GOTO argTests
2016-07-20 15:10:33 +02:00
ECHO "Invalid switch %SWITCH%"
GOTO error
2016-07-20 15:10:33 +02:00
:: handle each arg
2016-07-08 13:07:27 +02:00
2016-07-20 15:10:33 +02:00
:argRelease
set RELEASE=%VALUE%
SHIFT
goto processArgs
:argComment
SET COMMENT=%VALUE%
SHIFT
GOTO processArgs
2017-03-14 19:13:08 +01:00
:argBuild
SET BUILD=%VALUE%
SHIFT
GOTO processArgs
2016-07-20 15:10:33 +02:00
:argIntegration
SET INTEGRATION=1
SHIFT
GOTO processArgs
:argNugetFolder
SET nuGetFolder=%VALUE%
SHIFT
GOTO processArgs
2017-03-14 19:13:08 +01:00
:argNugetPkg
SET NUPKG=1
SHIFT
GOTO processArgs
:argTests
SET TESTS=true
2016-07-20 15:10:33 +02:00
SHIFT
GOTO processArgs
2017-03-14 19:13:08 +01:00
:endProcessArgs
:: validate
IF [%RELEASE%] EQU [] (
ECHO Could not determine release
ECHO Release is determined by the 'release' arg, or the UmbracoVersion.txt file
GOTO error
)
2016-07-20 15:10:33 +02:00
2017-03-14 19:13:08 +01:00
ECHO # Usage: on line 2 put the release version, on line 3 put the version comment (example: beta)> UmbracoVersion.txt
ECHO %release%>> UmbracoVersion.txt
ECHO %comment%>> UmbracoVersion.txt
:: run
2016-07-20 15:10:33 +02:00
SET VERSION=%RELEASE%
2017-03-14 19:13:08 +01:00
IF [%COMMENT%] NEQ [] (SET VERSION=%VERSION%-%COMMENT%)
IF [%BUILD%] NEQ [] (SET VERSION=%VERSION%+%BUILD%)
2016-07-08 13:07:27 +02:00
2016-10-17 12:24:35 +02:00
ECHO ################################################################
2016-07-20 15:10:33 +02:00
ECHO Building Umbraco %VERSION%
2016-10-17 12:24:35 +02:00
ECHO ################################################################
2013-11-05 11:44:34 +01:00
2016-10-05 14:28:05 +02:00
SET MSBUILDPATH=C:\Program Files (x86)\MSBuild\14.0\Bin
SET MSBUILD="%MSBUILDPATH%\MsBuild.exe"
SET PATH="%MSBUILDPATH%";%PATH%
2016-07-08 19:10:34 +02:00
2016-07-20 15:10:33 +02:00
ReplaceIISExpressPortNumber.exe ..\src\Umbraco.Web.UI\Umbraco.Web.UI.csproj %RELEASE%
2013-11-05 11:44:34 +01:00
2016-07-08 13:07:27 +02:00
ECHO.
2017-03-14 19:13:08 +01:00
ECHO First make sure everything is clean as a whistle
ECHO.
ECHO Removing the belle build folder and bower_components folder
RD ..\src\Umbraco.Web.UI.Client\build /Q /S
RD ..\src\Umbraco.Web.UI.Client\bower_components /Q /S
2016-07-08 13:07:27 +02:00
ECHO.
2017-03-14 19:13:08 +01:00
ECHO Removing existing built files
RMDIR /Q /S _BuildOutput
2016-10-17 12:24:35 +02:00
DEL /F /Q UmbracoCms.*.zip 2>NUL
DEL /F /Q UmbracoExamine.*.zip 2>NUL
DEL /F /Q UmbracoCms.*.nupkg 2>NUL
DEL /F /Q webpihash.txt 2>NUL
2016-07-08 13:07:27 +02:00
ECHO.
ECHO Making sure Git is in the path so that the build can succeed
CALL InstallGit.cmd
2016-07-08 13:07:27 +02:00
2017-03-14 19:13:08 +01:00
:: Adding the default Git path so that if it's installed it can actually be found
:: This is necessary because SETLOCAL is on in InstallGit.cmd so that one might find Git,
:: but the path setting is lost due to SETLOCAL
2016-10-05 14:28:05 +02:00
SET PATH="C:\Program Files (x86)\Git\cmd";"C:\Program Files\Git\cmd";%PATH%
ECHO.
2016-07-08 13:07:27 +02:00
ECHO Making sure we have a web.config
2016-11-05 15:33:27 +01:00
IF NOT EXIST "%CD%\..\src\Umbraco.Web.UI\web.config" COPY "%CD%\..\src\Umbraco.Web.UI\web.Template.config" "%CD%\..\src\Umbraco.Web.UI\web.config"
2016-07-08 13:07:27 +02:00
2016-10-05 14:28:05 +02:00
ECHO.
ECHO Reporting NuGet version
2016-11-05 15:33:27 +01:00
"%CD%\..\src\.nuget\NuGet.exe" help | findstr "^NuGet Version:"
2016-10-05 14:28:05 +02:00
ECHO.
2016-07-08 13:07:27 +02:00
ECHO Restoring NuGet packages
2016-07-20 15:10:33 +02:00
ECHO Into %nuGetFolder%
2016-11-05 15:33:27 +01:00
"%CD%\..\src\.nuget\NuGet.exe" restore "%CD%\..\src\umbraco.sln" -Verbosity Quiet -NonInteractive -PackagesDirectory "%nuGetFolder%"
2016-10-05 14:28:05 +02:00
IF ERRORLEVEL 1 GOTO :error
2016-07-08 13:07:27 +02:00
2016-10-05 14:28:05 +02:00
ECHO.
2016-07-08 13:07:27 +02:00
ECHO.
ECHO Performing MSBuild and producing Umbraco binaries zip files
ECHO This takes a few minutes and logging is set to report warnings
ECHO and errors only so it might seems like nothing is happening for a while.
ECHO You can check the msbuild.log file for progress.
ECHO.
2017-03-14 19:13:08 +01:00
%MSBUILD% "Build.proj" ^
/p:BUILD_RELEASE=%RELEASE% ^
/p:BUILD_COMMENT=%COMMENT% ^
/p:BUILD_NUMBER=%BUILD% ^
/p:BUILD_TESTS=%TESTS% ^
/p:NugetPackagesDirectory="%nuGetFolder%" ^
/consoleloggerparameters:Summary;ErrorsOnly ^
/fileLogger
2016-07-20 15:10:33 +02:00
IF ERRORLEVEL 1 GOTO error
2013-11-05 11:44:34 +01:00
2016-07-08 13:07:27 +02:00
ECHO.
2017-03-14 19:13:08 +01:00
ECHO Setting node_modules folder to hidden to prevent VS13 from
ECHO crashing on it while loading the websites project
attrib +h ..\src\Umbraco.Web.UI.Client\node_modules
2017-03-14 19:13:08 +01:00
IF %NUPKG% EQU 0 GOTO success
2016-07-20 15:10:33 +02:00
2016-07-08 13:07:27 +02:00
ECHO.
ECHO Adding Web.config transform files to the NuGet package
REN .\_BuildOutput\WebApp\Views\Web.config Web.config.transform
2016-07-08 13:07:27 +02:00
ECHO.
ECHO Packing the NuGet release files
2016-07-20 15:10:33 +02:00
..\src\.nuget\NuGet.exe Pack NuSpecs\UmbracoCms.Core.nuspec -Version %VERSION% -Symbols -Verbosity quiet
2016-09-19 12:04:22 +02:00
..\src\.nuget\NuGet.exe Pack NuSpecs\UmbracoCms.Compat7.nuspec -Version %VERSION% -Symbols -Verbosity quiet
2016-07-20 15:10:33 +02:00
..\src\.nuget\NuGet.exe Pack NuSpecs\UmbracoCms.nuspec -Version %VERSION% -Verbosity quiet
IF ERRORLEVEL 1 GOTO error
2016-07-08 13:07:27 +02:00
:success
ECHO.
ECHO No errors were detected!
ECHO There may still be some in the output, which you would need to investigate.
ECHO Warnings are usually normal.
2016-07-08 19:10:34 +02:00
ECHO.
ECHO.
2013-11-05 11:44:34 +01:00
GOTO :EOF
2016-07-08 13:07:27 +02:00
:error
ECHO.
ECHO Errors were detected!
2016-07-08 19:10:34 +02:00
ECHO.
2016-07-08 13:07:27 +02:00
2017-03-14 19:13:08 +01:00
:: don't pause if continuous integration else the build server waits forever
:: before cancelling the build (and, there is noone to read the output anyways)
2016-07-20 15:10:33 +02:00
IF %INTEGRATION% NEQ 1 PAUSE