Skip to content

Commit 1eb05c2

Browse files
committed
Allow building with desktop msbuild only
1 parent bcd20ab commit 1eb05c2

File tree

4 files changed

+43
-30
lines changed

4 files changed

+43
-30
lines changed

eng/AfterSolutionBuild.targets

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<Project>
22

3+
<Import Project="SharedFramework.Local.props" />
34
<Import Project="tools\RepoTasks\RepoTasks.tasks" />
45
<Import Project="SharedFramework.External.props" />
5-
<Import Project="SharedFramework.Local.props" />
6+
<Import Project="Common.props" />
67

78
<!-- This is temporary until we can use FrameworkReference to build our own packages. -->
8-
<Target Name="RemoveSharedFrameworkOnlyRefsFromNuspec" AfterTargets="Pack"
9-
Condition=" '$(MSBuildRuntimeType)' == 'core' ">
9+
<Target Name="RemoveSharedFrameworkOnlyRefsFromNuspec" AfterTargets="Pack" Condition="'$(BuildManaged)' == 'true'">
1010
<ItemGroup>
1111
<_BuildOutput Include="$(ArtifactsShippingPackagesDir)*.nupkg"
1212
Exclude="$(ArtifactsShippingPackagesDir)*.symbols.nupkg" />

eng/Tools.props

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<Project>
2-
<!-- Update the generated files when we restore projects. Skip in desktop msbuild due to VS 16.8 requirements. -->
2+
<!-- Update the generated files when we restore projects. -->
33
<Target Name="GenerateDirectoryBuildFiles"
4-
AfterTargets="Restore"
5-
Condition=" '$(MSBuildRuntimeType)' == 'core' ">
4+
AfterTargets="Restore">
65
<!-- Separate invocations and use different properties to ensure second can load the restored package info. -->
76
<MSBuild Projects="$(RepoRoot)eng\tools\GenerateFiles\GenerateFiles.csproj"
87
RemoveProperties="BaseIntermediateOutputPath"

