-
Notifications
You must be signed in to change notification settings - Fork 167
Expand file tree
/
Copy pathBuildAndTest.cmd
More file actions
90 lines (68 loc) · 3.19 KB
/
BuildAndTest.cmd
File metadata and controls
90 lines (68 loc) · 3.19 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
@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
if "%Configuration%" EQU "" (
set Configuration=Release
)
@REM Remove existing build data
if exist bld (rd /s /q bld)
set NuGetOutputDirectory=%~dp0bld\bin\nuget\
call SetCurrentVersion.cmd
set VERSION_CONSTANTS=%~dp0src\BinaryParsers\VersionConstants.cs
if not "%PRERELEASE%"=="" set PRERELEASE=.%PRERELEASE%
@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%";>> %VERSION_CONSTANTS%
echo public const string FileVersion = "%MAJOR%.%MINOR%.%PATCH%";>> %VERSION_CONSTANTS%
echo public const string Version = AssemblyVersion + Prerelease;>> %VERSION_CONSTANTS%
echo }>> %VERSION_CONSTANTS%
echo }>> %VERSION_CONSTANTS%
@REM Prerelease already contains dot if needed
echo Current Version: %MAJOR%.%MINOR%.%PATCH%%PRERELEASE%
::Restore packages
echo Restoring packages...
dotnet restore %~dp0src\BinSkim.sln
:: Build the solution
echo Building solution...
dotnet build --no-restore /verbosity:minimal %~dp0src\BinSkim.sln /p:Configuration=%Configuration% /filelogger /fileloggerparameters:Verbosity=detailed || goto :ExitFailed
::Run unit tests
echo Run unit tests
call :RunTests || goto :ExitFailed
::Create the BinSkim platform specific publish packages
echo Creating Platform Specific BinSkim 'Publish' Packages
call :CreatePublishPackage net9.0 win-x64 || goto :ExitFailed
call :CreatePublishPackage net9.0 linux-x64 || goto :ExitFailed
call :CreatePublishPackage net9.0 linux-arm64 || goto :ExitFailed
call :CreatePublishPackage net9.0 osx-x64 || goto :ExitFailed
::Build NuGet package
echo BuildPackages.cmd
call BuildPackages.cmd || goto :ExitFailed
::Update BinSkimRules.md to cover any xml changes
echo Exporting any BinSkim rules
.\bld\bin\BinSkim.Driver\release\BinSkim.exe export-rules .\docs\BinSkimRules.md
echo Fixing markdown angle brackets
powershell -Command "$content = [System.IO.File]::ReadAllText('.\docs\BinSkimRules.md'); $content = $content -replace '<', '<' -replace '>', '>'; [System.IO.File]::WriteAllText('.\docs\BinSkimRules.md', $content)"
goto :Exit
:RunTests
dotnet test src\BinSkim.sln --no-build -c %Configuration%
if "%ERRORLEVEL%" NEQ "0" (echo 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% --self-contained true
Exit /B %ERRORLEVEL%
:ExitFailed
@echo Build and test did not complete successfully.
Exit /B 1
:Exit