1
+ Properties {
2
+ $base_dir = resolve-path .\..\..\
3
+ $packages_dir = " $base_dir \packages"
4
+ $build_artifacts_dir = " $base_dir \build"
5
+ $solution_name = " $base_dir \WebApiContrib.Formatting.Xlsx.sln"
6
+ $test_dll = " $build_artifacts_dir \WebApiContrib.Formatting.Xlsx.Tests.dll"
7
+ $nuget_exe = " $base_dir \.nuget\Nuget.exe"
8
+ $test_result_path = " $base_dir \TestResults\"
9
+ $test_result_file = [System.IO.Path ]::Combine($test_result_path , " TestResults.trx" )
10
+ $vscomntools_path = VSCommonToolsPath
11
+ $mstest_path = (Get-Item $vscomntools_path ).Parent.FullName
12
+ $mstest_exe = [System.IO.Path ]::Combine($mstest_path , " IDE\MSTest.exe" )
13
+ }
14
+
15
+ Task Default - Depends BuildWebApiContrib, RunUnitTests, NuGetBuild
16
+
17
+ Task BuildWebApiContrib - Depends Clean , Build
18
+
19
+ Task Clean {
20
+ Exec { msbuild $solution_name / v:Quiet / t:Clean / p:Configuration= Release }
21
+ }
22
+
23
+ Task Build - depends Clean {
24
+ Exec { msbuild $solution_name / v:Quiet / t:Build / p:Configuration= Release / p:OutDir= $build_artifacts_dir \ }
25
+ }
26
+
27
+ Task NuGetBuild - depends Clean {
28
+ & $nuget_exe pack " $base_dir /src/WebApiContrib.Formatting.Xlsx/WebApiContrib.Formatting.Xlsx.csproj" - Build - OutputDirectory $build_artifacts_dir - Verbose - Properties Configuration= Release
29
+ }
30
+
31
+ Task RunUnitTests - depends Build {
32
+ $test_arguments = @ (" /resultsFile:$test_result_file " )
33
+ $test_arguments += " /testcontainer:$test_dll "
34
+
35
+ If (Test-Path $test_result_file ) { Remove-Item $test_result_file }
36
+
37
+ # psake will terminate the execution if mstest throws an exception.
38
+ Exec { & $mstest_exe $test_arguments }
39
+ }
40
+
41
+ # Find VS Common Tools directory path for the most recent version of Visual Studio.
42
+ Function VSCommonToolsPath {
43
+ If (Test-Path Env:VS150COMNTOOLS) { Return (Get-ChildItem env:VS150COMNTOOLS).Value }
44
+ If (Test-Path Env:VS140COMNTOOLS) { Return (Get-ChildItem env:VS140COMNTOOLS).Value }
45
+ If (Test-Path Env:VS130COMNTOOLS) { Return (Get-ChildItem env:VS130COMNTOOLS).Value }
46
+ If (Test-Path Env:VS120COMNTOOLS) { Return (Get-ChildItem env:VS120COMNTOOLS).Value }
47
+ If (Test-Path Env:VS110COMNTOOLS) { Return (Get-ChildItem env:VS110COMNTOOLS).Value }
48
+ If (Test-Path Env:VS100COMNTOOLS) { Return (Get-ChildItem env:VS100COMNTOOLS).Value }
49
+ If (Test-Path Env:VS90COMNTOOLS ) { Return (Get-ChildItem env:VS90COMNTOOLS).Value }
50
+ If (Test-Path Env:VS80COMNTOOLS ) { Return (Get-ChildItem env:VS80COMNTOOLS).Value }
51
+ }
0 commit comments