Repository navigation
Expand file tree
/
Copy pathbuildenv.cmd
More file actions
226 lines (179 loc) · 6.84 KB
/
Copy pathbuildenv.cmd
File metadata and controls
226 lines (179 loc) · 6.84 KB
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
@echo off
REM Configures the environment variables required to build NeonSDK projects.
REM
REM buildenv [ <source folder> ]
REM
REM Note that <source folder> defaults to the folder holding this
REM batch file.
REM
REM This must be [RUN AS ADMINISTRATOR].
echo ==========================================
echo * NeonSDK Build Environment Configurator *
echo ==========================================
REM Default NF_ROOT to the folder holding this batch file after stripping
REM off the trailing backslash.
set NF_ROOT=%~dp0
set NF_ROOT=%NF_ROOT:~0,-2%
if not [%1]==[] set NF_ROOT=%1
if exist %NF_ROOT%\neonSDK.sln goto goodPath
echo The [%NF_ROOT%\neonSDK.sln] file does not exist. Please pass the path
echo to the NeonSDK solution folder.
goto done
:goodPath
REM If NF_MAINTAINER is already set to "1", we're going to assume that all
REM of the other environment variables are already set.
if "%NF_MAINTAINER%"=="1" (
echo *** Environment already configured ***
goto done
)
REM Set NF_REPOS to the parent directory holding the NEONFORGE repositories.
pushd "%NF_ROOT%\.."
set NF_REPOS=%cd%
popd
REM We need to capture the developer's GitHub username, email address and
REM Personal Access Token (PAT):
echo.
set /p GITHUB_USERNAME="Enter your GitHub username: "
echo.
set /p GITHUB_EMAIL="Enter the email to be referenced by GitHub commits: "
echo.
set /p GITHUB_PAT="Enter your GitHub Personal Access Token (PAT): "
REM Ask the developer if they're a maintainer and set NF_MAINTAINER if they say yes.
:maintainerPrompt
echo.
set /P "IS_MAINTAINER=Are you a NEONFORGE maintainer? (y/n): "
if "%IS_MAINTAINER%"=="y" (
set NF_MAINTAINER=1
) else if "%IS_MAINTAINER%"=="Y" (
set NF_MAINTAINER=1
) else if "%IS_MAINTAINER%"=="n" (
set NF_MAINTAINER=
) else if "%IS_MAINTAINER%"=="N" (
set NF_MAINTAINER=
) else (
echo.
echo "*** ERROR: You must answer with: Y or N."
echo.
goto maintainerPrompt
)
REM Ask maintainers for their NEONFORGE Office 365 username.
if "%NF_MAINTAINER%"=="1" (
echo.
set /p NC_USER="Enter your primary NEONFORGE Office 365 email: "
setx NC_USER "%NC_USER%" /M > nul
)
REM Ask the developer if they're using preview Visual Studio.
:previewVSPrompt
echo.
set /P "IS_VS_PREVIEW=Are you a using a PREVIEW version of Visual Studio? (y/n): "
if "%IS_VS_PREVIEW%"=="y" (
set IS_VS_PREVIEW=1
) else if "%IS_VS_PREVIEW%"=="Y" (
set IS_VS_PREVIEW=1
) else if "%IS_VS_PREVIEW%"=="n" (
set IS_VS_PREVIEW=0
) else if "%IS_VS_PREVIEW%"=="N" (
set IS_VS_PREVIEW=0
) else (
echo.
echo "*** ERROR: You must answer with: Y or N."
echo.
goto previewVSPrompt
)
if "%IS_VS_PREVIEW%"=="1" (
set VS_EDITION=Preview
) else (
set VS_EDITION=Community
)
REM Ask the developer if they have Telerik JustMock installed and
REM set the JUSTMOCK_ENABLED environment variable if they do.
:justMockPrompt
echo.
set /P "HAS_JUSTMOCK=Do you have Telerik JustMock installed? (y/n): "
if "%HAS_JUSTMOCK%"=="y" (
set HAS_JUSTMOCK=1
) else if "%HAS_JUSTMOCK%"=="Y" (
set HAS_JUSTMOCK=1
) else if "%HAS_JUSTMOCK%"=="n" (
set HAS_JUSTMOCK=0
) else if "%HAS_JUSTMOCK%"=="N" (
set HAS_JUSTMOCK=0
) else (
echo.
echo "*** ERROR: You must answer with: Y or N."
echo.
goto justMockPrompt
)
if "%HAS_JUSTMOCK%"=="1" (
setx JUSTMOCK_ENABLED "true" /M > nul
)
REM Get on with configuration.
echo.
echo Configuring...
echo.
REM Configure the environment variables.
set NF_TOOLBIN=%NF_ROOT%\ToolBin
set NF_BUILD=%NF_ROOT%\Build
set NF_CACHE=%NF_ROOT%\Build-cache
set NF_SNIPPETS=%NF_ROOT%\Snippets
set NF_TEST=%NF_ROOT%\Test
set NF_TEMP=C:\Temp
set NF_SAMPLES_CADENCE=%NF_ROOT%\..\cadence-samples
set DOTNETPATH=%WINDIR%\Microsoft.NET\Framework64\v4.0.30319
set MSBUILDPATH=C:\Program Files\Microsoft Visual Studio\2022\%VS_EDITION%\Msbuild\Current\Bin\MSBuild.exe
set NEON_CLUSTER_TESTING=1
REM Persist the environment variables.
setx GITHUB_USERNAME "%GITHUB_USERNAME%" /M > nul
setx GITHUB_EMAIL "%GITHUB_EMAIL%" /M > nul
setx GITHUB_PAT "%GITHUB_PAT%" /M > nul
setx NF_MAINTAINER "%NF_MAINTAINER%" /M > nul
setx NF_REPOS "%NF_REPOS%" /M > nul
setx NF_ROOT "%NF_ROOT%" /M > nul
setx NF_TOOLBIN "%NF_TOOLBIN%" /M > nul
setx NF_BUILD "%NF_BUILD%" /M > nul
setx NF_CACHE "%NF_CACHE%" /M > nul
setx NF_SNIPPETS "%NF_SNIPPETS%" /M > nul
setx NF_TEST "%NF_TEST%" /M > nul
setx NF_TEMP "%NF_TEMP%" /M > nul
setx NF_SAMPLES_CADENCE "%NF_SAMPLES_CADENCE%" /M > nul
if "%NF_MAINTAINER%"=="1" (
setx NC_USER "%NC_USER%" /M > nul
)
setx DOTNETPATH "%DOTNETPATH%" /M > nul
setx MSBUILDPATH "%MSBUILDPATH%" /M > nul
setx DOTNET_CLI_TELEMETRY_OPTOUT 1 /M > nul
setx DEV_WORKSTATION 1 /M > nul
setx OPENSSL_CONF "%NF_ROOT%\External\OpenSSL\openssl.cnf" /M > nul
REM Make sure required folders exist.
if not exist "%NF_TEMP%" mkdir "%NF_TEMP%"
if not exist "%NF_TOOLBIN%" mkdir "%NF_TOOLBIN%"
if not exist "%NF_BUILD%" mkdir "%NF_BUILD%"
if not exist "%NF_BUILD%\neon" mkdir "%NF_BUILD%\neon"
REM Configure the PATH.
REM
REM Note that some tools like PuTTY and 7-Zip may be installed as
REM x86 or x64 to different directories. We'll include commands that
REM attempt to add both locations to the path and [%NF_TOOLBIN%\pathtool] is
REM smart enough to only add directories that actually exist.
%NF_TOOLBIN%\pathtool -dedup -system -add "%NF_BUILD%"
%NF_TOOLBIN%\pathtool -dedup -system -add "%NF_BUILD%\neon"
%NF_TOOLBIN%\pathtool -dedup -system -add "%NF_TOOLBIN%"
%NF_TOOLBIN%\pathtool -dedup -system -add "%NF_ROOT%\External\OpenSSL"
%NF_TOOLBIN%\pathtool -dedup -system -add "%DOTNETPATH%"
%NF_TOOLBIN%\pathtool -dedup -system -add "C:\cygwin64\bin"
%NF_TOOLBIN%\pathtool -dedup -system -add "%ProgramFiles%\7-Zip"
%NF_TOOLBIN%\pathtool -dedup -system -add "%ProgramFiles(x86)%\7-Zip"
%NF_TOOLBIN%\pathtool -dedup -system -add "%ProgramFiles%\PuTTY"
%NF_TOOLBIN%\pathtool -dedup -system -add "%ProgramFiles(x86)%\PuTTY"
%NF_TOOLBIN%\pathtool -dedup -system -add "%ProgramFiles%\WinSCP"
%NF_TOOLBIN%\pathtool -dedup -system -add "%ProgramFiles(x86)%\WinSCP"
REM Login Docker to GitHub Container Registry (GHCR).
echo %GITHUB_PAT% | docker login ghcr.io -u %GITHUB_USERNAME% --password-stdin
echo %GITHUB_PAT% | gh auth login --with-token
REM Perform additional initialization via Powershell.
pwsh -File "%NF_ROOT%\buildenv.ps1"
:done
echo.
echo ============================================================================================
echo * Be sure to close and reopen Visual Studio and any command windows to pick up the changes *
echo ============================================================================================