Build native assets by default (#22611)

* Build native assets by default
  - #22556
  - make `-BuildNative` primarily useful when you want _only_ native assets
    - can also build `-Projects` with desktop `msbuild` using `-BuildNative`
  - remove `-ForceCoreMsbuild` option
  nit: extra `Remove-Item`s caused `MSBuild` function to do redundant work

* !fixup! Get `/bl` options working again
  nit: Place SiteExtensions .binlogs correctly wherever script is run from
* !fixup! Remove *.vcxproj from Servers build
  - native projects are built implicitly
* !fixup! Remove `-buildNative` from IIS build script
This commit is contained in:
Doug Bunting 2020-06-08 12:39:10 -07:00 committed by GitHub
parent eb33b9657b
commit ee80cd5ccd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 46 additions and 30 deletions

View File

@ -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'

View File

@ -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'

View File

@ -1,3 +1,3 @@
@ECHO OFF
SET RepoRoot=%~dp0..\..\..
%RepoRoot%\build.cmd -BuildNative -projects %~dp0**\*.csproj %*
%RepoRoot%\build.cmd -projects %~dp0**\*.csproj %*

View File

@ -1,3 +1,3 @@
@ECHO OFF
SET RepoRoot=%~dp0..\..
%RepoRoot%\build.cmd -projects %~dp0**\*.*proj %*
%RepoRoot%\build.cmd -projects %~dp0**\*.csproj %*

View File

@ -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%
)