@@ -38,12 +38,52 @@ function Write-DotnetVersion
38
38
Write-Host " .NET Core runtime version: $dotnetVersion " - ForegroundColor Cyan
39
39
}
40
40
41
- function dotnet-restore ($project , $argv ) { Invoke-Cmd " dotnet restore $project $argv " }
42
- function dotnet-build ($project , $argv ) { Invoke-Cmd " dotnet build $project $argv " }
41
+ function Get-TargetFrameworks ($projFile )
42
+ {
43
+ [xml ]$proj = Get-Content $projFile
44
+
45
+ if ($proj.Project.PropertyGroup.TargetFrameworks -ne $null ) {
46
+ ($proj.Project.PropertyGroup.TargetFrameworks ).Split(" ;" )
47
+ }
48
+ else {
49
+ @ ($proj.Project.PropertyGroup.TargetFramework )
50
+ }
51
+ }
52
+
53
+ function Get-NetCoreTargetFramework ($projFile )
54
+ {
55
+ Get-TargetFrameworks $projFile | where { $_ -like " netstandard*" -or $_ -like " netcoreapp*" }
56
+ }
57
+
43
58
function dotnet-run ($project , $argv ) { Invoke-Cmd " dotnet run --project $project $argv " }
44
- function dotnet-test ($project , $argv ) { Invoke-Cmd " dotnet test $project $argv " }
45
59
function dotnet-pack ($project , $argv ) { Invoke-Cmd " dotnet pack $project $argv " }
46
60
61
+ function dotnet-build ($project , $argv )
62
+ {
63
+ if ($OnlyNetStandard.IsPresent ) {
64
+ $fw = Get-NetCoreTargetFramework $project
65
+ $argv = " -f $fw " + $argv
66
+ }
67
+
68
+ Invoke-Cmd " dotnet build $project $argv "
69
+ }
70
+
71
+ function dotnet-test ($project , $argv )
72
+ {
73
+ # Currently dotnet test does not work for net461 on Linux/Mac
74
+ # See: https://github.com/Microsoft/vstest/issues/1318
75
+ #
76
+ # Previously dotnet-xunit was a great alternative, however after
77
+ # issues with the maintenance dotnet xunit has been discontinued
78
+ # after xunit 2.4: https://xunit.github.io/releases/2.4
79
+ if (! (Test-IsWindows ) -or $OnlyNetStandard.IsPresent ) {
80
+ $fw = Get-NetCoreTargetFramework $project ;
81
+ $argv = " -f $fw " + $argv
82
+ }
83
+
84
+ Invoke-Cmd " dotnet test $project $argv "
85
+ }
86
+
47
87
function Test-Version ($project )
48
88
{
49
89
if ($env: APPVEYOR_REPO_TAG -eq $true )
@@ -88,26 +128,6 @@ function Remove-OldBuildArtifacts
88
128
Remove-Item $_ - Recurse - Force }
89
129
}
90
130
91
- function Get-TargetFrameworks ($projFile )
92
- {
93
- [xml ]$proj = Get-Content $projFile
94
- ($proj.Project.PropertyGroup.TargetFrameworks ).Split(" ;" )
95
- }
96
-
97
- function Get-NetCoreTargetFramework ($projFile )
98
- {
99
- Get-TargetFrameworks $projFile | where { $_ -like " netstandard*" -or $_ -like " netcoreapp*" }
100
- }
101
-
102
- function Get-FrameworkArg ($projFile )
103
- {
104
- if ($OnlyNetStandard.IsPresent ) {
105
- $fw = Get-NetCoreTargetFramework $projFile
106
- " -f $fw "
107
- }
108
- else { " " }
109
- }
110
-
111
131
# ----------------------------------------------
112
132
# Main
113
133
# ----------------------------------------------
@@ -130,42 +150,28 @@ Remove-OldBuildArtifacts
130
150
$configuration = if ($Release.IsPresent ) { " Release" } else { " Debug" }
131
151
132
152
Write-Host " Building Giraffe.DotLiquid..." - ForegroundColor Magenta
133
- $framework = Get-FrameworkArg $giraffeDotLiquid
134
- dotnet- restore $giraffeDotLiquid
135
- dotnet- build $giraffeDotLiquid " -c $configuration $framework "
153
+ dotnet- build $giraffeDotLiquid " -c $configuration "
136
154
137
155
if (! $ExcludeTests.IsPresent -and ! $Run.IsPresent )
138
156
{
139
157
Write-Host " Building and running tests..." - ForegroundColor Magenta
140
- $framework = Get-FrameworkArg $giraffeDotLiquidTests
141
- # Currently dotnet test does not work for net461 on Linux/Mac
142
- # See: https://github.com/Microsoft/vstest/issues/1318
143
- if (! (Test-IsWindows )) {
144
- Write-Warning " Running tests only for .NET Core build, because dotnet test does not support net4x tests on Linux/Mac at the moment (see: https://github.com/Microsoft/vstest/issues/1318)."
145
- $fw = Get-NetCoreTargetFramework $giraffeDotLiquidTests
146
- $framework = " -f $fw "
147
- }
148
- dotnet- restore $giraffeDotLiquidTests
149
- dotnet- build $giraffeDotLiquidTests $framework
150
- dotnet- test $giraffeDotLiquidTests $framework
158
+
159
+ dotnet- build $giraffeDotLiquidTests
160
+ dotnet- test $giraffeDotLiquidTests
151
161
}
152
162
153
163
if (! $ExcludeSamples.IsPresent -and ! $Run.IsPresent )
154
164
{
155
165
Write-Host " Building and testing samples..." - ForegroundColor Magenta
156
-
157
- dotnet- restore $sampleApp
158
166
dotnet- build $sampleApp
159
167
160
- dotnet- restore $sampleAppTests
161
168
dotnet- build $sampleAppTests
162
169
dotnet- test $sampleAppTests
163
170
}
164
171
165
172
if ($Run.IsPresent )
166
173
{
167
174
Write-Host " Launching sample application..." - ForegroundColor Magenta
168
- dotnet- restore $sampleApp
169
175
dotnet- build $sampleApp
170
176
dotnet- run $sampleApp
171
177
}
0 commit comments