@@ -38,12 +38,52 @@ function Write-DotnetVersion
3838 Write-Host " .NET Core runtime version: $dotnetVersion " - ForegroundColor Cyan
3939}
4040
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+
4358function dotnet-run ($project , $argv ) { Invoke-Cmd " dotnet run --project $project $argv " }
44- function dotnet-test ($project , $argv ) { Invoke-Cmd " dotnet test $project $argv " }
4559function dotnet-pack ($project , $argv ) { Invoke-Cmd " dotnet pack $project $argv " }
4660
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+
4787function Test-Version ($project )
4888{
4989 if ($env: APPVEYOR_REPO_TAG -eq $true )
@@ -88,26 +128,6 @@ function Remove-OldBuildArtifacts
88128 Remove-Item $_ - Recurse - Force }
89129}
90130
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-
111131# ----------------------------------------------
112132# Main
113133# ----------------------------------------------
@@ -130,42 +150,28 @@ Remove-OldBuildArtifacts
130150$configuration = if ($Release.IsPresent ) { " Release" } else { " Debug" }
131151
132152Write-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 "
136154
137155if (! $ExcludeTests.IsPresent -and ! $Run.IsPresent )
138156{
139157 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
151161}
152162
153163if (! $ExcludeSamples.IsPresent -and ! $Run.IsPresent )
154164{
155165 Write-Host " Building and testing samples..." - ForegroundColor Magenta
156-
157- dotnet- restore $sampleApp
158166 dotnet- build $sampleApp
159167
160- dotnet- restore $sampleAppTests
161168 dotnet- build $sampleAppTests
162169 dotnet- test $sampleAppTests
163170}
164171
165172if ($Run.IsPresent )
166173{
167174 Write-Host " Launching sample application..." - ForegroundColor Magenta
168- dotnet- restore $sampleApp
169175 dotnet- build $sampleApp
170176 dotnet- run $sampleApp
171177}
0 commit comments