summaryrefslogtreecommitdiffstats
path: root/Tools/nuget/make_pkg.proj
blob: 9843bc97ccdc1e3fc41b57cc8f9e1dc9ddd0fc45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <ProjectGuid>{10487945-15D1-4092-A214-338395C4116B}</ProjectGuid>
        <OutputName>python</OutputName>
        <OutputName Condition="$(Platform) == 'x86'">$(OutputName)x86</OutputName>
        <OutputName Condition="$(BuildForDaily) == 'true'">$(OutputName)daily</OutputName>
        <OutputSuffix></OutputSuffix>
        <SupportSigning>false</SupportSigning>
        <BuildForRelease Condition="$(BuildForRelease) == ''">true</BuildForRelease>
    </PropertyGroup>

    <Import Project="..\msi\msi.props" />

    <PropertyGroup>
        <Nuget Condition="$(Nuget) == ''">$(ExternalsDir)\windows-installer\nuget\nuget.exe</Nuget>
        <NuspecVersion>$(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber)</NuspecVersion>
        <NuspecVersion Condition="$(ReleaseLevelName) != ''">$(NuspecVersion)-$(ReleaseLevelName)</NuspecVersion>
        <NuspecVersion Condition="$(BuildForDaily) == 'true'">$(MajorVersionNumber).$(MinorVersionNumber).$(DailyBuildVersion)</NuspecVersion>
        <SignOutput>false</SignOutput>
        <TargetName>$(OutputName).$(NuspecVersion)</TargetName>
        <TargetExt>.nupkg</TargetExt>
        <IntermediateOutputPath>$(IntermediateOutputPath)\nuget_$(ArchName)</IntermediateOutputPath>
        
        <CleanCommand>rmdir /q/s "$(IntermediateOutputPath)"</CleanCommand>
        
        <PythonArguments>"$(PythonExe)" "$(MSBuildThisFileDirectory)\..\msi\make_zip.py"</PythonArguments>
        <PythonArguments>$(PythonArguments) -t "$(IntermediateOutputPath)" -b "$(BuildPath.TrimEnd(`\`))"</PythonArguments>
        
        <PipArguments>"$(IntermediateOutputPath)\python.exe" -B -c "import sys; sys.path.append(r'$(PySourcePath)\Lib'); import ensurepip; ensurepip._main()"</PipArguments>
        <PackageArguments Condition="$(Packages) != ''">"$(IntermediateOutputPath)\python.exe" -B -m pip install -U $(Packages)</PackageArguments>
        
        <NugetPackCommand>"$(Nuget)" pack "$(MSBuildThisFileDirectory)\$(OutputName).nuspec" -BasePath "$(IntermediateOutputPath)"</NugetPackCommand>
        <NugetPackSymbolsCommand Condition="Exists('$(MSBuildThisFileDirectory)\$(OutputName).symbols.nuspec')">"$(Nuget)" pack "$(MSBuildThisFileDirectory)\$(OutputName).symbols.nuspec" -BasePath "$(BuildPath.TrimEnd(`\`))"</NugetPackSymbolsCommand>
        <NugetArguments>$(NugetArguments) -OutputDirectory "$(OutputPath.Trim(`\`))"</NugetArguments>
        <NugetArguments>$(NugetArguments) -Version "$(NuspecVersion)"</NugetArguments>
        <NugetArguments>$(NugetArguments) -NoPackageAnalysis -NonInteractive</NugetArguments>
        
        <Environment>set DOC_FILENAME=python$(PythonVersion).chm</Environment>
        <Environment>$(Environment)%0D%0Aset PYTHONPATH=$(PySourcePath)Lib</Environment>
        <Environment Condition="Exists($(CRTRedist))">$(Environment)%0D%0Aset VCREDIST_PATH=$(CRTRedist)\$(Platform)</Environment>
        <Environment>$(Environment)%0D%0Amkdir "$(OutputPath.Trim(`\`))" &gt;nul 2&gt;nul</Environment>
    </PropertyGroup>

    <Target Name="_NugetMissing" BeforeTargets="_Build" Condition="!Exists($(Nuget))">
        <Error Text="$(Nuget) could not be found. Either avoid specifying the property or update your externals/windows-installer files." />
    </Target>

    <Target Name="_Build">
        <Exec Command="$(CleanCommand)" />
        <Exec Command="setlocal%0D%0A$(Environment)%0D%0A$(PythonArguments)" />
        <Exec Command="$(PipArguments)" />
        <Exec Command="$(PackageArguments)" Condition="$(PackageArguments) != ''" />

        <PropertyGroup>
            <_PropsContents>$([System.IO.File]::ReadAllText('python.props'))</_PropsContents>
            <_PropsContents>$(_PropsContents.Replace('$$PYTHON_TAG$$', '$(MajorVersionNumber).$(MinorVersionNumber)'))</_PropsContents>
            <_PropsContents>$(_PropsContents.Replace('$$PYTHON_VERSION$$', '$(NuspecVersion)'))</_PropsContents>
            <_PropsContents Condition="$(Platform) == 'x86'">$(_PropsContents.Replace('$$PYTHON_PLATFORM$$', 'Win32'))</_PropsContents>
            <_PropsContents Condition="$(Platform) != 'x86'">$(_PropsContents.Replace('$$PYTHON_PLATFORM$$', '$(Platform)'))</_PropsContents>
            <_PropsContents>$(_PropsContents.Replace('$$PYTHON_TARGET$$', '_GetPythonRuntimeFilesDependsOn$(MajorVersionNumber)$(MinorVersionNumber)_$(Platform)'))</_PropsContents>
            <_ExistingContents Condition="Exists('$(IntermediateOutputPath)\python.props')">$([System.IO.File]::ReadAllText('$(IntermediateOutputPath)\python.props'))</_ExistingContents>
        </PropertyGroup>
        <WriteLinesToFile File="$(IntermediateOutputPath)\python.props"
                          Lines="$(_PropsContents)"
                          Condition="$(_PropsContents) != $(_ExistingContents)" />

        <Exec Command="$(NugetPackCommand) $(NugetArguments)" />
        <Exec Command="$(NugetPackSymbolsCommand) $(NugetArguments)" Condition="$(NugetPackSymbolsCommand) != ''" />
    </Target>

    <Target Name="AfterBuild" />
    <Target Name="Build" DependsOnTargets="_Build;AfterBuild" />
</Project>