@@ -38,39 +38,52 @@ function Update-GeneratedCode {
3838 write-host - foreground blue " Generate code...END`n "
3939}
4040
41- function Start-Build ([ boolean ] $IncludeNanoFramework = $false ) {
42- write-host - foreground blue " Start-Build...`n ---"
41+ function Start-Build {
42+ write-host - foreground blue " Start-Build (dotnet CLI) ...`n ---"
4343
44- $fileLoggerArg = " /logger:FileLogger,Microsoft.Build;logfile=$logsDir \UnitsNet.msbuild.log"
45-
46- dotnet build -- configuration Release / p:ContinuousIntegrationBuild= true " $root \UnitsNet.slnx" $fileLoggerArg
44+ # Use dotnet CLI for all main projects - cross-platform compatible
45+ dotnet build -- configuration Release / p:ContinuousIntegrationBuild= true " $root \UnitsNet.slnx"
4746 if ($lastexitcode -ne 0 ) { exit 1 }
4847
49- if (-not $IncludeNanoFramework )
50- {
51- write-host - foreground yellow " Skipping .NET nanoFramework build."
48+ write-host - foreground blue " Start-Build...END`n "
49+ }
50+
51+ function Start-BuildNanoFramework {
52+ write-host - foreground blue " Start-BuildNanoFramework (MSBuild)...`n ---"
53+
54+ # Check prerequisites
55+ if (-not $msbuildx64 -or -not (Test-Path $msbuildx64 )) {
56+ write-host - foreground red " ERROR: Cannot build .NET nanoFramework - MSBuild not found."
57+ write-host - foreground yellow " Install Visual Studio with .NET desktop development workload to build NanoFramework projects."
58+ exit 1
5259 }
53- else
54- {
55- # Check if MSBuild is available before attempting NanoFramework build
56- if (-not $msbuildx64 -or -not (Test-Path $msbuildx64 )) {
57- write-host - foreground yellow " Cannot build .NET nanoFramework - MSBuild not found. Install Visual Studio to build NanoFramework projects."
58- write-host - foreground yellow " Continuing with main build only..."
59- }
60- else {
61- write-host - foreground green " Build .NET nanoFramework."
62- $fileLoggerArg = " /logger:FileLogger,Microsoft.Build;logfile=$logsDir \UnitsNet.NanoFramework.msbuild.log"
63-
64- # msbuild does not auto-restore nugets for this project type
65- & " $nuget " restore " $root \UnitsNet.NanoFramework\GeneratedCode\UnitsNet.nanoFramework.sln"
66-
67- # now build
68- & " $msbuildx64 " " $root \UnitsNet.NanoFramework\GeneratedCode\UnitsNet.nanoFramework.sln" / verbosity:minimal / p:Configuration= Release / p:Platform= " Any CPU" / p:ContinuousIntegrationBuild= true $fileLoggerArg
69- if ($lastexitcode -ne 0 ) { exit 1 }
70- }
60+
61+ if (-not (Test-Path $nuget )) {
62+ write-host - foreground red " ERROR: NuGet.exe not found at $nuget "
63+ write-host - foreground yellow " Run init.ps1 to download required tools."
64+ exit 1
7165 }
7266
73- write-host - foreground blue " Start-Build...END`n "
67+ write-host - foreground green " Building .NET nanoFramework projects..."
68+ $fileLoggerArg = " /logger:FileLogger,Microsoft.Build;logfile=$logsDir \UnitsNet.NanoFramework.msbuild.log"
69+
70+ # msbuild does not auto-restore nugets for this project type
71+ write-host " Restoring NuGet packages for NanoFramework..."
72+ & " $nuget " restore " $root \UnitsNet.NanoFramework\GeneratedCode\UnitsNet.nanoFramework.sln"
73+ if ($lastexitcode -ne 0 ) {
74+ write-host - foreground red " Failed to restore NuGet packages for NanoFramework"
75+ exit 1
76+ }
77+
78+ # Build with MSBuild
79+ write-host " Building NanoFramework solution..."
80+ & " $msbuildx64 " " $root \UnitsNet.NanoFramework\GeneratedCode\UnitsNet.nanoFramework.sln" / verbosity:minimal / p:Configuration= Release / p:Platform= " Any CPU" / p:ContinuousIntegrationBuild= true $fileLoggerArg
81+ if ($lastexitcode -ne 0 ) {
82+ write-host - foreground red " Failed to build NanoFramework solution"
83+ exit 1
84+ }
85+
86+ write-host - foreground blue " Start-BuildNanoFramework...END`n "
7487}
7588
7689function Start-Tests {
@@ -112,14 +125,14 @@ function Start-Tests {
112125 write-host - foreground blue " Run tests...END`n "
113126}
114127
115- function Start-PackNugets ([ boolean ] $IncludeNanoFramework = $false ) {
128+ function Start-PackNugets {
116129 $projectPaths = @ (
117130 " UnitsNet\UnitsNet.csproj" ,
118131 " UnitsNet.Serialization.JsonNet\UnitsNet.Serialization.JsonNet.csproj" ,
119132 " UnitsNet.NumberExtensions\UnitsNet.NumberExtensions.csproj"
120133 )
121134
122- write-host - foreground blue " Pack nugets...`n ---"
135+ write-host - foreground blue " Pack nugets (dotnet CLI) ...`n ---"
123136 foreach ($projectPath in $projectPaths ) {
124137 dotnet pack -- configuration Release `
125138 -- no- build `
@@ -130,14 +143,23 @@ function Start-PackNugets([boolean] $IncludeNanoFramework = $false) {
130143 if ($lastexitcode -ne 0 ) { exit 1 }
131144 }
132145
133- if (-not $IncludeNanoFramework ) {
134- write-host - foreground yellow " Skipping nanoFramework nuget pack."
135- } else {
136- write-host - foreground yellow " nanoFramework project not yet supported by dotnet CLI, using nuget.exe instead"
137- Invoke-BuildNanoNugets
146+ write-host - foreground blue " Pack nugets...END`n "
147+ }
148+
149+ function Start-PackNugetsNanoFramework {
150+ write-host - foreground blue " Pack NanoFramework nugets (NuGet.exe)...`n ---"
151+
152+ # Check prerequisites
153+ if (-not (Test-Path $nuget )) {
154+ write-host - foreground red " ERROR: NuGet.exe not found at $nuget "
155+ write-host - foreground yellow " Run init.ps1 to download required tools."
156+ exit 1
138157 }
139158
140- write-host - foreground blue " Pack nugets...END`n "
159+ write-host - foreground yellow " nanoFramework project not yet supported by dotnet CLI, using nuget.exe instead"
160+ Invoke-BuildNanoNugets
161+
162+ write-host - foreground blue " Pack NanoFramework nugets...END`n "
141163}
142164
143165function Compress-ArtifactsAsZip {
@@ -160,4 +182,4 @@ function Compress-ArtifactsAsZip {
160182 write-host - foreground blue " Zip artifacts...END`n "
161183}
162184
163- export-modulemember - function Start-NugetRestore , Remove-ArtifactsDir , Update-GeneratedCode , Start-Build , Start-SignedBuild , Start-Tests , Start-PackNugets , Compress-ArtifactsAsZip
185+ export-modulemember - function Remove-ArtifactsDir , Update-GeneratedCode , Start-Build , Start-BuildNanoFramework , Start-Tests , Start-PackNugets , Start-PackNugetsNanoFramework , Compress-ArtifactsAsZip
0 commit comments