eng/build.ps1

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ param(
184184
[Alias('v')]
185185
[string]$Verbosity = 'minimal',
186186
[switch]$DumpProcesses, # Capture all running processes and dump them to a file.
187+
[string]$msbuildEngine = 'dotnet',
187188

188189
# Other lifecycle targets
189190
[switch]$Help, # Show help
@@ -288,24 +289,20 @@ if ($RuntimeSourceFeed -or $RuntimeSourceFeedKey) {
288289
}
289290

290291
# Split build categories between dotnet msbuild and desktop msbuild. Use desktop msbuild as little as possible.
291-
[string[]]$dotnetBuildArguments = $MSBuildArguments
292+
[string[]]$dotnetBuildArguments = ''
293+
[string[]]$MSBuildOnlyArguments = ''
294+
292295
if ($All) { $dotnetBuildArguments += '/p:BuildAllProjects=true' }
293-
if ($Projects) {
294-
if ($BuildNative) {
295-
$MSBuildArguments += "/p:ProjectToBuild=$Projects"
296-
} else {
297-
$dotnetBuildArguments += "/p:ProjectToBuild=$Projects"
298-
}
299-
}
296+
if ($Projects) { $MSBuildArguments += "/p:ProjectToBuild=$Projects" }
300297

301-
if ($NoBuildInstallers) { $MSBuildArguments += "/p:BuildInstallers=false"; $BuildInstallers = $false }
302-
if ($BuildInstallers) { $MSBuildArguments += "/p:BuildInstallers=true" }
298+
if ($NoBuildInstallers) { $MSBuildOnlyArguments += "/p:BuildInstallers=false"; $BuildInstallers = $false }
299+
if ($BuildInstallers) { $MSBuildOnlyArguments += "/p:BuildInstallers=true" }
303300

304301
# Build native projects by default unless -NoBuildNative was specified.
305302
$specifiedBuildNative = $BuildNative
306303
$BuildNative = $true
307-
if ($NoBuildNative) { $MSBuildArguments += "/p:BuildNative=false"; $BuildNative = $false }
308-
if ($BuildNative) { $MSBuildArguments += "/p:BuildNative=true"}
304+
if ($NoBuildNative) { $MSBuildOnlyArguments += "/p:BuildNative=false"; $BuildNative = $false }
305+
if ($BuildNative) { $MSBuildOnlyArguments += "/p:BuildNative=true"}
309306

310307
if ($NoBuildJava) { $dotnetBuildArguments += "/p:BuildJava=false"; $BuildJava = $false }
311308
if ($BuildJava) { $dotnetBuildArguments += "/p:BuildJava=true" }
@@ -317,23 +314,24 @@ if ($BuildNodeJS) { $dotnetBuildArguments += "/p:BuildNodeJSUnlessSourcebuild=tr
317314
# Don't bother with two builds if just one will build everything. Ignore super-weird cases like
318315
# "-Projects ... -NoBuildJava -NoBuildManaged -NoBuildNodeJS". An empty `./build.ps1` command will build both
319316
# managed and native projects.
320-
$performDesktopBuild = $BuildInstallers -or $BuildNative
321-
$performDotnetBuild = $BuildJava -or $BuildManaged -or $BuildNodeJS -or `
317+
318+
# If -msbuildEngine vs is explicitly passed in, use desktop msbuild only.
319+
# This is necessary for one-shot builds like within the VMR.
320+
321+
$performDesktopBuild = $BuildInstallers -or $BuildNative -or $msbuildEngine -eq 'vs'
322+
$performDotnetBuild = $msBuildEngine -ne 'vs' -and ($BuildJava -or $BuildManaged -or $BuildNodeJS -or `
322323
($All -and -not ($NoBuildJava -and $NoBuildManaged -and $NoBuildNodeJS)) -or `
323-
($Projects -and -not ($BuildInstallers -or $specifiedBuildNative))
324+
($Projects -and -not ($BuildInstallers -or $specifiedBuildNative)))
324325

325326
# Initialize global variables need to be set before the import of Arcade is imported
326327
$restore = $RunRestore
327328

328-
# Though VS Code may indicate $nodeReuse and $msbuildEngine are unused, tools.ps1 uses them.
329+
# Though VS Code may indicate $nodeReuse is unused, tools.ps1 uses them.
329330

330331
# Disable node reuse - Workaround perpetual issues in node reuse and custom task assemblies
331332
$nodeReuse = $false
332333
$env:MSBUILDDISABLENODEREUSE=1
333334

334-
# Use `dotnet msbuild` by default
335-
$msbuildEngine = 'dotnet'
336-
337335
# Ensure passing neither -bl nor -nobl on CI avoids errors in tools.ps1. This is needed because both parameters are
338336
# $false by default i.e. they always exist. (We currently avoid binary logs but that is made visible in the YAML.)
339337
if ($CI -and -not $excludeCIBinarylog) {
@@ -414,12 +412,17 @@ if ($BinaryLog) {
414412
$bl = GetMSBuildBinaryLogCommandLineArgument($MSBuildArguments)
415413
if (-not $bl) {
416414
$dotnetBuildArguments += "/bl:" + (Join-Path $LogDir "Build.binlog")
417-
$MSBuildArguments += "/bl:" + (Join-Path $LogDir "Build.native.binlog")
415+
416+
# When running both builds, use a different binary log path for the desktop msbuild.
417+
if ($performDesktopBuild -and $performDotnetBuild) {
418+
$MSBuildOnlyArguments += "/bl:" + (Join-Path $LogDir "Build.native.binlog")
419+
}
420+
418421
$ToolsetBuildArguments += "/bl:" + (Join-Path $LogDir "Build.repotasks.binlog")
419422
} else {
420423
# Use a different binary log path when running desktop msbuild if doing both builds.
421424
if ($performDesktopBuild -and $performDotnetBuild) {
422-
$MSBuildArguments += "/bl:" + [System.IO.Path]::ChangeExtension($bl, "native.binlog")
425+
$MSBuildOnlyArguments += "/bl:" + [System.IO.Path]::ChangeExtension($bl, "native.binlog")
423426
}
424427

425428
$ToolsetBuildArguments += "/bl:" + [System.IO.Path]::ChangeExtension($bl, "repotasks.binlog")
@@ -478,15 +481,20 @@ try {
478481
Remove-Item variable:global:_BuildTool -ErrorAction Ignore
479482
$msbuildEngine = 'vs'
480483

481-
MSBuild $toolsetBuildProj /p:RepoRoot=$RepoRoot @MSBuildArguments
484+
# When running with desktop msbuild only, append the dotnet build specific arguments.
485+
if (-not $performDotnetBuild) {
486+
$MSBuildOnlyArguments += $dotnetBuildArguments
487+
}
488+
489+
MSBuild $toolsetBuildProj /p:RepoRoot=$RepoRoot @MSBuildArguments @MSBuildOnlyArguments
482490
}
483491

484492
if ($performDotnetBuild) {
485493
Write-Host
486494
Remove-Item variable:global:_BuildTool -ErrorAction Ignore
487495
$msbuildEngine = 'dotnet'
488496

489-
MSBuild $toolsetBuildProj /p:RepoRoot=$RepoRoot @dotnetBuildArguments
497+
MSBuild $toolsetBuildProj /p:RepoRoot=$RepoRoot @MSBuildArguments @dotnetBuildArguments
490498
}
491499
}
492500
}

eng/tools/GenerateFiles/GenerateFiles.csproj

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@
1212
</ItemGroup>
1313

1414
<!-- Update artifacts/bin/GenerateFiles/Directory.Build.* files. -->
15-
<Target Name="GenerateDirectoryBuildFiles">
15+
<Target Name="GenerateDirectoryBuildFiles"
16+
Inputs="$(MSBuildThisFileDirectory)Directory.Build.props.in;
17+
$(MSBuildThisFileDirectory)Directory.Build.targets.in;
18+
$(ConfigDirectory)dotnet-tools.json"
19+
Outputs="$(BaseOutputPath)Directory.Build.props;
20+
$(BaseOutputPath)Directory.Build.targets;
21+
$(ConfigDirectory)dotnet-tools.json">
1622
<PropertyGroup>
1723
<_TemplateProperties>
1824
AspNetCorePatchVersion=$(AspNetCorePatchVersion);

0 commit comments

Comments
 (0)