summaryrefslogtreecommitdiffstats
path: root/win/CS/build.xml
blob: da326533f0720dd83685ea4978a39921e1a4fb47 (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<!--
  build.xml
  This file is part of the HandBrake source code.
  Homepage: <http://handbrake.fr>.
  It may be used under the terms of the GNU General Public License
  
  HandBrake Build Script for usage with Jenkins.
  Usage: 
    msbuild build_publish.xml /t:x64 /p:Profile=[Nightly or Release]
    msbuild build_publish.xml /t:arm64 /p:Profile=[Nightly or Release]
  Example with code signing:
    msbuild build_publish.xml /t:x64 /p:SignThumbprint=XYZ /p:SignTimestampServer=http://time.certum.pl/
    msbuild build_publish.xml /t:x64 /p:PfxFile=file.pfx /p:PfxPwd=XYZ /p:SignTimestampServer=http://time.certum.pl/
    
  Requires: hb.dll to be in the release folder.
  
-->
<Project DefaultTargets="x64" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <!-- ******* Build Targets ******* -->
  <Target Name="arm64" DependsOnTargets="$(ARM64DependsOn)"/>
  <Target Name="x64" DependsOnTargets="$(X64DependsOn)"/>

  <PropertyGroup Condition="'$(Profile)'==''">
    <Profile>Nightly</Profile>
    <Configuration>Debug</Configuration>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Profile)'=='Nightly'">
    <Configuration>Debug</Configuration>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Profile)'=='Release'">
    <Configuration>Release</Configuration>
  </PropertyGroup>

  <PropertyGroup>
    <ARM64DependsOn>ARM64Setup;BuildSoftware;BuildInstaller</ARM64DependsOn>
    <X64DependsOn>X64Setup;BuildSoftware;BuildInstaller</X64DependsOn>
  </PropertyGroup>

  <Target Name="ARM64Setup">
    <PropertyGroup>
      <BuildProfile>publish_arm64</BuildProfile>
      <Platform>arm64</Platform>
    </PropertyGroup>
  </Target>

  <Target Name="X64Setup">
    <PropertyGroup>
      <BuildProfile>publish_x64</BuildProfile>
      <Platform>x64</Platform>
    </PropertyGroup>
  </Target>

  <!-- ******* Build the software ******* -->
  <Target Name="BuildSoftware">
    <Exec Command="dotnet publish -p:PublishProfile=$(buildProfile)" />

    <!-- Copy required assets -->
    <Exec Command="xcopy $(MSBuildProjectDirectory)\HandBrake.Worker\bin\publish $(MSBuildProjectDirectory)\HandBrakeWPF\bin\publish /I /Y" />
    <Exec Command="xcopy $(MSBuildProjectDirectory)\doc $(MSBuildProjectDirectory)\HandBrakeWPF\bin\publish\doc /I /Y" />
    <Exec Command="xcopy $(MSBuildProjectDirectory)\doc $(MSBuildProjectDirectory)\HandBrakeWPF\bin\publish\doc /I /Y" />

    <Exec Command="copy $(MSBuildProjectDirectory)\HandBrakeWPF\Installer\Installer64.nsi $(MSBuildProjectDirectory)\HandBrakeWPF\bin\publish /Y"      Condition="'$(Profile)'=='Release'"/>
    <Exec Command="copy $(MSBuildProjectDirectory)\HandBrakeWPF\Installer\MakeNightly64.nsi $(MSBuildProjectDirectory)\HandBrakeWPF\bin\publish /Y"    Condition="'$(Profile)'=='Nightly'"/>
    <Exec Command="copy $(MSBuildProjectDirectory)\HandBrakeWPF\Installer\InstallerBackground.bmp $(MSBuildProjectDirectory)\HandBrakeWPF\bin\publish /Y" />
    <Exec Command="copy $(MSBuildProjectDirectory)\HandBrakeWPF\handbrakepineapple.ico $(MSBuildProjectDirectory)\HandBrakeWPF\bin\publish /Y" />
  </Target>

  <!-- ******* Create Installers ******* -->

  <ItemGroup>
    <InstallerToBuild Include="HandBrake.Installer\*wixproj" Exclude="$(MSBuildProjectFile)" >
      <AdditionalProperties>HBPROFILE=$(Platform)</AdditionalProperties>
    </InstallerToBuild>
  </ItemGroup>

  <Target Name="BuildInstaller">
    <Exec Command="makensis $(MSBuildProjectDirectory)\HandBrakeWPF\bin\publish\MakeNightly64.nsi" Condition="'$(Profile)'=='Nightly'" />
    <Exec Command="makensis $(MSBuildProjectDirectory)\HandBrakeWPF\bin\publish\Installer64.nsi" Condition="'$(Profile)'=='Release'" />

    <!-- Wix Installer -->
    <MSBuild Projects ="@(InstallerToBuild)" ContinueOnError ="false" Properties="Configuration=$(Configuration)" >
      <Output ItemName="OutputFiles" TaskParameter="TargetOutputs"/>
    </MSBuild>

    <Exec Command="copy $(MSBuildProjectDirectory)\HandBrake.Installer\bin\$(Configuration)\HandBrake.msi $(MSBuildProjectDirectory)\HandBrakeWPF\bin\publish\HandBrake-$(Profile)-ARM64-Win_GUI.msi /Y" Condition="'$(Platform)'=='arm64'" />
    <Exec Command="copy $(MSBuildProjectDirectory)\HandBrake.Installer\bin\$(Configuration)\HandBrake.msi $(MSBuildProjectDirectory)\HandBrakeWPF\bin\publish\HandBrake-$(Profile)-x86_64-Win_GUI.msi /Y" Condition="'$(Platform)'=='x64'" />
  </Target>


  <!-- ******* Code Signing ******* -->

  <PropertyGroup Condition="'$(SignToolLocation)'==''">
    <SignToolLocation>C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64\SignTool.exe</SignToolLocation>
  </PropertyGroup>

  <PropertyGroup Condition="'$(SignTimestampServer)'!=''">
    <SignTimestamp  Condition="'$(SignTimestampServer)'!=''" >/t</SignTimestamp>
  </PropertyGroup>

  <PropertyGroup Condition="'$(SignThumbprint)'!=''">
    <SignType>/sha1</SignType>
    <SignEnabled>true</SignEnabled>
  </PropertyGroup>

  <PropertyGroup Condition="'$(PfxFile)'!=''">
    <SignType>/f</SignType>
    <SignPwd Condition="'$(PfxPwd)'!=''">/p</SignPwd>
    <SignEnabled>true</SignEnabled>
  </PropertyGroup>

  <Target Name="CodeSign" Condition="'$(SignEnabled)' == 'true'">
    <Exec Command="&quot;$(SignToolLocation)&quot; sign $(SignType) $(SignThumbprint)$(PfxFile) $(SignPwd) $(PfxPwd) $(SignTimestamp) $(SignTimestampServer) /v &quot;$(MSBuildProjectDirectory)\HandBrakeWPF\bin\publish\*Win_GUI.exe&quot;" />
    <Exec Command="&quot;$(SignToolLocation)&quot; sign $(SignType) $(SignThumbprint)$(PfxFile) $(SignPwd) $(PfxPwd) $(SignTimestamp) $(SignTimestampServer) /v &quot;$(MSBuildProjectDirectory)\HandBrakeWPF\bin\publish\*Win_GUI.msi&quot;" />
  </Target>

</Project>