Skip to content

Commit 2b7a3a2

Browse files
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 <natemcmaster@users.noreply.github.com> Co-authored-by: Justin Kotalik <jkotalik@users.noreply.github.com>
1 parent 4816bdc commit 2b7a3a2

28 files changed

+92
-209
lines changed

Directory.Build.props

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@
8787
<InstallersOutputPath>$(ArtifactsConfigurationDir)installers\</InstallersOutputPath>
8888
</PropertyGroup>
8989

90+
<PropertyGroup Condition=" '$(OutputInRepoRoot)' == 'true' ">
91+
<BaseOutputPath>$(RepositoryRoot)bin\$(Configuration)\$(MSBuildProjectName)\</BaseOutputPath>
92+
<OutputPath>$(BaseOutputPath)</OutputPath>
93+
<BaseIntermediateOutputPath>$(RepositoryRoot)obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
94+
<IntermediateOutputPath>$(BaseIntermediateOutputPath)$(Configuration)\</IntermediateOutputPath>
95+
<OutputPath Condition=" '$(AppendPlatformToOutputPath)' == 'true' AND '$(Platform)' != '' AND '$(Platform)' != 'AnyCPU' ">$(OutputPath)$(Platform)\</OutputPath>
96+
<IntermediateOutputPath Condition=" '$(AppendPlatformToOutputPath)' == 'true' AND '$(Platform)' != '' AND '$(Platform)' != 'AnyCPU' ">$(IntermediateOutputPath)$(Platform)\</IntermediateOutputPath>
97+
</PropertyGroup>
98+
9099
<!-- Defines project type conventions. -->
91100
<PropertyGroup>
92101
<RepoRelativeProjectDir>$([MSBuild]::MakeRelative($(RepositoryRoot), $(MSBuildProjectDirectory)))</RepoRelativeProjectDir>
@@ -97,6 +106,8 @@
97106
<IsSampleProject Condition="$(RepoRelativeProjectDir.Contains('sample'))">true</IsSampleProject>
98107
</PropertyGroup>
99108

109+
<Import Project="build\tasks\RepoTasks.tasks" Condition="'$(MSBuildProjectName)' != 'RepoTasks'" />
110+
100111
<Import Project="eng\Dependencies.props" />
101112
<Import Project="eng\PatchConfig.props" />
102113
<Import Project="eng\ProjectReferences.props" />

