Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit f5f9a34

Browse files
authored
Build xunit wrappers the same way on windows and unix (#18695)
* Initial change to allow build wrappers and runtest.py * Build xunit wrappers on unix The generated wrapper needs to target netcoreapp on unix. I had to exclude assets from the xunit package and introduce a dependency on the private corefx bits, to resolve a dependency conflict in which the generated wrapper was depending on an older System.Runtime.dll than the helper library. I also disabled binclash logging, because the wrapper build binplaces the helper library to the same location multiple times. I couldn't find a simple way to disable binclash logging for the wrapper build only, since that requires passing an empty switch to run.exe, and bash word splitting makes this nontrivial from build-test. * Correctly generate TestEnv xplat Note that this will still require changes to the test wrapper to actually source the TestEnv on unix * Build xunit wrappers using SDK * Target netcoreapp2.0 in xunit wrappers This way, the wrappers can build even if the 2.1 SDK isn't installed on the machine. * Restore to packages directory for xunit wrappers * Move common properties out to dir.common.props When building wrappers using the SDK, we need some basic properties (like the build os/arch/config, and the output directories) to be set. I factored out properties used by both the old test build and the new SDK-project test build. At first I tried using Directory.Build.props (which is automatically imported by the SDK), but our test build already imports SDK targets in various places, so this was resulting in duplicate imports. Instead, I used dir.common.props, and made the imports explicit. * Remove desktop-specific test wrapper csproj * Pass build os/arch/type and logsdir to msbuild from runtest.py * Remove xunit wrapper helper library from traversal build * Fix parameter passing in build-test.sh Use bash arrays to pass parameters for the build command. This makes it possible to pass arguments with spaces to build_Tests_internal. We use this to disable binclashlogging selectively (for the xunit wrapper build only). * Clean up factored .props files * Undo runtest.sh changes * Use latest xunit console runner everywhere * Remove extra StaticDependency on xunit.runner.console * Eliminate tests/src/dir.common.props, and rename dir.sdkbuild.props tests/src/dir.common.props was only used for the desktop-specific xunit wrapper helper library. There's no need for it any more, so its properties have been moved into tests/src/dir.props. dir.sdkbuild.props has been renamed to dir.common.props, since it contains properties used by SDK projects and buildtools projects. This change also re-enables the test build. * Reintroduce dir.sdkbuild.props as a place for SDK-only props With this, some properties shared by SDK projects can go in a global location. The TargetFramework is shared by all SDK projects in the test tree. This change also uses a property for the xunit package directory that contains the xunit.console.dll we copy to core_root. * Add xml namespace to dir.common.props This fixes a failure in the windows build. * Satisfy xunit analyzer * Satisfy xunit analyzer again * Use SDK msbuild to build wrappers On windows, the use of run.exe, config.json, and msbuild.cmd uses msbuild.exe on the path. This change will build wrappers using the local SDK via "dotnet msbuild", bypassing run.exe. Run.exe will go away entirely with the move from buildtools to arcade, so other build invocatios should follow suit. * Remove Microsoft.CSharp.Core.targets workaround UseBuildTools used to be true all the time. Now that we are building wrappers on core, UseBuildTools becomes false. However, the rest of the runtest.proj expects to build using buildtools, so we keep UseBuildTools true until we switch to arcade. The CSharpCoreTargetsPath was imported when running on core only. This used to happen only on unix, but now it also happens when building runtest.proj for the xunit wrappers on windows. On unix, this targets file was a symlink to itself to work around some buildtools logic that expected the file to exist. This workaround no longer appears necessary, and on windows, this was never used in the first place, so this change removes it. * Remove UseRoslynCompilers prop and unify roslyn import UseRoslynCompilers was introduced in buildtools by dotnet/buildtools#947, with different behaviors on windows/unix. It was removed by dotnet/buildtools#1974, so we can unify our roslyn imports now. * Don't copy xunit dlls to corefx test host The corefx tests run on specific versions of xunit dlls, defined in CoreFX.depproj. We want to use these versions in the test host, not those in CORE_ROOT, so exclude these from being copied to the test host directory. This fixes the failing corefx tests. * Don't pass run.exe arguments through build-test.cmd in test pipeline These arguments get passed along to the xunit wrapper build as unprocessed build args. They need to work for "dotnet msbuild" (used for the wrapper build) as well as for run.exe. * Fix parameter passing of priority arg in build-test.cmd UnprocessedBuildArgs should contain arguments in the format expected by msbuild, not by run.exe. * Fix parameter passing of unprocessed args in build-test.cmd The "--" syntax is used by run.exe to pass everything following to msbuild directly. It should not be a part of unprocessed args. * Pass TargetsWindowsArg to wrapper build in build-test.cmd Helix builds tests on windows and runs them on unix using the xunit wrappers. When cross-building the wrappers like this, TargetsWindows is set to false by the test build pipeline. This variable ensures that the wrapper uses correct directory separators when invoking the test .sh file. * Pass BuildTestsAgainstPackages arg to exclude unix tests Helix builds xunit wrappers on windows, and runs them on unix. The BuildTestsAgainstPackages should currently be set to true in the windows wrapper build to properly filter the .cmd files based on exclusions in issues.targets.
1 parent f26b8ee commit f5f9a34

31 files changed

+721
-407
lines changed

build-test.cmd

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ set processedArgs=
4646
set __unprocessedBuildArgs=
4747
set __RunArgs=
4848
set __BuildAgainstPackagesArg=
49+
set __BuildAgainstPackagesMsbuildArg=
4950
set __SkipRestorePackages=
5051
set __SkipManaged=
5152
set __SkipNative=
@@ -59,6 +60,8 @@ set __DoCrossgen=
5960
@REM appears to CMD parsing as "-priority 1". Handle -priority specially to avoid problems,
6061
@REM and allow the "-priority=1" syntax.
6162
set __Priority=0
63+
set __PriorityArg=
64+
set __PassThroughArg=
6265

6366
:Arg_Loop
6467
if "%1" == "" goto ArgsDone
@@ -80,14 +83,15 @@ if /i "%1" == "skipmanaged" (set __SkipManaged=1&set processedArgs=!pr
8083
if /i "%1" == "skipnative" (set __SkipNative=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
8184
if /i "%1" == "buildtesthostonly" (set __SkipNative=1&set __SkipManaged=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
8285
if /i "%1" == "toolset_dir" (set __ToolsetDir=%2&set __PassThroughArgs=%__PassThroughArgs% %2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop)
83-
if /i "%1" == "buildagainstpackages" (set __ZipTests=1&set __BuildAgainstPackagesArg=-BuildTestsAgainstPackages&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
86+
if /i "%1" == "buildagainstpackages" (set __ZipTests=1&set __BuildAgainstPackagesArg=-BuildTestsAgainstPackages&set __BuildAgainstPackagesMsbuildArg=/p:BuildTestsAgainstPackages=true&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
8487
if /i "%1" == "skiprestorepackages" (set __SkipRestorePackages=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
8588
if /i "%1" == "ziptests" (set __ZipTests=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
8689
if /i "%1" == "crossgen" (set __DoCrossgen=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
8790
if /i "%1" == "runtimeid" (set __RuntimeId=%2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop)
8891
if /i "%1" == "targetsNonWindows" (set __TargetsWindows=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
8992
if /i "%1" == "Exclude" (set __Exclude=%2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop)
9093
if /i "%1" == "-priority" (set __Priority=%2&shift&set processedArgs=!processedArgs! %1=%2&shift&goto Arg_Loop)
94+
if /i "%1" == "--" (set __PassThroughArg=%1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
9195

9296
if [!processedArgs!]==[] (
9397
set __UnprocessedBuildArgs=%__args%
@@ -101,7 +105,7 @@ if [!processedArgs!]==[] (
101105
:ArgsDone
102106

103107
@REM Special handling for -priority=N argument.
104-
if %__Priority% GTR 0 (set "__UnprocessedBuildArgs=!__UnprocessedBuildArgs! -priority=%__Priority%")
108+
if %__Priority% GTR 0 (set "__PriorityArg=-priority=%__Priority%")
105109

106110
if defined __BuildAgainstPackagesArg (
107111
if not defined __RuntimeID (
@@ -113,6 +117,8 @@ if defined __BuildAgainstPackagesArg (
113117
@if defined _echo @echo on
114118

115119
set __RunArgs=-BuildOS=%__BuildOS% -BuildType=%__BuildType% -BuildArch=%__BuildArch%
120+
REM As we move from buildtools to arcade, __RunArgs should be replaced with __msbuildArgs
121+
set __msbuildArgs=/p:__BuildOS=%__BuildOS% /p:__BuildType=%__BuildType% /p:__BuildArch=%__BuildArch%
116122

117123
if defined __ToolsetDir (
118124
rem arm64 builds currently use private toolset which has not been released yet
@@ -156,6 +162,12 @@ REM ===
156162
REM =========================================================================================
157163
call "%__ProjectDir%\init-tools.cmd"
158164
@if defined _echo @echo on
165+
set "__ToolsDir=%__ProjectDir%\Tools"
166+
set "__DotnetHost=%__ToolsDir%\dotnetcli\dotnet.exe"
167+
if not exist "%__DotnetHost%" (
168+
echo %__DotnetHost% not found after init-tools.
169+
exit /b 1
170+
)
159171

160172
REM =========================================================================================
161173
REM ===
@@ -220,7 +232,7 @@ set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%"
220232
set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%"
221233
set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"
222234

223-
call "%__ProjectDir%\run.cmd" build -Project="%__NativeTestIntermediatesDir%\install.vcxproj" -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__msbuildNativeArgs% %__RunArgs% %__unprocessedBuildArgs%
235+
call "%__ProjectDir%\run.cmd" build -Project="%__NativeTestIntermediatesDir%\install.vcxproj" -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__msbuildNativeArgs% %__RunArgs% %__PriorityArg% %__PassThroughArg% %__unprocessedBuildArgs%
224236
if errorlevel 1 (
225237
echo %__MsgPrefix%Error: build failed. Refer to the build log files for details:
226238
echo %__BuildLog%
@@ -250,7 +262,7 @@ set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%"
250262
set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%"
251263
set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"
252264

253-
call "%__ProjectDir%\run.cmd" build -Project=%__ProjectDir%\tests\build.proj -BatchRestorePackages -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %__unprocessedBuildArgs%
265+
call "%__ProjectDir%\run.cmd" build -Project=%__ProjectDir%\tests\build.proj -BatchRestorePackages -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %__PriorityArg% %__PassThroughArg% %__unprocessedBuildArgs%
254266

255267
if not defined __BuildAgainstPackagesArg goto SkipRestoreProduct
256268
set __BuildLogRootName=Tests_GenerateRuntimeLayout
@@ -261,7 +273,7 @@ set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%"
261273
set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%"
262274
set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"
263275

264-
call "%__ProjectDir%\run.cmd" build -Project=%__ProjectDir%\tests\runtest.proj -BinPlaceRef -BinPlaceProduct -CopyCrossgenToProduct -RuntimeId="%__RuntimeId%" -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %__unprocessedBuildArgs%
276+
call "%__ProjectDir%\run.cmd" build -Project=%__ProjectDir%\tests\runtest.proj -BinPlaceRef -BinPlaceProduct -CopyCrossgenToProduct -RuntimeId="%__RuntimeId%" -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %__PriorityArg% %__PassThroughArg% %__unprocessedBuildArgs%
265277
if errorlevel 1 (
266278
echo BinPlace of mscorlib.dll failed
267279
exit /b 1
@@ -309,7 +321,7 @@ for /l %%G in (1, 1, %__BuildLoopCount%) do (
309321
set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%";Append=!__AppendToLog!
310322

311323
set TestBuildSlice=%%G
312-
call "%__ProjectDir%\run.cmd" build -Project=%__ProjectDir%\tests\build.proj -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %__unprocessedBuildArgs%
324+
call "%__ProjectDir%\run.cmd" build -Project=%__ProjectDir%\tests\build.proj -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %__PriorityArg% %__PassThroughArg% %__unprocessedBuildArgs%
313325

314326
if errorlevel 1 (
315327
echo %__MsgPrefix%Error: build failed. Refer to the build log files for details:
@@ -365,10 +377,13 @@ if defined __RuntimeId (
365377
)
366378

367379
set TargetsWindowsArg=
380+
set TargetsWindowsMsbuildArg=
368381
if "%__TargetsWindows%"=="1" (
369382
set TargetsWindowsArg=-TargetsWindows=true
383+
set TargetsWindowsMsbuildArg=/p:TargetsWindows=true
370384
) else if "%__TargetsWindows%"=="0" (
371385
set TargetsWindowsArg=-TargetsWindows=false
386+
set TargetsWindowsMsbuildArg=/p:TargetsWindows=false
372387
)
373388

374389
echo %__MsgPrefix%Creating test overlay...
@@ -381,7 +396,7 @@ set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%"
381396
set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%"
382397
set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"
383398

384-
call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\runtest.proj -testOverlay -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %RuntimeIdArg% %__unprocessedBuildArgs%
399+
call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\runtest.proj -testOverlay -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %RuntimeIdArg% %__PriorityArg% %__PassThroughArg% %__unprocessedBuildArgs%
385400
if errorlevel 1 (
386401
echo %__MsgPrefix%Error: build failed. Refer to the build log files for details:
387402
echo %__BuildLog%
@@ -403,7 +418,7 @@ set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%"
403418
set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%"
404419
set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"
405420

406-
call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\runtest.proj -testHost -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %RuntimeIdArg% %__unprocessedBuildArgs%
421+
call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\runtest.proj -testHost -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %RuntimeIdArg% %__PriorityArg% %__PassThroughArg% %__unprocessedBuildArgs%
407422
if errorlevel 1 (
408423
echo %__MsgPrefix%Error: build failed. Refer to the build log files for details:
409424
echo %__BuildLog%
@@ -424,7 +439,8 @@ set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%"
424439
set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%"
425440
set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"
426441

427-
call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\runtest.proj -BuildWrappers -MsBuildEventLogging=" " -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %TargetsWindowsArg% %__unprocessedBuildArgs%
442+
REM Build wrappers using the local SDK's msbuild. As we move to arcade, the other builds should be moved away from run.exe as well.
443+
call %__DotnetHost% msbuild %__ProjectDir%\tests\runtest.proj /p:BuildWrappers=true !__msbuildLog! !__msbuildWrn! !__msbuildErr! %__msbuildArgs% %TargetsWindowsMsbuildArg% %__BuildAgainstPackagesMsbuildArg% %__unprocessedBuildArgs%
428444
if errorlevel 1 (
429445
echo Xunit Wrapper build failed
430446
exit /b 1
@@ -459,7 +475,7 @@ REM === Prep test binaries for Helix publishing
459475
REM ===
460476
REM =========================================================================================
461477

462-
call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\helixprep.proj -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %RuntimeIdArg% %TargetsWindowsArg% %__CrossgenArg% %__unprocessedBuildArgs%
478+
call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\helixprep.proj -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %RuntimeIdArg% %TargetsWindowsArg% %__CrossgenArg% %__PriorityArg% %__PassThroughArg% %__unprocessedBuildArgs%
463479
if errorlevel 1 (
464480
echo %__MsgPrefix%Error: build failed. Refer to the build log files for details:
465481
echo %__BuildLog%

build-test.sh

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ generate_layout()
152152
# ===
153153
# =========================================================================================
154154

155-
build_Tests_internal "Restore_Packages" "${__ProjectDir}/tests/build.proj" " -BatchRestorePackages" "Restore product binaries (build tests)"
155+
build_Tests_internal "Restore_Packages" "${__ProjectDir}/tests/build.proj" "Restore product binaries (build tests)" "-BatchRestorePackages"
156156

157157
if [ -n "$__UpdateInvalidPackagesArg" ]; then
158158
__up=-updateinvalidpackageversion
@@ -172,22 +172,14 @@ generate_layout()
172172

173173
mkdir -p $CORE_ROOT
174174

175-
build_Tests_internal "Tests_Overlay_Managed" "${__ProjectDir}/tests/runtest.proj" "-testOverlay" "Creating test overlay"
175+
build_Tests_internal "Tests_Overlay_Managed" "${__ProjectDir}/tests/runtest.proj" "Creating test overlay" "-testOverlay"
176176

177177
chmod +x $__BinDir/corerun
178178
chmod +x $__BinDir/crossgen
179179

180180
# Make sure to copy over the pulled down packages
181181
cp -r $__BinDir/* $CORE_ROOT/ > /dev/null
182182

183-
# Work hardcoded path around
184-
if [ ! -f "${__BuildToolsDir}/Microsoft.CSharp.Core.Targets" ]; then
185-
ln -s "${__BuildToolsDir}/Microsoft.CSharp.Core.targets" "${__BuildToolsDir}/Microsoft.CSharp.Core.Targets"
186-
fi
187-
if [ ! -f "${__BuildToolsDir}/Microsoft.CSharp.targets" ]; then
188-
ln -s "${__BuildToolsDir}/Microsoft.CSharp.Targets" "${__BuildToolsDir}/Microsoft.CSharp.targets"
189-
fi
190-
191183
}
192184

193185
generate_testhost()
@@ -201,7 +193,7 @@ generate_testhost()
201193
echo "${__MsgPrefix}Creating test overlay..."
202194
mkdir -p $TEST_HOST
203195

204-
build_Tests_internal "Tests_Generate_TestHost" "${__ProjectDir}/tests/runtest.proj" "-testHost" "Creating test host"
196+
build_Tests_internal "Tests_Generate_TestHost" "${__ProjectDir}/tests/runtest.proj" "Creating test host" "-testHost"
205197
}
206198

207199

@@ -246,15 +238,15 @@ build_Tests()
246238
# ===
247239
# =========================================================================================
248240

249-
build_Tests_internal "Restore_Product" "${__ProjectDir}/tests/build.proj" " -BatchRestorePackages" "Restore product binaries (build tests)"
241+
build_Tests_internal "Restore_Product" "${__ProjectDir}/tests/build.proj" "Restore product binaries (build tests)" "-BatchRestorePackages"
250242

251243
if [ -n "$__BuildAgainstPackagesArg" ]; then
252-
build_Tests_internal "Tests_GenerateRuntimeLayout" "${__ProjectDir}/tests/runtest.proj" "-BinPlaceRef -BinPlaceProduct -CopyCrossgenToProduct" "Restore product binaries (run tests)"
244+
build_Tests_internal "Tests_GenerateRuntimeLayout" "${__ProjectDir}/tests/runtest.proj" "Restore product binaries (run tests)" "-BinPlaceRef" "-BinPlaceProduct" "-CopyCrossgenToProduct"
253245
fi
254246

255247
echo "Starting the Managed Tests Build..."
256248

257-
build_Tests_internal "Tests_Managed" "$__ProjectDir/tests/build.proj" "$__up" "Managed tests build (build tests)"
249+
build_Tests_internal "Tests_Managed" "$__ProjectDir/tests/build.proj" "Managed tests build (build tests)" "$__up"
258250

259251
if [ $? -ne 0 ]; then
260252
echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)"
@@ -270,7 +262,7 @@ build_Tests()
270262

271263
if [ ! -f $__XUnitWrapperBuiltMarker ]; then
272264

273-
build_Tests_internal "Tests_XunitWrapper" "$__ProjectDir/tests/runtest.proj" "-BuildWrappers -MsBuildEventLogging=\" \" " "Test Xunit Wrapper"
265+
build_Tests_internal "Tests_XunitWrapper" "$__ProjectDir/tests/runtest.proj" "Test Xunit Wrapper" "-BuildWrappers" "-MsBuildEventLogging= " "-TargetsWindows=false"
274266

275267
if [ $? -ne 0 ]; then
276268
echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)"
@@ -295,23 +287,33 @@ build_Tests()
295287

296288
if [ $__ZipTests -ne 0 ]; then
297289
echo "${__MsgPrefix}ZIP tests packages..."
298-
build_Tests_internal "Helix_Prep" "$__ProjectDir/tests/helixprep.proj" " " "Prep test binaries for Helix publishing"
290+
build_Tests_internal "Helix_Prep" "$__ProjectDir/tests/helixprep.proj" "Prep test binaries for Helix publishing" " "
299291
fi
300292
}
301293

302294
build_Tests_internal()
303295
{
304296
subDirectoryName=$1
305-
projectName=$2
306-
extraBuildParameters=$3
307-
stepName="$4"
297+
shift
298+
projectName=$1
299+
shift
300+
stepName="$1"
301+
shift
302+
extraBuildParameters=("$@")
308303

309304
# Set up directories and file names
310305
__BuildLogRootName=$subDirectoryName
311306
__BuildLog="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.log"
312307
__BuildWrn="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.wrn"
313308
__BuildErr="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.err"
314309

310+
# Use binclashlogger by default if no other logger is specified
311+
if [[ "${extraBuildParameters[*]}" == *"-MsBuildEventLogging"* ]]; then
312+
msbuildEventLogging=""
313+
else
314+
msbuildEventLogging="-MsBuildEventLogging=\"/l:BinClashLogger,Tools/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log\""
315+
fi
316+
315317
if [[ "$subDirectoryName" == "Tests_Managed" ]]; then
316318
# Execute msbuild managed test build in stages - workaround for excessive data retention in MSBuild ConfigCache
317319
# See https://github.com/Microsoft/msbuild/issues/2993
@@ -337,12 +339,16 @@ build_Tests_internal()
337339
export TestBuildSlice=$slice
338340

339341
# Generate build command
340-
buildCommand="$__ProjectRoot/run.sh build -Project=$projectName -MsBuildLog=${__msbuildLog} -MsBuildWrn=${__msbuildWrn} -MsBuildErr=${__msbuildErr} -MsBuildEventLogging=\"/l:BinClashLogger,Tools/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log\" $extraBuildParameters $__RunArgs $__UnprocessedBuildArgs"
342+
buildArgs=("-Project=$projectName" "-MsBuildLog=${__msbuildLog}" "-MsBuildWrn=${__msbuildWrn}" "-MsBuildErr=${__msbuildErr}")
343+
buildArgs+=("$msbuildEventLogging")
344+
buildArgs+=("${extraBuildParameters[@]}")
345+
buildArgs+=("${__RunArgs[@]}")
346+
buildArgs+=("${__UnprocessedBuildArgs[@]}")
341347

342348
echo "Building step '$stepName' slice=$slice via $buildCommand"
343349

344350
# Invoke MSBuild
345-
eval $buildCommand
351+
"$__ProjectRoot/run.sh" build "${buildArgs[@]}"
346352

347353
# Make sure everything is OK
348354
if [ $? -ne 0 ]; then
@@ -362,15 +368,16 @@ build_Tests_internal()
362368
__msbuildErr="\"/flp2:ErrorsOnly;LogFile=${__BuildErr}\""
363369

364370
# Generate build command
365-
buildCommand="$__ProjectRoot/run.sh build -Project=$projectName -MsBuildLog=${__msbuildLog} -MsBuildWrn=${__msbuildWrn} -MsBuildErr=${__msbuildErr} -MsBuildEventLogging=\"/l:BinClashLogger,Tools/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log\" $extraBuildParameters $__RunArgs $__UnprocessedBuildArgs"
371+
buildArgs=("-Project=$projectName" "-MsBuildLog=${__msbuildLog}" "-MsBuildWrn=${__msbuildWrn}" "-MsBuildErr=${__msbuildErr}")
372+
buildArgs+=("$msbuildEventLogging")
373+
buildArgs+=("${extraBuildParameters[@]}")
374+
buildArgs+=("${__RunArgs[@]}")
375+
buildArgs+=("${__UnprocessedBuildArgs[@]}")
366376

367377
echo "Building step '$stepName' via $buildCommand"
368378

369379
# Invoke MSBuild
370-
eval $buildCommand
371-
372-
# Invoke MSBuild
373-
# $__ProjectRoot/run.sh build -Project=$projectName -MsBuildLog="$__msbuildLog" -MsBuildWrn="$__msbuildWrn" -MsBuildErr="$__msbuildErr" $extraBuildParameters $__RunArgs $__UnprocessedBuildArgs
380+
"$__ProjectRoot/run.sh" build "${buildArgs[@]}"
374381

375382
# Make sure everything is OK
376383
if [ $? -ne 0 ]; then
@@ -524,7 +531,7 @@ __ZipTests=0
524531
__NativeTestIntermediatesDir=
525532
__RunTests=0
526533
__RebuildTests=0
527-
__BuildTestWrappers=0
534+
__BuildTestWrappers=1
528535
__GenerateLayoutOnly=
529536
__GenerateTestHostOnly=
530537
__priority1=
@@ -686,23 +693,23 @@ while :; do
686693
;;
687694
priority1)
688695
__priority1=1
689-
__UnprocessedBuildArgs="$__UnprocessedBuildArgs -priority=1"
696+
__UnprocessedBuildArgs+=("-priority=1")
690697
;;
691698
*)
692-
__UnprocessedBuildArgs="$__UnprocessedBuildArgs $1"
699+
__UnprocessedBuildArgs+=("$1")
693700
;;
694701
esac
695702

696703
shift
697704
done
698705

699706

700-
__RunArgs="-BuildArch=$__BuildArch -BuildType=$__BuildType -BuildOS=$__BuildOS"
707+
__RunArgs=("-BuildArch=$__BuildArch" "-BuildType=$__BuildType" "-BuildOS=$__BuildOS")
701708

702709
# Configure environment if we are doing a verbose build
703710
if [ $__VerboseBuild == 1 ]; then
704711
export VERBOSE=1
705-
__RunArgs="$__RunArgs -verbose"
712+
__RunArgs+=("-verbose")
706713
fi
707714

708715
# Set default clang version
@@ -747,7 +754,7 @@ __CrossgenExe="$__CrossComponentBinDir/crossgen"
747754

748755
isMSBuildOnNETCoreSupported
749756

750-
# CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to set.
757+
# CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to it.
751758
# This is needed by CLI to function.
752759
if [ -z "$HOME" ]; then
753760
if [ ! -d "$__ProjectDir/temp_home" ]; then

0 commit comments

Comments
 (0)