forked from Azure/azure-iot-remote-monitoring
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cmd
121 lines (98 loc) · 3.95 KB
/
build.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
@Set Command=
@Set EnvironmentName=
@Set Configuration=
@Set AzureEnvironmentName=
@IF /I '%1' NEQ '' (
Set Command=%1)
@IF /I '%2' NEQ '' (
Set Configuration=%2)
@IF /I '%3' NEQ '' (
Set EnvironmentName=%3)
@IF /I '%4' NEQ '' (
Set AzureEnvironmentName=%4)
@REM ----------------------------------------------
@REM Validate arguments
@REM ----------------------------------------------
@IF '%Command%' == '' (
@ECHO Command was not provided
@GOTO :Error)
@IF /I '%Command%' == 'Cloud' (
@IF '%EnvironmentName%' == '' (
@ECHO EnvironmentName was not provided
@GOTO :Error)
) ELSE (
Set AzureEnvironmentName=%EnvironmentName%
Set EnvironmentName=%Command%
)
@IF /I '%Configuration%' == '' (
Set Configuration=Debug)
@REM ----------------------------------------------
@REM Parse arguments
@REM ----------------------------------------------
@SET DeploymentScripts=%~dp0\Common\Deployment
@SET BuildPath=%~dp0Build_Output\%Configuration%
@SET PowerShellCmd="%windir%\system32\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Unrestricted -Command
@SET PublishCmd=%PowerShellCmd% "& ""%DeploymentScripts%\PrepareIoTSample.ps1""" -environmentName %EnvironmentName% -configuration %Configuration% %SuiteArgs%
@SET PackageCmd=%PowerShellCmd% "& ""%DeploymentScripts%\PackageIoTSample.ps1""" -configuration %Configuration%
@IF /I '%AzureEnvironmentName%' NEQ '' (
@Set PublishCmd=%PublishCmd% -azureEnvironmentName %AzureEnvironmentName%
)
@%PowerShellCmd% "if (!('%EnvironmentName%' -match '^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{3,49}[a-zA-Z0-9]{1,1}$')) { throw 'Invalid EnvironmentName' }"
@IF /I '%ERRORLEVEL%' NEQ '0' (
@echo Error EnvironmentName - '%EnvironmentName%' must start with a letter, end with a letter or number, between 3-50 characters in length, and only contain letters, numbers and dashes
@echo
@goto :Error)
@IF /I '%Command%' == 'Build' (
@GOTO :Build)
@IF /I '%Command%' == 'Local' (
@GOTO :Config)
@IF /I '%Command%' == 'Cloud' (
@GOTO :Build)
@IF /I '%Command%' == 'Package' (
@GOTO :Build)
@ECHO Invalid command '%Command%'
@GOTO :Error
:Build
msbuild RemoteMonitoring.sln /v:m /p:Configuration=%Configuration%
@IF /I '%ERRORLEVEL%' NEQ '0' (
@echo Error msbuild IoTRefImplementation.sln /v:m /t:publish /p:Configuration=%Configuration%
@goto :Error)
@IF /I '%Command%' == 'Build' (
@GOTO :End)
:Package
@REM For Zip based deployments for private repos
msbuild DeviceAdministration\Web\Web.csproj /v:m /T:Package
@IF /I '%ERRORLEVEL%' NEQ '0' (
@echo Error msbuild DeviceAdministration\Web\Web.csproj /v:m /T:Package
@goto :Error)
msbuild WebJobHost\WebJobHost.csproj /v:m /T:Package
@IF /I '%ERRORLEVEL%' NEQ '0' (
@echo Error msbuild WebJobHost\WebJobHost.csproj /v:m /T:Package
@goto :Error)
@IF /I '%Command%' == 'Package' (
%PackageCmd%
@GOTO :END)
:Config
%PublishCmd%
@IF /I '%ERRORLEVEL%' NEQ '0' (
@echo Error %PublishCmd%
@goto :Error
)
@GOTO :End
:Error
@REM ----------------------------------------------
@REM Help on errors
@REM ----------------------------------------------
@ECHO Arguments: build.cmd "Command" "Configuration" "EnvironmentName" "AzureEnvironment"
@ECHO Command: build (just builds); package (package build into zip files); local (config local); cloud (config cloud, build, and deploy)
@ECHO Configuration: build configuration either Debug or Release; default is Debug
@ECHO EnvironmentName: Name of cloud environment to deploy - default is local
@ECHO AzureEnvironment: Name of the Azure Environment to deploy to - default is AzureCloud
@ECHO
@ECHO eg.
@ECHO build - build.cmd build
@ECHO package release build - build.cmd package release
@ECHO local deployment: build.cmd local
@ECHO cloud deployment: build.cmd cloud release mydeployment
@ECHO national cloud deployment: same as above but include CloudName at end (eg. build.cmd local debug AzureGermanCloud or build.cmd cloud release mydeployment AzureGermanCloud)
:End