1<?xml version="1.0" encoding="utf-8"?>
2<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" TreatAsLocalProperty="ReleaseUri">
3    <PropertyGroup>
4        <TargetName>$(OutputName)</TargetName>
5        <DefineSolutionProperties>false</DefineSolutionProperties>
6        <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
7        <SuppressIces>$(SuppressIces);ICE03;ICE57;ICE61</SuppressIces>
8        <CompilerSuppressSpecificWarnings>1026</CompilerSuppressSpecificWarnings>
9        <BuildForRelease Condition="'$(BuildForRelease)' == ''">false</BuildForRelease>
10        <SignOutput Condition="'$(SigningCertificate)' != ''">true</SignOutput>
11        <Configuration Condition="'$(Configuration)' == ''">Release</Configuration>
12        <Platform Condition="'$(Platform)' == ''">x86</Platform>
13        <InstallScope Condition="'$(InstallScope)' != 'perMachine'">perUser</InstallScope>
14        <_MakeCatCommand Condition="'$(_MakeCatCommand)' == ''">makecat</_MakeCatCommand>
15        <SkipCopySSLDLL>true</SkipCopySSLDLL>
16    </PropertyGroup>
17
18    <Import Project="wix.props" />
19    <Import Project="..\..\PCbuild\openssl.props" />
20    <Import Project="..\..\PCbuild\tcltk.props" />
21
22    <PropertyGroup>
23        <!--
24        This URI is used to generate the various GUIDs used by the installer.
25        Installers built with the same URI will upgrade each other or block
26        when attempting to downgrade.
27
28        By default, this is the local computer name, which will produce
29        installers that do not interfere with other installers. Products
30        that intend to bundle Python should rebuild these modules with their
31        own URI to avoid conflicting with the official releases.
32
33        The official releases use "https://www.python.org/$(ArchName)"
34
35        This is not the same as the DownloadUrl property used in the bundle
36        projects.
37        -->
38        <ReleaseUri Condition="'$(ReleaseUri)' == ''">$(ComputerName)/$(ArchName)/</ReleaseUri>
39        <ReleaseUri Condition="!$(ReleaseUri.EndsWith(`/`))">$(ReleaseUri)/</ReleaseUri>
40    </PropertyGroup>
41
42
43    <ItemGroup>
44        <Compile Include="$(MSBuildThisFileDirectory)common.wxs" />
45        <WxlTemplate Include="$(MSBuildThisFileDirectory)\*.wxl_template" Condition="$(IgnoreCommonWxlTemplates) != 'true'" />
46        <WixExtension Include="WixUtilExtension">
47            <HintPath>WixUtilExtension</HintPath>
48            <Name>WixUtilExtension</Name>
49        </WixExtension>
50    </ItemGroup>
51
52    <PropertyGroup>
53        <IntermediateOutputPath>$(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)$(ArchName)_$(Configuration)\msi_$(OutputName)</IntermediateOutputPath>
54        <IntermediateOutputPath Condition="'$(OutputSuffix)' != ''">$(IntermediateOutputPath)_$(OutputSuffix)</IntermediateOutputPath>
55        <OutputPath Condition="'$(OutputPath)' == ''">$(BuildPath)</OutputPath>
56        <OutputPath Condition="!HasTrailingSlash($(OutputPath))">$(OutputPath)\</OutputPath>
57        <OutDir>$(OutputPath)</OutDir>
58        <ReuseCabinetCache>true</ReuseCabinetCache>
59        <CRTRedist Condition="'$(CRTRedist)' == ''">$(ExternalsDir)\windows-installer\redist-1\$(Platform)</CRTRedist>
60        <CRTRedist>$([System.IO.Path]::GetFullPath($(CRTRedist)))</CRTRedist>
61        <TclTkLibraryDir Condition="$(TclTkLibraryDir) == ''">$(tcltkDir)lib</TclTkLibraryDir>
62        <DocFilename>python$(MajorVersionNumber)$(MinorVersionNumber)$(MicroVersionNumber)$(ReleaseLevelName).chm</DocFilename>
63
64        <InstallerVersion>$(MajorVersionNumber).$(MinorVersionNumber).$(Field3Value).0</InstallerVersion>
65    </PropertyGroup>
66
67    <PropertyGroup Condition="!$(BuildForRelease)">
68        <RevisionNumber Condition="'$(RevisionNumber)' == ''">$([System.Math]::Floor($([System.DateTime]::Now.Subtract($([System.DateTime]::new(2001, 1, 1))).TotalDays)))</RevisionNumber>
69        <PythonVersion>$(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber)dev$(RevisionNumber)</PythonVersion>
70        <InstallerVersion>$(MajorVersionNumber).$(MinorVersionNumber).$(RevisionNumber).0</InstallerVersion>
71    </PropertyGroup>
72
73    <PropertyGroup>
74        <Bitness>32-bit</Bitness>
75        <Bitness Condition="$(Platform) == 'x64'">64-bit</Bitness>
76        <Bitness Condition="$(Platform) == 'ARM64'">ARM64</Bitness>
77        <PlatformArchitecture>32bit</PlatformArchitecture>
78        <PlatformArchitecture Condition="$(Platform) == 'x64'">64bit</PlatformArchitecture>
79        <PlatformArchitecture Condition="$(Platform) == 'ARM64'">ARM64</PlatformArchitecture>
80        <DefineConstants>
81            $(DefineConstants);
82            Version=$(InstallerVersion);
83            ShortVersion=$(MajorVersionNumber).$(MinorVersionNumber);
84            LongVersion=$(PythonVersion);
85            MajorVersionNumber=$(MajorVersionNumber);
86            MinorVersionNumber=$(MinorVersionNumber);
87            UpgradeMinimumVersion=$(MajorVersionNumber).$(MinorVersionNumber).0.0;
88            NextMajorVersionNumber=$(MajorVersionNumber).$([msbuild]::Add($(MinorVersionNumber), 1)).0.0;
89            Bitness=$(Bitness);
90            PlatformArchitecture=$(PlatformArchitecture);
91            PyDebugExt=$(PyDebugExt);
92            PyArchExt=$(PyArchExt);
93            PyTestExt=$(PyTestExt);
94            OptionalFeatureName=$(OutputName);
95            ssltag=$(OpenSSLDLLSuffix);
96            Suffix32=$(PyArchExt);
97        </DefineConstants>
98        <DefineConstants Condition="'$(CRTRedist)' != ''">
99            $(DefineConstants);CRTRedist=$(CRTRedist);
100        </DefineConstants>
101    </PropertyGroup>
102
103    <ItemDefinitionGroup>
104        <InstallFiles>
105            <Group>generated_filelist</Group>
106            <Condition></Condition>
107            <DiskId></DiskId>
108            <IncludeInCat>false</IncludeInCat>
109        </InstallFiles>
110        <LinkerBindInputPaths>
111            <Visible>false</Visible>
112        </LinkerBindInputPaths>
113    </ItemDefinitionGroup>
114    <ItemGroup>
115        <LinkerBindInputPaths Include="$(PGOBuildPath);$(BuildPath)">
116            <BindName></BindName>
117        </LinkerBindInputPaths>
118        <LinkerBindInputPaths Include="$(PySourcePath)">
119            <BindName>src</BindName>
120        </LinkerBindInputPaths>
121        <LinkerBindInputPaths Include="$(TclTkLibraryDir)">
122            <BindName>tcltk</BindName>
123        </LinkerBindInputPaths>
124        <LinkerBindInputPaths Include="$(CRTRedist)">
125            <BindName>redist</BindName>
126        </LinkerBindInputPaths>
127        <LinkerBindInputPaths Include="$(BuildPath32)">
128            <BindName>build32</BindName>
129        </LinkerBindInputPaths>
130        <LinkerBindInputPaths Include="$(BuildPath64)">
131            <BindName>build64</BindName>
132        </LinkerBindInputPaths>
133        <LinkerBindInputPaths Include="$(BuildPathARM64)">
134            <BindName>buildarm64</BindName>
135        </LinkerBindInputPaths>
136    </ItemGroup>
137
138    <Target Name="_ValidateMsiProps" BeforeTargets="PrepareForBuild">
139        <Error Text="Platform '$(Platform)' is not supported. Use 'x86', 'x64' or 'ARM64'."
140               Condition="$(Platform) != 'x86' and $(Platform) != 'x64' and $(Platform) != 'ARM64'" />
141    </Target>
142
143    <ItemGroup>
144        <_Uuid Include="CoreUpgradeCode">
145            <Uri>upgradecode</Uri>
146        </_Uuid>
147        <_Uuid Include="UpgradeCode">
148            <Uri>upgradecode/$(OutputName)</Uri>
149        </_Uuid>
150        <_Uuid Include="InstallDirectoryGuidSeed">
151            <Uri>installdirectoryseed</Uri>
152        </_Uuid>
153        <_Uuid Include="PythonExeComponentGuid">
154            <Uri>python.exe</Uri>
155        </_Uuid>
156        <_Uuid Include="PythonwExeComponentGuid">
157            <Uri>pythonw.exe</Uri>
158        </_Uuid>
159        <_Uuid Include="RemoveLib2to3PickleComponentGuid">
160            <Uri>lib2to3/pickles</Uri>
161        </_Uuid>
162        <_Uuid Include="CommonPythonRegComponentGuid">
163            <Uri>registry</Uri>
164        </_Uuid>
165        <_Uuid Include="PythonRegComponentGuid">
166            <Uri>registry/$(OutputName)</Uri>
167        </_Uuid>
168    </ItemGroup>
169    <Target Name="_GenerateGuids"
170            AfterTargets="PrepareForBuild"
171            DependsOnTargets="FindPythonForBuild"
172            Condition="$(TargetName) != 'launcher'">
173        <PropertyGroup>
174            <_Uuids>@(_Uuid->'("%(Identity)", "$(MajorVersionNumber).$(MinorVersionNumber)/%(Uri)")',',')</_Uuids>
175            <_GenerateCommand>import uuid; print('\n'.join('{}={}'.format(i, uuid.uuid5(uuid.UUID('c8d9733e-a70c-43ff-ab0c-e26456f11083'), '$(ReleaseUri.Replace(`{arch}`, `$(ArchName)`))' + j)) for i,j in [$(_Uuids.Replace(`"`,`'`))]))</_GenerateCommand>
176        </PropertyGroup>
177
178        <Exec Command='$(PythonForBuild) -c "$(_GenerateCommand)" &gt; "$(IntermediateOutputPath)$(OutputName)guids.txt"'
179              WorkingDirectory="$(MSBuildThisFileDirectory)"
180              IgnoreExitCode="false" />
181
182        <ReadLinesFromFile File="$(IntermediateOutputPath)$(OutputName)guids.txt">
183            <Output TaskParameter="Lines" ItemName="_UuidValue" />
184        </ReadLinesFromFile>
185
186        <PropertyGroup>
187            <DefineConstants>$(DefineConstants);@(_UuidValue,';');</DefineConstants>
188        </PropertyGroup>
189    </Target>
190</Project>