build.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ Build native projects (C++).
4545
.PARAMETER NodeJS
4646
Build NodeJS projects (TypeScript, JS).
4747
48+
.PARAMETER Installers
49+
Build Windows Installers. Required .NET 3.5 to be installed (WiX toolset requirement).
50+
4851
.PARAMETER MSBuildArguments
4952
Additional MSBuild arguments to be passed through.
5053
@@ -96,6 +99,8 @@ param(
9699
[switch]$Native,
97100
[Parameter(ParameterSetName = 'Groups')]
98101
[switch]$NodeJS,
102+
[Parameter(ParameterSetName = 'Groups')]
103+
[switch]$Installers,
99104

100105
# Other lifecycle targets
101106
[switch]$Help, # Show help
@@ -236,7 +241,7 @@ elseif ($Projects) {
236241
}
237242
else {
238243
# When adding new sub-group build flags, add them to this check.
239-
if((-not $Native) -and (-not $Managed) -and (-not $NodeJS)) {
244+
if((-not $Native) -and (-not $Managed) -and (-not $NodeJS) -and (-not $Installers)) {
240245
Write-Warning "No default group of projects was specified, so building the 'managed' subset of projects. Run ``build.cmd -help`` for more details."
241246

242247
# This goal of this is to pick a sensible default for `build.cmd` with zero arguments.
@@ -248,6 +253,7 @@ else {
248253
$MSBuildArguments += "/p:BuildManaged=$Managed"
249254
$MSBuildArguments += "/p:BuildNative=$Native"
250255
$MSBuildArguments += "/p:BuildNodeJS=$NodeJS"
256+
$MSBuildArguments += "/p:BuildWindowsInstallers=$Installers"
251257
}
252258

253259
# Target selection

build/repo.props

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,35 @@
6464
</ItemGroup>
6565
</When>
6666
<Otherwise>
67+
<ItemGroup Condition=" '$(BuildWindowsInstallers)' == 'true' ">
68+
<ProjectToBuild Include="$(RepositoryRoot)src/Installers/Windows/AspNetCoreModule-Setup/ANCMPackageResolver/ANCMPackageResolver.csproj" />
69+
70+
<!-- Build the ANCM custom action -->
71+
<ProjectToBuild Include="$(RepositoryRoot)src/Installers/Windows/AspNetCoreModule-Setup/CustomAction/aspnetcoreCA.vcxproj" AdditionalProperties="Platform=x64" />
72+
<ProjectToBuild Include="$(RepositoryRoot)src/Installers/Windows/AspNetCoreModule-Setup/CustomAction/aspnetcoreCA.vcxproj" AdditionalProperties="Platform=x86" />
73+
74+
<!-- Build the ANCM msis -->
75+
<ProjectToBuild Include="$(RepositoryRoot)src/Installers/Windows/AspNetCoreModule-Setup/ANCMIISExpressV1/AncmIISExpressV1.wixproj" AdditionalProperties="Platform=x64" />
76+
<ProjectToBuild Include="$(RepositoryRoot)src/Installers/Windows/AspNetCoreModule-Setup/ANCMIISExpressV1/AncmIISExpressV1.wixproj" AdditionalProperties="Platform=x86" />
77+
<ProjectToBuild Include="$(RepositoryRoot)src/Installers/Windows/AspNetCoreModule-Setup/ANCMIISExpressV2/AncmIISExpressV2.wixproj" AdditionalProperties="Platform=x64" />
78+
<ProjectToBuild Include="$(RepositoryRoot)src/Installers/Windows/AspNetCoreModule-Setup/ANCMIISExpressV2/AncmIISExpressV2.wixproj" AdditionalProperties="Platform=x86" />
79+
<ProjectToBuild Include="$(RepositoryRoot)src/Installers/Windows/AspNetCoreModule-Setup/ANCMV1/ANCMV1.wixproj" AdditionalProperties="Platform=x64" />
80+
<ProjectToBuild Include="$(RepositoryRoot)src/Installers/Windows/AspNetCoreModule-Setup/ANCMV1/ANCMV1.wixproj" AdditionalProperties="Platform=x86" />
81+
<ProjectToBuild Include="$(RepositoryRoot)src/Installers/Windows/AspNetCoreModule-Setup/ANCMV2/ANCMV2.wixproj" AdditionalProperties="Platform=x64" />
82+
<ProjectToBuild Include="$(RepositoryRoot)src/Installers/Windows/AspNetCoreModule-Setup/ANCMV2/ANCMV2.wixproj" AdditionalProperties="Platform=x86" />
83+
84+
<!-- Build the SharedFramework installers -->
85+
<ProjectToBuild Include="$(RepositoryRoot)src/Installers/Windows/SharedFrameworkBundle/SharedFrameworkBundle.wixproj" AdditionalProperties="Platform=x64" />
86+
<ProjectToBuild Include="$(RepositoryRoot)src/Installers/Windows/SharedFrameworkBundle/SharedFrameworkBundle.wixproj" AdditionalProperties="Platform=x86" />
87+
88+
<!-- Build the SharedFramework wixlib -->
89+
<ProjectToBuild Include="$(RepositoryRoot)src/Installers/Windows/SharedFrameworkLib/SharedFrameworkLib.wixproj" AdditionalProperties="Platform=x64" />
90+
<ProjectToBuild Include="$(RepositoryRoot)src/Installers/Windows/SharedFrameworkLib/SharedFrameworkLib.wixproj" AdditionalProperties="Platform=x86" />
91+
92+
<!-- Windows hosting bundled -->
93+
<ProjectToBuild Include="$(RepositoryRoot)src/Installers/Windows/WindowsHostingBundle/WindowsHostingBundle.wixproj" AdditionalProperties="Platform=x86" />
94+
</ItemGroup>
95+
6796
<ItemGroup>
6897
<NpmProjectDirectory Include="$(RepositoryRoot)src\Middleware\CORS\test\FunctionalTests\" />
6998

src/Installers/Windows/InstallerTasks/GetMsiProperty.cs renamed to build/tasks/GetMsiProperty.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if BUILD_MSI_TASKS
12
// Copyright (c) .NET Foundation. All rights reserved.
23
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
34

@@ -36,3 +37,4 @@ public override bool Execute()
3637
}
3738
}
3839
}
40+
#endif

build/tasks/RepoTasks.csproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<PropertyGroup>
55
<TargetFramework Condition="'$(MSBuildRuntimeType)' == 'Core' ">netcoreapp2.1</TargetFramework>
66
<TargetFramework Condition="'$(MSBuildRuntimeType)' != 'Core' ">net461</TargetFramework>
7+
<DefineConstants Condition="'$(BuildWindowsInstallers)' == 'true'">$(DefineConstants);BUILD_MSI_TASKS</DefineConstants>
78
</PropertyGroup>
89

910
<ItemGroup>
@@ -13,5 +14,16 @@
1314
<PackageReference Include="WindowsAzure.Storage" Version="$(DevDependency_WindowsAzureStoragePackageVersion)" />
1415
</ItemGroup>
1516

17+
<ItemGroup Condition="'$(BuildWindowsInstallers)' == 'true'">
18+
<PackageReference Include="Wix" Version="3.11.1" />
19+
20+
<Reference Include="Microsoft.Deployment.WindowsInstaller">
21+
<HintPath>$(WiXSdkPath)\Microsoft.Deployment.WindowsInstaller.dll</HintPath>
22+
</Reference>
23+
<Reference Include="Microsoft.Deployment.WindowsInstaller.Package">
24+
<HintPath>$(WiXSdkPath)\Microsoft.Deployment.WindowsInstaller.Package.dll</HintPath>
25+
</Reference>
26+
</ItemGroup>
27+
1628
<Import Project="$(RepoTasksSdkPath)\Sdk.targets" Condition="'$(RepoTasksSdkPath)' != '' "/>
1729
</Project>

build/tasks/RepoTasks.tasks

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
</PropertyGroup>
55

66
<UsingTask TaskName="RepoTasks.GenerateRestoreSourcesPropsFile" AssemblyFile="$(_RepoTaskAssembly)" />
7+
<UsingTask TaskName="RepoTasks.GenerateGuid" AssemblyFile="$(_RepoTaskAssembly)" />
8+
<UsingTask TaskName="RepoTasks.GetMsiProperty" AssemblyFile="$(_RepoTaskAssembly)" />
79
<UsingTask TaskName="RepoTasks.JoinItems" AssemblyFile="$(_RepoTaskAssembly)" />
810
<UsingTask TaskName="RepoTasks.OrderBy" AssemblyFile="$(_RepoTaskAssembly)" />
911
<UsingTask TaskName="RepoTasks.GenerateSharedFrameworkMetadataFiles" AssemblyFile="$(_RepoTaskAssembly)" />
File renamed without changes.

eng/scripts/common.psm1

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -52,54 +52,6 @@ function LoadXml([string]$path) {
5252
return $obj
5353
}
5454

55-
function Get-MSBuildPath {
56-
param(
57-
[switch]$Prerelease,
58-
[string[]]$Requires
59-
)
60-
61-
$vsInstallDir = $null
62-
if ($env:VSINSTALLDIR -and (Test-Path $env:VSINSTALLDIR)) {
63-
$vsInstallDir = $env:VSINSTALLDIR
64-
Write-Verbose "Using VSINSTALLDIR=$vsInstallDir"
65-
}
66-
else {
67-
$vswhere = "${env:ProgramFiles(x86)}/Microsoft Visual Studio/Installer/vswhere.exe"
68-
Write-Verbose "Using vswhere.exe from $vswhere"
69-
70-
if (-not (Test-Path $vswhere)) {
71-
Write-Error "Missing prerequisite: could not find vswhere"
72-
}
73-
74-
[string[]] $vswhereArgs = @()
75-
76-
if ($Prerelease) {
77-
$vswhereArgs += '-prerelease'
78-
}
79-
80-
if ($Requires) {
81-
foreach ($r in $Requires) {
82-
$vswhereArgs += '-requires', $r
83-
}
84-
}
85-
86-
$installs = & $vswhere -format json -version '[15.0, 16.0)' -latest -products * @vswhereArgs | ConvertFrom-Json
87-
if (!$installs) {
88-
Write-Error "Missing prerequisite: could not find any installations of Visual Studio"
89-
}
90-
91-
$vs = $installs | Select-Object -First 1
92-
$vsInstallDir = $vs.installationPath
93-
Write-Host "Using $($vs.displayName)"
94-
}
95-
96-
$msbuild = Join-Path $vsInstallDir 'MSBuild/15.0/bin/msbuild.exe'
97-
if (!(Test-Path $msbuild)) {
98-
Write-Error "Missing prerequisite: could not find msbuild.exe"
99-
}
100-
return $msbuild
101-
}
102-
10355
function Get-RemoteFile([string]$RemotePath, [string]$LocalPath) {
10456
if ($RemotePath -notlike 'http*') {
10557
Copy-Item $RemotePath $LocalPath

eng/targets/Wix.Common.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<TargetFramework>net461</TargetFramework>
1313
<MSBuildProjectExtensionsPath>$(BaseIntermediateOutputPath)</MSBuildProjectExtensionsPath>
1414
<MSBuildProjectExtensionsPath Condition="'$(MSBuildProjectExtensionsPath)' == ''">$(MSBuildProjectDir)\obj\</MSBuildProjectExtensionsPath>
15-
<!-- IsRunningFromVisualStudio may be true even when running msbuild.exe from command line. This generally means that MSBUild is Visual Studio installation and therefore we need to find NuGet.targets in a different location. -->
15+
<!-- IsRunningFromVisualStudio may be true even when running msbuild.exe from command line. This generally means that MSBUild is Visual Studio installation and therefore we need to find NuGet.targets in a different location. -->
1616
<NuGetRestoreTargets Condition="'$(NuGetRestoreTargets)'=='' and '$([MSBuild]::IsRunningFromVisualStudio())'=='true'">$(MSBuildToolsPath32)\..\..\..\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets</NuGetRestoreTargets>
1717
<NuGetRestoreTargets Condition="'$(NuGetRestoreTargets)'==''">$(MSBuildToolsPath)\NuGet.targets</NuGetRestoreTargets>
1818
</PropertyGroup>

0 commit comments

Comments
 (0)