From 2b7a3a222af721a8b6ab1cbe6a40594a4270a3d8 Mon Sep 17 00:00:00 2001 From: Justin Kotalik Date: Mon, 31 Dec 2018 10:54:15 -0800 Subject: [PATCH] Build Windows Installers using the repo's main build script and repotasks (#6139) Follow-up to #6078 This should solve race conditions in restoring .wixproj files. Co-authored-by: Nate McMaster Co-authored-by: Justin Kotalik --- Directory.Build.props | 11 +++++ build.ps1 | 8 +++- build/repo.props | 29 +++++++++++ .../tasks}/GenerateGuid.cs | 0 .../tasks}/GetMsiProperty.cs | 2 + build/tasks/RepoTasks.csproj | 12 +++++ build/tasks/RepoTasks.tasks | 2 + .../InstallerTasks => build/tasks}/Uuid.cs | 0 eng/scripts/common.psm1 | 48 ------------------- eng/targets/Wix.Common.props | 2 +- eng/targets/Wix.Common.targets | 1 - src/Framework/pkg/Metapackage.targets | 2 - src/Framework/src/SharedFx.targets | 2 - .../ANCMPackageResolver.csproj | 14 +++--- .../Directory.Build.props | 3 ++ src/Installers/Windows/Directory.Build.props | 9 +--- .../Windows/Directory.Build.targets | 2 +- .../InstallerTasks/InstallerTasks.csproj | 23 --------- src/Installers/Windows/Installers.sln | 14 ------ .../WindowsHostingBundle/Product.targets | 6 +-- src/Installers/Windows/WindowsInstallers.proj | 45 ----------------- src/Installers/Windows/Wix.targets | 2 - src/Installers/Windows/build.ps1 | 42 +++------------- src/SiteExtensions/Directory.Build.props | 9 ++-- .../LoggingBranch/Directory.Build.targets | 2 - .../Runtime/Directory.Build.targets | 2 - ...t.AspNetCore.Runtime.SiteExtension.pkgproj | 2 +- src/Tools/Directory.Build.props | 7 ++- 28 files changed, 92 insertions(+), 209 deletions(-) rename {src/Installers/Windows/InstallerTasks => build/tasks}/GenerateGuid.cs (100%) rename {src/Installers/Windows/InstallerTasks => build/tasks}/GetMsiProperty.cs (97%) rename {src/Installers/Windows/InstallerTasks => build/tasks}/Uuid.cs (100%) delete mode 100644 src/Installers/Windows/InstallerTasks/InstallerTasks.csproj delete mode 100644 src/Installers/Windows/WindowsInstallers.proj diff --git a/Directory.Build.props b/Directory.Build.props index 43fb9fcfd1..e255df9e9a 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -87,6 +87,15 @@ $(ArtifactsConfigurationDir)installers\ + + $(RepositoryRoot)bin\$(Configuration)\$(MSBuildProjectName)\ + $(BaseOutputPath) + $(RepositoryRoot)obj\$(MSBuildProjectName)\ + $(BaseIntermediateOutputPath)$(Configuration)\ + $(OutputPath)$(Platform)\ + $(IntermediateOutputPath)$(Platform)\ + + $([MSBuild]::MakeRelative($(RepositoryRoot), $(MSBuildProjectDirectory))) @@ -97,6 +106,8 @@ true + + diff --git a/build.ps1 b/build.ps1 index 3214fbf70b..cf66e3eacd 100644 --- a/build.ps1 +++ b/build.ps1 @@ -45,6 +45,9 @@ Build native projects (C++). .PARAMETER NodeJS Build NodeJS projects (TypeScript, JS). +.PARAMETER Installers +Build Windows Installers. Required .NET 3.5 to be installed (WiX toolset requirement). + .PARAMETER MSBuildArguments Additional MSBuild arguments to be passed through. @@ -96,6 +99,8 @@ param( [switch]$Native, [Parameter(ParameterSetName = 'Groups')] [switch]$NodeJS, + [Parameter(ParameterSetName = 'Groups')] + [switch]$Installers, # Other lifecycle targets [switch]$Help, # Show help @@ -236,7 +241,7 @@ elseif ($Projects) { } else { # When adding new sub-group build flags, add them to this check. - if((-not $Native) -and (-not $Managed) -and (-not $NodeJS)) { + if((-not $Native) -and (-not $Managed) -and (-not $NodeJS) -and (-not $Installers)) { Write-Warning "No default group of projects was specified, so building the 'managed' subset 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. @@ -248,6 +253,7 @@ else { $MSBuildArguments += "/p:BuildManaged=$Managed" $MSBuildArguments += "/p:BuildNative=$Native" $MSBuildArguments += "/p:BuildNodeJS=$NodeJS" + $MSBuildArguments += "/p:BuildWindowsInstallers=$Installers" } # Target selection diff --git a/build/repo.props b/build/repo.props index 798b27743e..10d5859796 100644 --- a/build/repo.props +++ b/build/repo.props @@ -64,6 +64,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Installers/Windows/InstallerTasks/GenerateGuid.cs b/build/tasks/GenerateGuid.cs similarity index 100% rename from src/Installers/Windows/InstallerTasks/GenerateGuid.cs rename to build/tasks/GenerateGuid.cs diff --git a/src/Installers/Windows/InstallerTasks/GetMsiProperty.cs b/build/tasks/GetMsiProperty.cs similarity index 97% rename from src/Installers/Windows/InstallerTasks/GetMsiProperty.cs rename to build/tasks/GetMsiProperty.cs index 90f3cd3d24..182a5f0af3 100644 --- a/src/Installers/Windows/InstallerTasks/GetMsiProperty.cs +++ b/build/tasks/GetMsiProperty.cs @@ -1,3 +1,4 @@ +#if BUILD_MSI_TASKS // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. @@ -36,3 +37,4 @@ namespace RepoTasks } } } +#endif diff --git a/build/tasks/RepoTasks.csproj b/build/tasks/RepoTasks.csproj index 17c9981497..f0b7d88273 100644 --- a/build/tasks/RepoTasks.csproj +++ b/build/tasks/RepoTasks.csproj @@ -4,6 +4,7 @@ netcoreapp2.1 net461 + $(DefineConstants);BUILD_MSI_TASKS @@ -13,5 +14,16 @@ + + + + + $(WiXSdkPath)\Microsoft.Deployment.WindowsInstaller.dll + + + $(WiXSdkPath)\Microsoft.Deployment.WindowsInstaller.Package.dll + + + diff --git a/build/tasks/RepoTasks.tasks b/build/tasks/RepoTasks.tasks index c99d93e1c3..17919c3e90 100644 --- a/build/tasks/RepoTasks.tasks +++ b/build/tasks/RepoTasks.tasks @@ -4,6 +4,8 @@ + + diff --git a/src/Installers/Windows/InstallerTasks/Uuid.cs b/build/tasks/Uuid.cs similarity index 100% rename from src/Installers/Windows/InstallerTasks/Uuid.cs rename to build/tasks/Uuid.cs diff --git a/eng/scripts/common.psm1 b/eng/scripts/common.psm1 index 3a31f2a023..96544dc6f2 100644 --- a/eng/scripts/common.psm1 +++ b/eng/scripts/common.psm1 @@ -52,54 +52,6 @@ function LoadXml([string]$path) { return $obj } -function Get-MSBuildPath { - param( - [switch]$Prerelease, - [string[]]$Requires - ) - - $vsInstallDir = $null - if ($env:VSINSTALLDIR -and (Test-Path $env:VSINSTALLDIR)) { - $vsInstallDir = $env:VSINSTALLDIR - Write-Verbose "Using VSINSTALLDIR=$vsInstallDir" - } - else { - $vswhere = "${env:ProgramFiles(x86)}/Microsoft Visual Studio/Installer/vswhere.exe" - Write-Verbose "Using vswhere.exe from $vswhere" - - if (-not (Test-Path $vswhere)) { - Write-Error "Missing prerequisite: could not find vswhere" - } - - [string[]] $vswhereArgs = @() - - if ($Prerelease) { - $vswhereArgs += '-prerelease' - } - - if ($Requires) { - foreach ($r in $Requires) { - $vswhereArgs += '-requires', $r - } - } - - $installs = & $vswhere -format json -version '[15.0, 16.0)' -latest -products * @vswhereArgs | ConvertFrom-Json - if (!$installs) { - Write-Error "Missing prerequisite: could not find any installations of Visual Studio" - } - - $vs = $installs | Select-Object -First 1 - $vsInstallDir = $vs.installationPath - Write-Host "Using $($vs.displayName)" - } - - $msbuild = Join-Path $vsInstallDir 'MSBuild/15.0/bin/msbuild.exe' - if (!(Test-Path $msbuild)) { - Write-Error "Missing prerequisite: could not find msbuild.exe" - } - return $msbuild -} - function Get-RemoteFile([string]$RemotePath, [string]$LocalPath) { if ($RemotePath -notlike 'http*') { Copy-Item $RemotePath $LocalPath diff --git a/eng/targets/Wix.Common.props b/eng/targets/Wix.Common.props index 47e291d5b8..9875352599 100644 --- a/eng/targets/Wix.Common.props +++ b/eng/targets/Wix.Common.props @@ -12,7 +12,7 @@ net461 $(BaseIntermediateOutputPath) $(MSBuildProjectDir)\obj\ - + $(MSBuildToolsPath32)\..\..\..\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets $(MSBuildToolsPath)\NuGet.targets diff --git a/eng/targets/Wix.Common.targets b/eng/targets/Wix.Common.targets index 3cdb0c3b86..7ff9e39fd6 100644 --- a/eng/targets/Wix.Common.targets +++ b/eng/targets/Wix.Common.targets @@ -41,5 +41,4 @@ - diff --git a/src/Framework/pkg/Metapackage.targets b/src/Framework/pkg/Metapackage.targets index 365eacc8fa..6307d33621 100644 --- a/src/Framework/pkg/Metapackage.targets +++ b/src/Framework/pkg/Metapackage.targets @@ -38,8 +38,6 @@ - - diff --git a/src/Framework/src/SharedFx.targets b/src/Framework/src/SharedFx.targets index 17c1ddc1b2..9027f74b31 100644 --- a/src/Framework/src/SharedFx.targets +++ b/src/Framework/src/SharedFx.targets @@ -4,8 +4,6 @@ This targets file should only be imported by .shfxproj files. --> - - $(MSBuildAllProjects);$(MSBuildThisFileFullPath) diff --git a/src/Installers/Windows/AspNetCoreModule-Setup/ANCMPackageResolver/ANCMPackageResolver.csproj b/src/Installers/Windows/AspNetCoreModule-Setup/ANCMPackageResolver/ANCMPackageResolver.csproj index c585d69ae2..16cace9755 100644 --- a/src/Installers/Windows/AspNetCoreModule-Setup/ANCMPackageResolver/ANCMPackageResolver.csproj +++ b/src/Installers/Windows/AspNetCoreModule-Setup/ANCMPackageResolver/ANCMPackageResolver.csproj @@ -1,4 +1,6 @@ - + + + netstandard1.0 true @@ -14,14 +16,10 @@ - $(RepositoryRoot).deps\ANCM; - - $(RestoreSources); - https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json; - https://api.nuget.org/v3/index.json; - https://dotnet.myget.org/F/dotnet-core/api/v3/index.json; + $(RepositoryRoot).deps\ANCM; - + + diff --git a/src/Installers/Windows/AspNetCoreModule-Setup/Directory.Build.props b/src/Installers/Windows/AspNetCoreModule-Setup/Directory.Build.props index 4b9d69aa1d..ada3840cee 100644 --- a/src/Installers/Windows/AspNetCoreModule-Setup/Directory.Build.props +++ b/src/Installers/Windows/AspNetCoreModule-Setup/Directory.Build.props @@ -3,6 +3,9 @@ + $(PackageVersion) + $(PackageVersion) + <_TwoDigitYear>$([MSBuild]::Subtract($([System.DateTime]::UtcNow.Year), 2000)) <_ThreeDigitDayOfYear>$([System.DateTime]::UtcNow.DayOfYear.ToString().PadLeft(3, '0')) diff --git a/src/Installers/Windows/Directory.Build.props b/src/Installers/Windows/Directory.Build.props index 6a33e27c7d..641ea3aa93 100644 --- a/src/Installers/Windows/Directory.Build.props +++ b/src/Installers/Windows/Directory.Build.props @@ -1,13 +1,8 @@ - $([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)..\..\..\')) - $(RepositoryRoot)artifacts\$(Configuration)\installers\ - $(RepositoryRoot)bin\$(Configuration)\$(MSBuildProjectName)\ - $(BaseOutputPath) - $(RepositoryRoot)obj\$(MSBuildProjectName)\ - $(BaseIntermediateOutputPath)$(Configuration)\ - $(IntermediateOutputPath)$(Platform)\ + true + true diff --git a/src/Installers/Windows/Directory.Build.targets b/src/Installers/Windows/Directory.Build.targets index 8dc63cace9..b5cebea51b 100644 --- a/src/Installers/Windows/Directory.Build.targets +++ b/src/Installers/Windows/Directory.Build.targets @@ -1,4 +1,4 @@ - + diff --git a/src/Installers/Windows/InstallerTasks/InstallerTasks.csproj b/src/Installers/Windows/InstallerTasks/InstallerTasks.csproj deleted file mode 100644 index a6d3ce18f1..0000000000 --- a/src/Installers/Windows/InstallerTasks/InstallerTasks.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - net461 - false - false - - - - - - - - - - $(WiXSdkPath)\Microsoft.Deployment.WindowsInstaller.dll - - - $(WiXSdkPath)\Microsoft.Deployment.WindowsInstaller.Package.dll - - - - diff --git a/src/Installers/Windows/Installers.sln b/src/Installers/Windows/Installers.sln index 0572e5d0ee..b34c18e8de 100644 --- a/src/Installers/Windows/Installers.sln +++ b/src/Installers/Windows/Installers.sln @@ -25,8 +25,6 @@ Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "WindowsHostingBundle", "Win EndProject Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "SharedFramework", "SharedFramework\SharedFramework.wixproj", "{C681D730-4505-42C6-9E6C-87F757C4FB32}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InstallerTasks", "InstallerTasks\InstallerTasks.csproj", "{D58277B2-4C1F-46D6-B9E1-845C711E3B55}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -131,18 +129,6 @@ Global {C681D730-4505-42C6-9E6C-87F757C4FB32}.Release|x64.ActiveCfg = Release|x86 {C681D730-4505-42C6-9E6C-87F757C4FB32}.Release|x86.ActiveCfg = Release|x86 {C681D730-4505-42C6-9E6C-87F757C4FB32}.Release|x86.Build.0 = Release|x86 - {D58277B2-4C1F-46D6-B9E1-845C711E3B55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D58277B2-4C1F-46D6-B9E1-845C711E3B55}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D58277B2-4C1F-46D6-B9E1-845C711E3B55}.Debug|x64.ActiveCfg = Debug|Any CPU - {D58277B2-4C1F-46D6-B9E1-845C711E3B55}.Debug|x64.Build.0 = Debug|Any CPU - {D58277B2-4C1F-46D6-B9E1-845C711E3B55}.Debug|x86.ActiveCfg = Debug|Any CPU - {D58277B2-4C1F-46D6-B9E1-845C711E3B55}.Debug|x86.Build.0 = Debug|Any CPU - {D58277B2-4C1F-46D6-B9E1-845C711E3B55}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D58277B2-4C1F-46D6-B9E1-845C711E3B55}.Release|Any CPU.Build.0 = Release|Any CPU - {D58277B2-4C1F-46D6-B9E1-845C711E3B55}.Release|x64.ActiveCfg = Release|Any CPU - {D58277B2-4C1F-46D6-B9E1-845C711E3B55}.Release|x64.Build.0 = Release|Any CPU - {D58277B2-4C1F-46D6-B9E1-845C711E3B55}.Release|x86.ActiveCfg = Release|Any CPU - {D58277B2-4C1F-46D6-B9E1-845C711E3B55}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Installers/Windows/WindowsHostingBundle/Product.targets b/src/Installers/Windows/WindowsHostingBundle/Product.targets index c91339b2c9..36f4cb8cd9 100644 --- a/src/Installers/Windows/WindowsHostingBundle/Product.targets +++ b/src/Installers/Windows/WindowsHostingBundle/Product.targets @@ -19,7 +19,7 @@ - + https://dotnetcli.azureedge.net/dotnet/ $(DotNetAssetRootUrl)/ @@ -40,9 +40,7 @@ SourceUrl="%(RemoteAsset.Identity)" DestinationFolder="$(DepsPath)" DestinationFileName="%(RemoteAsset.TargetFileName)" /> - - - + diff --git a/src/Installers/Windows/WindowsInstallers.proj b/src/Installers/Windows/WindowsInstallers.proj deleted file mode 100644 index 5337f23dba..0000000000 --- a/src/Installers/Windows/WindowsInstallers.proj +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Installers/Windows/Wix.targets b/src/Installers/Windows/Wix.targets index d4504f10c3..1ceda1d5a5 100644 --- a/src/Installers/Windows/Wix.targets +++ b/src/Installers/Windows/Wix.targets @@ -10,8 +10,6 @@ $(GuidInputs);$(BuildNumberSuffix) - - diff --git a/src/Installers/Windows/build.ps1 b/src/Installers/Windows/build.ps1 index 5b64363f40..252e850d37 100644 --- a/src/Installers/Windows/build.ps1 +++ b/src/Installers/Windows/build.ps1 @@ -1,7 +1,3 @@ -# -# This script requires internal-only access to the code which generates ANCM installers. -# - #requires -version 5 [cmdletbinding()] param( @@ -14,20 +10,20 @@ param( [string]$Runtime64Zip, [string]$BuildNumber = 't000', [switch]$IsFinalBuild, - [string]$SignType = '', - [switch]$clean + [string]$SignType = '' ) $ErrorActionPreference = 'Stop' $repoRoot = Resolve-Path "$PSScriptRoot/../../../" Import-Module -Scope Local "$repoRoot/eng/scripts/common.psm1" -Force -$msbuild = Get-MSBuildPath -Prerelease -requires 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64' $harvestRoot = "$repoRoot/obj/sfx/" if ($clean) { Remove-Item -Recurse -Force $harvestRoot -ErrorAction Ignore | Out-Null } +# TODO: harvest shared frameworks from a project reference + New-Item "$harvestRoot/x86", "$harvestRoot/x64" -ItemType Directory -ErrorAction Ignore | Out-Null if (-not (Test-Path "$harvestRoot/x86/shared/")) { @@ -40,40 +36,14 @@ if (-not (Test-Path "$harvestRoot/x64/shared/")) { Push-Location $PSScriptRoot try { - Invoke-Block { & $msbuild ` - InstallerTasks/InstallerTasks.csproj ` - -nologo ` - -m ` - -v:m ` - -nodeReuse:false ` - -restore ` - -t:Build ` - "-p:Configuration=$Configuration" - } - - [string[]] $msbuildArgs = @() - - if ($clean) { - $msbuildArgs += '-t:Clean' - } - - Invoke-Block { & $msbuild ` - WindowsInstallers.proj ` - -restore ` - -nologo ` - -m ` - -v:m ` - -nodeReuse:false ` - -clp:Summary ` + & $repoRoot/build.ps1 ` + -Installers ` "-p:SharedFrameworkHarvestRootPath=$repoRoot/obj/sfx/" ` "-p:Configuration=$Configuration" ` "-p:BuildNumberSuffix=$BuildNumber" ` "-p:SignType=$SignType" ` "-p:IsFinalBuild=$IsFinalBuild" ` - "-bl:$repoRoot/artifacts/logs/installers.msbuild.binlog" ` - '-t:Build' ` - @msbuildArgs - } + "-bl:$repoRoot/artifacts/logs/installers.msbuild.binlog" } finally { Pop-Location diff --git a/src/SiteExtensions/Directory.Build.props b/src/SiteExtensions/Directory.Build.props index 51a165b974..574418ea36 100644 --- a/src/SiteExtensions/Directory.Build.props +++ b/src/SiteExtensions/Directory.Build.props @@ -1,8 +1,7 @@ - - - $(RepositoryRoot)obj\$(MSBuildProjectName)\ - $(RepositoryRoot)bin\$(MSBuildProjectName)\ + true - \ No newline at end of file + + + diff --git a/src/SiteExtensions/LoggingBranch/Directory.Build.targets b/src/SiteExtensions/LoggingBranch/Directory.Build.targets index 920f1867f5..df33ae31f1 100644 --- a/src/SiteExtensions/LoggingBranch/Directory.Build.targets +++ b/src/SiteExtensions/LoggingBranch/Directory.Build.targets @@ -30,6 +30,4 @@ - - diff --git a/src/SiteExtensions/Runtime/Directory.Build.targets b/src/SiteExtensions/Runtime/Directory.Build.targets index 7e0b4cf398..661159ab76 100644 --- a/src/SiteExtensions/Runtime/Directory.Build.targets +++ b/src/SiteExtensions/Runtime/Directory.Build.targets @@ -30,8 +30,6 @@ - - diff --git a/src/SiteExtensions/Runtime/Microsoft.AspNetCore.Runtime.SiteExtension.pkgproj b/src/SiteExtensions/Runtime/Microsoft.AspNetCore.Runtime.SiteExtension.pkgproj index 758794431b..fb9cd35046 100644 --- a/src/SiteExtensions/Runtime/Microsoft.AspNetCore.Runtime.SiteExtension.pkgproj +++ b/src/SiteExtensions/Runtime/Microsoft.AspNetCore.Runtime.SiteExtension.pkgproj @@ -19,7 +19,7 @@ - + diff --git a/src/Tools/Directory.Build.props b/src/Tools/Directory.Build.props index 0cbe48018a..b4dcdb53d4 100644 --- a/src/Tools/Directory.Build.props +++ b/src/Tools/Directory.Build.props @@ -1,10 +1,9 @@ - - - $(RepositoryRoot)obj\$(MSBuildProjectName)\ - $(RepositoryRoot)bin\$(MSBuildProjectName)\ + true $(MSBuildThisFileDirectory)Shared\ + +