-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ps1
95 lines (81 loc) · 2.79 KB
/
build.ps1
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
$ErrorActionPreference = 'Stop'
$solutionName = 'Dhgms.Nucleotide'
$solutionPath = 'src\\' + $solutionName + '.sln'
$testProject = 'src\\' + $solutionName + '.UnitTests\\' + $solutionName + '.UnitTests.csproj'
function CreateDirectoryIfItDoesNotExist([String] $DirectoryToCreate)
{
if (-not (Test-Path -LiteralPath $DirectoryToCreate))
{
try
{
New-Item -Path $DirectoryToCreate -ItemType Directory -ErrorAction Stop | Out-Null #-Force
}
catch
{
Write-Error -Message "Unable to create directory '$DirectoryToCreate'. Error was: $_" -ErrorAction Stop
}
}
}
$tools = (
('dotnet', ('tool', 'install', '--global', 'dotMorten.OmdGenerator')),
('dotnet', ('tool', 'install', '--global', 'ConfigValidate')),
('dotnet', ('tool', 'install', '--global', 'dotnet-outdated-tool')),
('dotnet', ('tool', 'install', '--global', 'snitch')),
('dotnet', ('tool', 'install', '--global', 'dotnet-sonarscanner'))
#{ restore $solutionPath /bl:artifacts\\binlog\\restore.binlog }
)
Foreach ($i in $tools)
{
& $i[0] $i[1]
}
CreateDirectoryIfItDoesNotExist('.\artifacts\nupkg');
CreateDirectoryIfItDoesNotExist('.\artifacts\outdated');
CreateDirectoryIfItDoesNotExist('.\artifacts\snitch');
CreateDirectoryIfItDoesNotExist('.\artifacts\omd');
CreateDirectoryIfItDoesNotExist('.\artifacts\docfx');
Remove-Item 'artifacts\docfx\*.*' -Recurse
$actions = (
('dotnet', ('restore', $solutionPath, '/bl:artifacts\\binlog\\restore.binlog')),
('dotnet', ('build', $solutionPath, '--configuration', 'Release', '--no-restore', '/bl:artifacts\\binlog\\build.binlog')),
('dotnet', ('test', $testProject, '--configuration', 'Release', '--no-build', '--nologo', '--collect:"XPlat Code Coverage"', '--', 'DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover', '/bl:artifacts\\binlog\\test.binlog'))
)
Foreach ($i in $actions)
{
& $i[0] $i[1]
if(!$?)
{
return 1;
}
}
#$runSonar = $false;
#
#if ($runSonar)
#{
# dotnet sonarscanner begin /k:"project-key"
#}
#if ($runSonar)
#{
# dotnet sonarscanner end
#}
if ($Env:GITHUB_REF -and $Env:GITHUB_REF.StartsWith("refs/heads/dependabot"))
{
#drop out if dependabot, no point doing package ref checks, or additional output as won't be used.
Write-Host "Dependabot branch, skipping rest of checks"
return
}
$postBuildActions = (
('dotnet', ('pack', $solutionPath, '--configuration', 'Release', '--no-build', '/bl:artifacts\\binlog\\pack.binlog', '/p:PackageOutputPath=..\..\artifacts\nuget')),
('dotnet', ('outdated', '-o', 'artifacts\outdated\outdated.json', 'src'))
#('snitch', ('src', '--strict')),
#('generateomd.exe', ('/source=src', '/output=artifacts\omd\index.htm', '/format=html'))
)
Foreach ($i in $postBuildActions)
{
#Write-Host -Message 'Starting $i[1]'
& $i[0] $i[1]
if(!$?)
{
return 1;
}
}
#xcopy src\docfx_project\_site artifacts\docfx /E /I /Y