forked from microsoft/binskim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BuildAndTest.cmd
86 lines (68 loc) · 3.91 KB
/
BuildAndTest.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
@echo off
SETLOCAL
@REM Uncomment this line to update nuget.exe
@REM Doing so can break SLN build (which uses nuget.exe to
@REM create a nuget package for binskim) so must opt-in
@REM %~dp0.nuget\NuGet.exe update -self
set Configuration=%1
set Platform=AnyCPU
if "%Configuration%" EQU "" (
set Configuration=Release
)
@REM Remove existing build data
if exist bld (rd /s /q bld)
SET NuGetConfigFile=%~dp0src\NuGet.config
set NuGetPackageDir=%~dp0src\packages
set NuGetOutputDirectory=%~dp0bld\bin\nuget\
call SetCurrentVersion.cmd
set VERSION_CONSTANTS=%~dp0src\BinaryParsers\VersionConstants.cs
@REM Rewrite VersionConstants.cs
echo // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT > %VERSION_CONSTANTS%
echo // license. See LICENSE file in the project root for full license information. >> %VERSION_CONSTANTS%
echo namespace Microsoft.CodeAnalysis.IL >> %VERSION_CONSTANTS%
echo { >> %VERSION_CONSTANTS%
echo public static class VersionConstants >> %VERSION_CONSTANTS%
echo { >> %VERSION_CONSTANTS%
echo public const string Prerelease = "%PRERELEASE%"; >> %VERSION_CONSTANTS%
echo public const string AssemblyVersion = "%MAJOR%.%MINOR%.%PATCH%" + ".0"; >> %VERSION_CONSTANTS%
echo public const string FileVersion = "%MAJOR%.%MINOR%.%PATCH%" + ".0"; >> %VERSION_CONSTANTS%
echo public const string Version = AssemblyVersion + Prerelease; >> %VERSION_CONSTANTS%
echo } >> %VERSION_CONSTANTS%
echo } >> %VERSION_CONSTANTS%
dotnet restore --runtime win-x86 --runtime win-x64 --runtime linux-x64 %~dp0src\BinSkim.sln /p:Configuration=%Configuration% --configfile "%NuGetConfigFile%" --packages "%NuGetPackageDir%"
:: Build the solution
dotnet clean /verbosity:minimal %~dp0src\BinSkim.sln /p:Configuration=%Configuration% || goto :ExitFailed
dotnet build --no-restore /verbosity:minimal %~dp0src\BinSkim.sln /p:Configuration=%Configuration% /filelogger /fileloggerparameters:Verbosity=detailed || goto :ExitFailed
::Run unit tests
echo Run all multitargeting xunit tests
call :RunTestProject BinaryParsers Unit || goto :ExitFailed
call :RunTestProject BinSkim.Rules Unit || goto :ExitFailed
call :RunTestProject BinSkim.Driver Functional || goto :ExitFailed
call :RunTestProject BinSkim.Rules Functional || goto :ExitFailed
::Create the BinSkim platform specific publish packages
echo Creating Platform Specific BinSkim 'Publish' Packages
call :CreatePublishPackage netcoreapp2.0 win-x86 || goto :ExitFailed
call :CreatePublishPackage netcoreapp2.0 win-x64 || goto :ExitFailed
call :CreatePublishPackage netcoreapp2.0 linux-x64 || goto :ExitFailed
::Build NuGet package
echo BuildPackages.cmd
call BuildPackages.cmd || goto :ExitFailed
::Create layout directory of assemblies that need to be signed
echo CreateLayoutDirectory.cmd %~dp0bld\bin %Configuration% %Platform%
call CreateLayoutDirectory.cmd %~dp0bld\bin %Configuration% %Platform%
goto :Exit
:RunTestProject
set TestProject=%1
set TestType=%2
pushd %~dp0src\Test.%TestType%Tests.%TestProject% && dotnet test --no-build -c %Configuration% && popd
if "%ERRORLEVEL%" NEQ "0" (echo %TestProject% %TestType% tests execution FAILED.)
Exit /B %ERRORLEVEL%
:CreatePublishPackage
set Framework=%~1
set RuntimeArg=%~2
dotnet publish %~dp0src\BinSkim.Driver\BinSkim.Driver.csproj --no-restore -c %Configuration% -f %Framework% --runtime %RuntimeArg%
Exit /B %ERRORLEVEL%
:ExitFailed
@echo Build and test did not complete successfully.
Exit /B 1
:Exit