Skip to content

Commit e778af9

Browse files
ViktorHoferwtgodbe
andauthored
Build installers at the end of the repo build and allow building with desktop msbuild (dotnet#58987)
* Condition SharedFrameworkBundle correctly and remove an incorrect warnings * Build updates * Use Aracade's BuildStep metadata * Condition installers correctly * Update buildstep metadata * Update eng/Build.props Co-authored-by: William Godbe <[email protected]> * Update Build.props --------- Co-authored-by: William Godbe <[email protected]>
1 parent 0ec0fe2 commit e778af9

File tree

9 files changed

+137
-109
lines changed

9 files changed

+137
-109
lines changed

eng/AfterSolutionBuild.targets

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

3+
<Import Project="Common.props" />
34
<Import Project="tools\RepoTasks\RepoTasks.tasks" />
45
<Import Project="SharedFramework.External.props" />
56
<Import Project="SharedFramework.Local.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/Build.props

Lines changed: 88 additions & 72 deletions
Large diffs are not rendered by default.

eng/Npm.Workspace.FunctionalTests.nodeproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project>
1+
<Project DefaultTargets="Build">
22

33
<!-- Import Directory.Build.Props -->
44
<Import Project="$(MSBuildThisFileDirectory)..\Directory.Build.props" />

eng/Npm.Workspace.nodeproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project>
1+
<Project DefaultTargets="Build">
22

33
<!-- Import Directory.Build.Props -->
44
<Import Project="$(MSBuildThisFileDirectory)..\Directory.Build.props" />

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/targets/ResolveReferences.targets

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,6 @@
227227
Condition=" '@(PackageReference->HasMetadata('Private')->Count())' != '0' "
228228
Code="BUILD004"
229229
Text="%25(Private) metadata should not be applied to the %(Identity) package reference. Did you mean %25(PrivateAssets)?" />
230-
<Warning
231-
Condition=" '@(ProjectReference->HasMetadata('PrivateAssets')->Count())' != '0' "
232-
Code="BUILD005"
233-
Text="%25(PrivateAssets) metadata should not be applied to the %(Identity) project reference. Did you mean %25(Private)?" />
234230
<Warning
235231
Condition=" '@(Reference->HasMetadata('PrivateAssets')->Count())' != '0' "
236232
Code="BUILD006"

eng/tools/GenerateFiles/GenerateFiles.csproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
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+
Outputs="$(BaseOutputPath)Directory.Build.props;
19+
$(BaseOutputPath)Directory.Build.targets;
20+
$(ConfigDirectory)dotnet-tools.json">
1621
<PropertyGroup>
1722
<_TemplateProperties>
1823
AspNetCorePatchVersion=$(AspNetCorePatchVersion);

src/Installers/Windows/SharedFrameworkBundle/SharedFrameworkBundle.wixproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,17 @@
4646
</When>
4747
<Otherwise>
4848
<ItemGroup>
49-
<ProjectReference Include="..\SharedFrameworkLib\SharedFrameworkLib.wixproj" SetPlatform="Platform=x86">
49+
<ProjectReference Include="..\SharedFrameworkLib\SharedFrameworkLib.wixproj"
50+
SetPlatform="Platform=x86"
51+
Condition="'$(DotNetBuild)' != 'true' or '$(Platform)' == 'Win32'">
5052
<Name>SharedFrameworkLib</Name>
5153
<Project>{5244BC49-2568-4701-80A6-EAB8950AB5FA}</Project>
5254
<Private>True</Private>
5355
<DoNotHarvest>True</DoNotHarvest>
5456
</ProjectReference>
55-
<ProjectReference Include="..\SharedFrameworkLib\SharedFrameworkLib.wixproj" SetPlatform="Platform=x64">
57+
<ProjectReference Include="..\SharedFrameworkLib\SharedFrameworkLib.wixproj"
58+
SetPlatform="Platform=x64"
59+
Condition="'$(DotNetBuild)' != 'true' or '$(Platform)' == 'x64'">
5660
<Name>SharedFrameworkLib</Name>
5761
<Project>{5244BC49-2568-4701-80A6-EAB8950AB5FA}</Project>
5862
<Private>True</Private>

0 commit comments

Comments
 (0)