forked from danbarua/NEventSocket
-
Notifications
You must be signed in to change notification settings - Fork 11
/
default.ps1
84 lines (71 loc) · 3.16 KB
/
default.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
properties {
$projectName = "NEventSocket"
$buildNumber = 0
$rootDir = Resolve-Path .\
$buildOutputDir = "$rootDir\build"
$mergedDir = "$buildOutputDir\merged"
$reportsDir = "$buildOutputDir\reports"
$srcDir = "$rootDir\src"
$solutionFilePath = "$rootDir\$projectName.sln"
$assemblyInfoFilePath = "$rootDir\SharedAssemblyInfo.cs"
$ilmerge_path = "$rootDir\packages\ILMerge.2.14.1208\tools\ilmerge.exe"
$xunit_path = "$rootDir\packages\xunit.runners.1.9.2\tools\xunit.console.clr4.x86.exe"
$is_appveyor_build = Test-Path Env:\APPVEYOR_BUILD_NUMBER
}
task BuildMergedPackage -depends Clean, UpdateVersion, RunTests, CreateNuGetPackages
task default -depends Clean, CreateNuGetPackageFromProject
task Clean {
Remove-Item $buildOutputDir -Force -Recurse -ErrorAction SilentlyContinue
exec { dotnet build /nologo /verbosity:quiet $solutionFilePath /t:Clean /p:platform="Any CPU"}
}
task UpdateVersion {
$version = Get-Version $assemblyInfoFilePath
$oldVersion = New-Object Version $version
$newVersion = New-Object Version ($oldVersion.Major, $oldVersion.Minor, $oldVersion.Build, $buildNumber)
Update-Version $newVersion $assemblyInfoFilePath
}
task Compile {
if ($is_appveyor_build){
exec { dotnet build /nologo /verbosity:quiet $solutionFilePath /p:Configuration=Release /p:platform="Any CPU" /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"}
}
else{
exec { dotnet build /nologo /verbosity:quiet $solutionFilePath /p:Configuration=Release /p:platform="Any CPU"}
}
}
task RunTests -depends Compile {
New-Item "$reportsDir\xUnit\$project\" -Type Directory -ErrorAction SilentlyContinue
#if (!($is_appveyor_build)){
exec { & dotnet test -c Release -r "$reportsDir\xUnit\$project"}
#}
}
task ILMerge -depends Compile {
New-Item $mergedDir -Type Directory -ErrorAction SilentlyContinue
$dllDir = "$srcDir\NEventSocket\bin\Release"
$inputDlls = "$dllDir\NEventSocket.dll "
@("System.Reactive.Core", "System.Reactive.Interfaces", "System.Reactive.Linq", "System.Reactive.PlatformServices") |% { $inputDlls = "$inputDlls $dllDir\$_.dll" }
Invoke-Expression "$ilmerge_path /targetplatform:v4 /internalize /allowDup /target:library /log /out:$mergedDir\NEventSocket.dll $inputDlls"
}
task CreateNuGetPackages -depends ILMerge {
$versionString = Get-Version $assemblyInfoFilePath
$version = New-Object Version $versionString
if (-not $is_appveyor_build){
$packageVersion = $version.Major.ToString() + "." + $version.Minor.ToString() + "." + $version.Build.ToString()
}
else{
$packageVersion = $version.Major.ToString() + "." + $version.Minor.ToString() + "." + $version.Build.ToString() + "-build" + $buildNumber.ToString().PadLeft(5,'0')
}
$packageVersion
gci $srcDir -Recurse -Include *.nuspec | % {
exec { nuget.exe pack $_ -o $buildOutputDir -version $packageVersion }
}
}
task CreateNuGetPackageFromProject -depends RunTests {
exec { dotnet pack -o $buildOutputDir -c Release }
}
task PublishNugetPackages -depends CreateNuGetPackages {
Get-ChildItem "$buildOutputDir\*.nupkg" | `
ForEach-Object {
Write-Host "Publishing $($_.FullName)"
exec { nuget.exe push $_.FullName }
}
}