Skip to content

Commit

Permalink
Build xunit wrappers the same way on windows and unix (dotnet#18695)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
sbomer committed Jul 19, 2018
1 parent f26b8ee commit f5f9a34
Show file tree
Hide file tree
Showing 31 changed files with 721 additions and 407 deletions.
36 changes: 26 additions & 10 deletions build-test.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ set processedArgs=
set __unprocessedBuildArgs=
set __RunArgs=
set __BuildAgainstPackagesArg=
set __BuildAgainstPackagesMsbuildArg=
set __SkipRestorePackages=
set __SkipManaged=
set __SkipNative=
Expand All @@ -59,6 +60,8 @@ set __DoCrossgen=
@REM appears to CMD parsing as "-priority 1". Handle -priority specially to avoid problems,
@REM and allow the "-priority=1" syntax.
set __Priority=0
set __PriorityArg=
set __PassThroughArg=

:Arg_Loop
if "%1" == "" goto ArgsDone
Expand All @@ -80,14 +83,15 @@ if /i "%1" == "skipmanaged" (set __SkipManaged=1&set processedArgs=!pr
if /i "%1" == "skipnative" (set __SkipNative=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
if /i "%1" == "buildtesthostonly" (set __SkipNative=1&set __SkipManaged=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
if /i "%1" == "toolset_dir" (set __ToolsetDir=%2&set __PassThroughArgs=%__PassThroughArgs% %2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop)
if /i "%1" == "buildagainstpackages" (set __ZipTests=1&set __BuildAgainstPackagesArg=-BuildTestsAgainstPackages&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
if /i "%1" == "buildagainstpackages" (set __ZipTests=1&set __BuildAgainstPackagesArg=-BuildTestsAgainstPackages&set __BuildAgainstPackagesMsbuildArg=/p:BuildTestsAgainstPackages=true&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
if /i "%1" == "skiprestorepackages" (set __SkipRestorePackages=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
if /i "%1" == "ziptests" (set __ZipTests=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
if /i "%1" == "crossgen" (set __DoCrossgen=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
if /i "%1" == "runtimeid" (set __RuntimeId=%2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop)
if /i "%1" == "targetsNonWindows" (set __TargetsWindows=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
if /i "%1" == "Exclude" (set __Exclude=%2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop)
if /i "%1" == "-priority" (set __Priority=%2&shift&set processedArgs=!processedArgs! %1=%2&shift&goto Arg_Loop)
if /i "%1" == "--" (set __PassThroughArg=%1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)

if [!processedArgs!]==[] (
set __UnprocessedBuildArgs=%__args%
Expand All @@ -101,7 +105,7 @@ if [!processedArgs!]==[] (
:ArgsDone

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

if defined __BuildAgainstPackagesArg (
if not defined __RuntimeID (
Expand All @@ -113,6 +117,8 @@ if defined __BuildAgainstPackagesArg (
@if defined _echo @echo on

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

if defined __ToolsetDir (
rem arm64 builds currently use private toolset which has not been released yet
Expand Down Expand Up @@ -156,6 +162,12 @@ REM ===
REM =========================================================================================
call "%__ProjectDir%\init-tools.cmd"
@if defined _echo @echo on
set "__ToolsDir=%__ProjectDir%\Tools"
set "__DotnetHost=%__ToolsDir%\dotnetcli\dotnet.exe"
if not exist "%__DotnetHost%" (
echo %__DotnetHost% not found after init-tools.
exit /b 1
)

REM =========================================================================================
REM ===
Expand Down Expand Up @@ -220,7 +232,7 @@ set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%"
set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%"
set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"

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

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

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

call "%__ProjectDir%\run.cmd" build -Project=%__ProjectDir%\tests\runtest.proj -BinPlaceRef -BinPlaceProduct -CopyCrossgenToProduct -RuntimeId="%__RuntimeId%" -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %__unprocessedBuildArgs%
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%
if errorlevel 1 (
echo BinPlace of mscorlib.dll failed
exit /b 1
Expand Down Expand Up @@ -309,7 +321,7 @@ for /l %%G in (1, 1, %__BuildLoopCount%) do (
set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%";Append=!__AppendToLog!

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

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

set TargetsWindowsArg=
set TargetsWindowsMsbuildArg=
if "%__TargetsWindows%"=="1" (
set TargetsWindowsArg=-TargetsWindows=true
set TargetsWindowsMsbuildArg=/p:TargetsWindows=true
) else if "%__TargetsWindows%"=="0" (
set TargetsWindowsArg=-TargetsWindows=false
set TargetsWindowsMsbuildArg=/p:TargetsWindows=false
)

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

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

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

call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\runtest.proj -BuildWrappers -MsBuildEventLogging=" " -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %TargetsWindowsArg% %__unprocessedBuildArgs%
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.
call %__DotnetHost% msbuild %__ProjectDir%\tests\runtest.proj /p:BuildWrappers=true !__msbuildLog! !__msbuildWrn! !__msbuildErr! %__msbuildArgs% %TargetsWindowsMsbuildArg% %__BuildAgainstPackagesMsbuildArg% %__unprocessedBuildArgs%
if errorlevel 1 (
echo Xunit Wrapper build failed
exit /b 1
Expand Down Expand Up @@ -459,7 +475,7 @@ REM === Prep test binaries for Helix publishing
REM ===
REM =========================================================================================

call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\helixprep.proj -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %RuntimeIdArg% %TargetsWindowsArg% %__CrossgenArg% %__unprocessedBuildArgs%
call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\helixprep.proj -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %RuntimeIdArg% %TargetsWindowsArg% %__CrossgenArg% %__PriorityArg% %__PassThroughArg% %__unprocessedBuildArgs%
if errorlevel 1 (
echo %__MsgPrefix%Error: build failed. Refer to the build log files for details:
echo %__BuildLog%
Expand Down
71 changes: 39 additions & 32 deletions build-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ generate_layout()
# ===
# =========================================================================================

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

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

mkdir -p $CORE_ROOT

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

chmod +x $__BinDir/corerun
chmod +x $__BinDir/crossgen

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

# Work hardcoded path around
if [ ! -f "${__BuildToolsDir}/Microsoft.CSharp.Core.Targets" ]; then
ln -s "${__BuildToolsDir}/Microsoft.CSharp.Core.targets" "${__BuildToolsDir}/Microsoft.CSharp.Core.Targets"
fi
if [ ! -f "${__BuildToolsDir}/Microsoft.CSharp.targets" ]; then
ln -s "${__BuildToolsDir}/Microsoft.CSharp.Targets" "${__BuildToolsDir}/Microsoft.CSharp.targets"
fi

}

generate_testhost()
Expand All @@ -201,7 +193,7 @@ generate_testhost()
echo "${__MsgPrefix}Creating test overlay..."
mkdir -p $TEST_HOST

build_Tests_internal "Tests_Generate_TestHost" "${__ProjectDir}/tests/runtest.proj" "-testHost" "Creating test host"
build_Tests_internal "Tests_Generate_TestHost" "${__ProjectDir}/tests/runtest.proj" "Creating test host" "-testHost"
}


Expand Down Expand Up @@ -246,15 +238,15 @@ build_Tests()
# ===
# =========================================================================================

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

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

echo "Starting the Managed Tests Build..."

build_Tests_internal "Tests_Managed" "$__ProjectDir/tests/build.proj" "$__up" "Managed tests build (build tests)"
build_Tests_internal "Tests_Managed" "$__ProjectDir/tests/build.proj" "Managed tests build (build tests)" "$__up"

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

if [ ! -f $__XUnitWrapperBuiltMarker ]; then

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

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

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

build_Tests_internal()
{
subDirectoryName=$1
projectName=$2
extraBuildParameters=$3
stepName="$4"
shift
projectName=$1
shift
stepName="$1"
shift
extraBuildParameters=("$@")

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

# Use binclashlogger by default if no other logger is specified
if [[ "${extraBuildParameters[*]}" == *"-MsBuildEventLogging"* ]]; then
msbuildEventLogging=""
else
msbuildEventLogging="-MsBuildEventLogging=\"/l:BinClashLogger,Tools/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log\""
fi

if [[ "$subDirectoryName" == "Tests_Managed" ]]; then
# Execute msbuild managed test build in stages - workaround for excessive data retention in MSBuild ConfigCache
# See https://github.com/Microsoft/msbuild/issues/2993
Expand All @@ -337,12 +339,16 @@ build_Tests_internal()
export TestBuildSlice=$slice

# Generate build command
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"
buildArgs=("-Project=$projectName" "-MsBuildLog=${__msbuildLog}" "-MsBuildWrn=${__msbuildWrn}" "-MsBuildErr=${__msbuildErr}")
buildArgs+=("$msbuildEventLogging")
buildArgs+=("${extraBuildParameters[@]}")
buildArgs+=("${__RunArgs[@]}")
buildArgs+=("${__UnprocessedBuildArgs[@]}")

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

# Invoke MSBuild
eval $buildCommand
"$__ProjectRoot/run.sh" build "${buildArgs[@]}"

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

# Generate build command
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"
buildArgs=("-Project=$projectName" "-MsBuildLog=${__msbuildLog}" "-MsBuildWrn=${__msbuildWrn}" "-MsBuildErr=${__msbuildErr}")
buildArgs+=("$msbuildEventLogging")
buildArgs+=("${extraBuildParameters[@]}")
buildArgs+=("${__RunArgs[@]}")
buildArgs+=("${__UnprocessedBuildArgs[@]}")

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

# Invoke MSBuild
eval $buildCommand

# Invoke MSBuild
# $__ProjectRoot/run.sh build -Project=$projectName -MsBuildLog="$__msbuildLog" -MsBuildWrn="$__msbuildWrn" -MsBuildErr="$__msbuildErr" $extraBuildParameters $__RunArgs $__UnprocessedBuildArgs
"$__ProjectRoot/run.sh" build "${buildArgs[@]}"

# Make sure everything is OK
if [ $? -ne 0 ]; then
Expand Down Expand Up @@ -524,7 +531,7 @@ __ZipTests=0
__NativeTestIntermediatesDir=
__RunTests=0
__RebuildTests=0
__BuildTestWrappers=0
__BuildTestWrappers=1
__GenerateLayoutOnly=
__GenerateTestHostOnly=
__priority1=
Expand Down Expand Up @@ -686,23 +693,23 @@ while :; do
;;
priority1)
__priority1=1
__UnprocessedBuildArgs="$__UnprocessedBuildArgs -priority=1"
__UnprocessedBuildArgs+=("-priority=1")
;;
*)
__UnprocessedBuildArgs="$__UnprocessedBuildArgs $1"
__UnprocessedBuildArgs+=("$1")
;;
esac

shift
done


__RunArgs="-BuildArch=$__BuildArch -BuildType=$__BuildType -BuildOS=$__BuildOS"
__RunArgs=("-BuildArch=$__BuildArch" "-BuildType=$__BuildType" "-BuildOS=$__BuildOS")

# Configure environment if we are doing a verbose build
if [ $__VerboseBuild == 1 ]; then
export VERBOSE=1
__RunArgs="$__RunArgs -verbose"
__RunArgs+=("-verbose")
fi

# Set default clang version
Expand Down Expand Up @@ -747,7 +754,7 @@ __CrossgenExe="$__CrossComponentBinDir/crossgen"

isMSBuildOnNETCoreSupported

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

0 comments on commit f5f9a34

Please sign in to comment.