diff --git a/build.ps1 b/build.ps1 index 06fea4c768..d31ab318cc 100644 --- a/build.ps1 +++ b/build.ps1 @@ -54,7 +54,8 @@ You can also use -NoBuildManaged to suppress this project type. .PARAMETER BuildNative Build native projects (C++). -You can also use -NoBuildNative to suppress this project type. +This is the default for x64 and x86 builds but useful when you want to build _only_ native projects. +You can use -NoBuildNative to suppress this project type. .PARAMETER BuildNodeJS Build NodeJS projects (TypeScript, JS). @@ -89,8 +90,21 @@ Key for feed that can be used when downloading .NET runtimes .EXAMPLE Building both native and managed projects. + build.ps1 + +or + + build.ps1 -BuildManaged + +or + build.ps1 -BuildManaged -BuildNative +.EXAMPLE +Build only native projects. + + build.ps1 -BuildNative + .EXAMPLE Building a subfolder of code. @@ -146,10 +160,6 @@ param( [switch]$NoBuildRepoTasks, - # Disable pre-build of C++ code in x64 (default) and x86 builds. Affects -All and -Projects handling and causes - # -BuildInstallers and -BuildNative to be ignored. - [switch]$ForceCoreMsbuild, - # Diagnostics [Alias('bl')] [switch]$BinaryLog, @@ -191,15 +201,12 @@ if ($Projects) { { $Projects = Join-Path (Get-Location) $Projects } - $MSBuildArguments += "/p:ProjectToBuild=$Projects" } # When adding new sub-group build flags, add them to this check. elseif (-not ($All -or $BuildNative -or $BuildManaged -or $BuildNodeJS -or $BuildInstallers -or $BuildJava)) { - Write-Warning "No default group of projects was specified, so building the 'managed' and its dependent subsets of projects. Run ``build.cmd -help`` for more details." - - # This goal of this is to pick a sensible default for `build.cmd` with zero arguments. - # Now that we support subfolder invokations of build.cmd, we will be pushing to have build.cmd build everything (-all) by default + Write-Warning "No default group of projects was specified, so building the managed and native projects and their dependencies. Run ``build.cmd -help`` for more details." + # The goal of this is to pick a sensible default for `build.cmd` with zero arguments. $BuildManaged = $true } @@ -261,10 +268,21 @@ if ($DotNetRuntimeSourceFeed -or $DotNetRuntimeSourceFeedKey) { # Split build categories between dotnet msbuild and desktop msbuild. Use desktop msbuild as little as possible. [string[]]$dotnetBuildArguments = $MSBuildArguments -if ($All) { $dotnetBuildArguments += '/p:BuildAllProjects=true'; $BuildNative = $true } +if ($All) { $dotnetBuildArguments += '/p:BuildAllProjects=true' } +if ($Projects) { + if ($BuildNative) { + $MSBuildArguments += "/p:ProjectToBuild=$Projects" + } else { + $dotnetBuildArguments += "/p:ProjectToBuild=$Projects" + } +} if ($NoBuildInstallers) { $MSBuildArguments += "/p:BuildInstallers=false"; $BuildInstallers = $false } if ($BuildInstallers) { $MSBuildArguments += "/p:BuildInstallers=true" } + +# Build native projects by default unless -NoBuildNative was specified. +$specifiedBuildNative = $BuildNative +$BuildNative = $true if ($NoBuildNative) { $MSBuildArguments += "/p:BuildNative=false"; $BuildNative = $false } if ($BuildNative) { $MSBuildArguments += "/p:BuildNative=true"} @@ -276,12 +294,13 @@ if ($NoBuildNodeJS) { $dotnetBuildArguments += "/p:BuildNodeJS=false"; $BuildNod if ($BuildNodeJS) { $dotnetBuildArguments += "/p:BuildNodeJS=true" } # Don't bother with two builds if just one will build everything. Ignore super-weird cases like -# "-Projects ... -NoBuildJava -NoBuildManaged -NoBuildNodeJS". -$ForceCoreMsbuild = $ForceCoreMsbuild -or -not ($BuildInstallers -or $BuildNative) -or ` - $Architecture.StartsWith("arm", [System.StringComparison]::OrdinalIgnoreCase) -$performDotnetBuild = $ForceCoreMsbuild -or $BuildJava -or $BuildManaged -or $BuildNodeJS -or ` +# "-Projects ... -NoBuildJava -NoBuildManaged -NoBuildNodeJS". An empty `./build.ps1` command will build both +# managed and native projects. +$performDesktopBuild = ($BuildInstallers -or $BuildNative) -and ` + -not $Architecture.StartsWith("arm", [System.StringComparison]::OrdinalIgnoreCase) +$performDotnetBuild = $BuildJava -or $BuildManaged -or $BuildNodeJS -or ` ($All -and -not ($NoBuildJava -and $NoBuildManaged -and $NoBuildNodeJS)) -or ` - ($Projects -and -not ($BuildInstallers -or $BuildNative)) + ($Projects -and -not ($BuildInstallers -or $specifiedBuildNative)) $foundJdk = $false $javac = Get-Command javac -ErrorAction Ignore -CommandType Application @@ -378,11 +397,11 @@ if ($BinaryLog) { $ToolsetBuildArguments += "/bl:" + (Join-Path $LogDir "Build.repotasks.binlog") } else { # Use a different binary log path when running desktop msbuild if doing both builds. - if (-not $ForceCoreMsbuild -and $performDotnetBuild) { - $MSBuildArguments += [System.IO.Path]::ChangeExtension($bl, "native.binlog") + if ($performDesktopBuild -and $performDotnetBuild) { + $MSBuildArguments += "/bl:" + [System.IO.Path]::ChangeExtension($bl, "native.binlog") } - $ToolsetBuildArguments += [System.IO.Path]::ChangeExtension($bl, "repotasks.binlog") + $ToolsetBuildArguments += "/bl:" + [System.IO.Path]::ChangeExtension($bl, "repotasks.binlog") } } elseif ($CI) { # Ensure the artifacts/log directory isn't empty to avoid warnings. @@ -421,7 +440,7 @@ try { @ToolsetBuildArguments } - if (-not $ForceCoreMsbuild) { + if ($performDesktopBuild) { Write-Host Remove-Item variable:global:_BuildTool -ErrorAction Ignore $msbuildEngine = 'vs' diff --git a/eng/scripts/GenerateReferenceAssemblies.ps1 b/eng/scripts/GenerateReferenceAssemblies.ps1 index 56c1101fb3..2884b7aa7f 100644 --- a/eng/scripts/GenerateReferenceAssemblies.ps1 +++ b/eng/scripts/GenerateReferenceAssemblies.ps1 @@ -10,9 +10,6 @@ try { & "$repoRoot\build.ps1" -ci:$ci -nobl -noBuildRepoTasks -noRestore -buildNative -configuration Debug Remove-Item variable:global:_BuildTool -ErrorAction Ignore - Remove-Item variable:global:_DotNetInstallDir -ErrorAction Ignore - Remove-Item variable:global:_ToolsetBuildProj -ErrorAction Ignore - Remove-Item variable:global:_MSBuildExe -ErrorAction Ignore $excludeCIBinarylog = $true $msbuildEngine = 'dotnet' diff --git a/src/Servers/IIS/build.cmd b/src/Servers/IIS/build.cmd index 4369bfd550..27c6a00d21 100644 --- a/src/Servers/IIS/build.cmd +++ b/src/Servers/IIS/build.cmd @@ -1,3 +1,3 @@ @ECHO OFF SET RepoRoot=%~dp0..\..\.. -%RepoRoot%\build.cmd -BuildNative -projects %~dp0**\*.csproj %* +%RepoRoot%\build.cmd -projects %~dp0**\*.csproj %* diff --git a/src/Servers/build.cmd b/src/Servers/build.cmd index 2406296662..5ea9e8eda6 100644 --- a/src/Servers/build.cmd +++ b/src/Servers/build.cmd @@ -1,3 +1,3 @@ @ECHO OFF SET RepoRoot=%~dp0..\.. -%RepoRoot%\build.cmd -projects %~dp0**\*.*proj %* +%RepoRoot%\build.cmd -projects %~dp0**\*.csproj %* diff --git a/src/SiteExtensions/build.cmd b/src/SiteExtensions/build.cmd index 8f9d907879..d0f42cd74e 100644 --- a/src/SiteExtensions/build.cmd +++ b/src/SiteExtensions/build.cmd @@ -3,14 +3,14 @@ SET RepoRoot=%~dp0..\.. ECHO Building x64 Microsoft.AspNetCore.Runtime.SiteExtension CALL "%RepoRoot%\build.cmd" -arch x64 -projects "%~dp0Runtime\Microsoft.AspNetCore.Runtime.SiteExtension.pkgproj" ^ - /bl:artifacts/log/SiteExtensions-Runtime-x86.binlog %* + "/bl:%RepoRoot%/artifacts/log/SiteExtensions-Runtime-x86.binlog" %* IF %ERRORLEVEL% NEQ 0 ( EXIT /b %ErrorLevel% ) ECHO Building x86 Microsoft.AspNetCore.Runtime.SiteExtension CALL "%RepoRoot%\build.cmd" -arch x86 -projects "%~dp0Runtime\Microsoft.AspNetCore.Runtime.SiteExtension.pkgproj" ^ - /bl:artifacts/log/SiteExtensions-Runtime-x86.binlog %* + "/bl:%RepoRoot%/artifacts/log/SiteExtensions-Runtime-x86.binlog" %* IF %ERRORLEVEL% NEQ 0 ( EXIT /b %ErrorLevel% ) @@ -19,14 +19,14 @@ ECHO Building x64 LoggingBranch REM /p:DisableTransitiveFrameworkReferences=true is needed to prevent SDK from picking up transitive references to REM Microsoft.AspNetCore.App as framework references https://github.com/dotnet/sdk/pull/3221 CALL "%RepoRoot%\build.cmd" -arch x64 -projects "%~dp0LoggingBranch\LB.csproj" ^ - /p:DisableTransitiveFrameworkReferences=true /bl:artifacts/log/SiteExtensions-LoggingBranch-x64.binlog %* + /p:DisableTransitiveFrameworkReferences=true "/bl:%RepoRoot%/artifacts/log/SiteExtensions-LoggingBranch-x64.binlog" %* IF %ERRORLEVEL% NEQ 0 ( EXIT /b %ErrorLevel% ) ECHO Building x86 LoggingBranch CALL "%RepoRoot%\build.cmd" -arch x86 -projects "%~dp0LoggingBranch\LB.csproj" ^ - /p:DisableTransitiveFrameworkReferences=true /bl:artifacts/log/SiteExtensions-LoggingBranch-x86.binlog %* + /p:DisableTransitiveFrameworkReferences=true "/bl:%RepoRoot%/artifacts/log/SiteExtensions-LoggingBranch-x86.binlog" %* IF %ERRORLEVEL% NEQ 0 ( EXIT /b %ErrorLevel% ) @@ -34,7 +34,7 @@ IF %ERRORLEVEL% NEQ 0 ( ECHO Building Microsoft.AspNetCore.AzureAppServices.SiteExtension CALL "%RepoRoot%\build.cmd" -projects ^ "%~dp0LoggingAggregate\src\Microsoft.AspNetCore.AzureAppServices.SiteExtension\Microsoft.AspNetCore.AzureAppServices.SiteExtension.csproj" ^ - /bl:artifacts/log/SiteExtensions-LoggingAggregate.binlog %* + "/bl:%RepoRoot%/artifacts/log/SiteExtensions-LoggingAggregate.binlog" %* IF %ERRORLEVEL% NEQ 0 ( EXIT /b %ErrorLevel% )