|
| 1 | +<?xml version="1.0" encoding="utf-8"?> |
| 2 | +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
| 3 | + <UsingTask TaskName="Xamarin.MacDev.Tasks.Messaging.GenerateBuildSessionId" AssemblyFile="$(_TaskAssemblyName)" /> |
| 4 | + <UsingTask TaskName="Xamarin.MacDev.Tasks.Messaging.SayHello" AssemblyFile="$(_TaskAssemblyName)" /> |
| 5 | + <UsingTask TaskName="Xamarin.MacDev.Tasks.Messaging.CopyFileFromBuildServer" AssemblyFile="$(_TaskAssemblyName)" /> |
| 6 | + <UsingTask TaskName="Xamarin.MacDev.Tasks.Messaging.CopyFilesToBuildServer" AssemblyFile="$(_TaskAssemblyName)" /> |
| 7 | + <UsingTask TaskName="Xamarin.MacDev.Tasks.Messaging.CopyLongPaths" AssemblyFile="$(_TaskAssemblyName)" /> |
| 8 | + <UsingTask TaskName="Xamarin.MacDev.Tasks.Messaging.VerifyBuildSignature" AssemblyFile="$(_TaskAssemblyName)" /> |
| 9 | + <UsingTask TaskName="Xamarin.MacDev.Tasks.Messaging.SayGoodbye" AssemblyFile="$(_TaskAssemblyName)" /> |
| 10 | + |
| 11 | + <PropertyGroup> |
| 12 | + <IsRemoteBuild Condition="'$(IsRemoteBuild)' == ''">true</IsRemoteBuild> |
| 13 | + <ShouldDisconnect Condition="'$(ShouldDisconnect)' == ''">true</ShouldDisconnect> |
| 14 | + <IsRebuild>false</IsRebuild> |
| 15 | + </PropertyGroup> |
| 16 | + |
| 17 | + <PropertyGroup> |
| 18 | + <RebuildDependsOn> |
| 19 | + _SetIsRebuild; |
| 20 | + _SetShouldDisconnect; |
| 21 | + _GenerateBuildSessionId; |
| 22 | + _SayHello; |
| 23 | + $(RebuildDependsOn); |
| 24 | + _SayGoodbye; |
| 25 | + </RebuildDependsOn> |
| 26 | + <!-- If the Clean executes as part of a Rebuild, the _GenerateBuildSessionId and _SayHello will not run because they've already run --> |
| 27 | + <CleanDependsOn> |
| 28 | + _GenerateBuildSessionId; |
| 29 | + _SayHello; |
| 30 | + $(CleanDependsOn); |
| 31 | + _DisconnectAfterClean; |
| 32 | + </CleanDependsOn> |
| 33 | + <!-- If the Build executes as part of a Rebuild, the _GenerateBuildSessionId and _SayHello will not run because they've already run --> |
| 34 | + <BuildDependsOn> |
| 35 | + _GenerateBuildSessionId; |
| 36 | + _SayHello; |
| 37 | + _VerifyBuildSignature; |
| 38 | + AfterConnect; |
| 39 | + $(BuildDependsOn); |
| 40 | + BeforeDisconnect; |
| 41 | + _DisconnectAfterBuild; |
| 42 | + </BuildDependsOn> |
| 43 | + <BuildSignatureDirectory Condition="'$(BuildSignatureDirectory)' == ''">$(IntermediateOutputPath)build-signature\</BuildSignatureDirectory> |
| 44 | + <BuildSignatureDirectory Condition="!HasTrailingSlash('$(BuildSignatureDirectory)')">$(BuildSignatureDirectory)\</BuildSignatureDirectory> |
| 45 | + <BuildSignatureFile>$(BuildSignatureDirectory)signature</BuildSignatureFile> |
| 46 | + <!-- By default, we don't want to warn about offline builds for class libraries, which typically don't require a connection --> |
| 47 | + <WarnOfflineBuild Condition="'$(WarnOfflineBuild)' == '' and '$(OutputType)' == 'Library' and '$(XamarinOutputType)' != 'Binding'">false</WarnOfflineBuild> |
| 48 | + <WarnOfflineBuild Condition="'$(WarnOfflineBuild)' == ''">true</WarnOfflineBuild> |
| 49 | + <NoWarn Condition="'$(WarnOfflineBuild)' == 'false'">$(NoWarn);VSX1000</NoWarn> |
| 50 | + </PropertyGroup> |
| 51 | + |
| 52 | + <!-- AfterConnect: Redefine this target in your project in order to run tasks just after the XMA connection is performed --> |
| 53 | + <Target Name="AfterConnect" Condition="'$(IsRemoteBuild)' == 'true'" /> |
| 54 | + |
| 55 | + <!-- BeforeDisconnect: Redefine this target in your project in order to run tasks just before the XMA disconnection happens --> |
| 56 | + <Target Name="BeforeDisconnect" Condition="'$(IsRemoteBuild)' == 'true'" /> |
| 57 | + |
| 58 | + <Target Name="_SetShouldDisconnect"> |
| 59 | + <PropertyGroup> |
| 60 | + <ShouldDisconnect>false</ShouldDisconnect> |
| 61 | + </PropertyGroup> |
| 62 | + </Target> |
| 63 | + |
| 64 | + <Target Name="_SetIsRebuild"> |
| 65 | + <PropertyGroup> |
| 66 | + <IsRebuild>true</IsRebuild> |
| 67 | + </PropertyGroup> |
| 68 | + </Target> |
| 69 | + |
| 70 | + <Target Name="_DisconnectAfterClean" Condition="'$(ShouldDisconnect)' == 'true' Or ('$(ShouldDisconnect)' == 'if-connection-established' And '$(_DidEstablishConnection)' == 'true')" DependsOnTargets="_SayGoodbye" /> |
| 71 | + |
| 72 | + <Target Name="_DisconnectAfterBuild" Condition="'$(ShouldDisconnect)' == 'true' Or ('$(ShouldDisconnect)' == 'if-connection-established' And '$(_DidEstablishConnection)' == 'true')" DependsOnTargets="_SayGoodbye" /> |
| 73 | + |
| 74 | + <Target Name="_GenerateBuildSessionId" Condition="'$(IsRemoteBuild)' == 'true'"> |
| 75 | + <GenerateBuildSessionId MessagingVersion="$(MessagingVersion)" |
| 76 | + TargetFramework="$(TargetFramework)" |
| 77 | + ProjectFullPath="$(MSBuildProjectFullPath)" |
| 78 | + ProjectName="$(MSBuildProjectName)" |
| 79 | + VisualStudioProcessId="$(VisualStudioProcessId)"> |
| 80 | + <Output TaskParameter="BuildSessionId" PropertyName="BuildSessionId" /> |
| 81 | + <Output TaskParameter="BuildAppName" PropertyName="BuildAppName" /> |
| 82 | + </GenerateBuildSessionId> |
| 83 | + </Target> |
| 84 | + |
| 85 | + <Target Name="_SayHello" Condition="'$(IsRemoteBuild)' == 'true'" DependsOnTargets="_GenerateBuildSessionId"> |
| 86 | + <PropertyGroup> |
| 87 | + <!-- Explicitly using defauly SSH port if not specified --> |
| 88 | + <ServerSshPort Condition="'$(ServerSshPort)' == ''">22</ServerSshPort> |
| 89 | + <!-- Maintaining backwards compatibility if using the deprecated ServerPort property --> |
| 90 | + <ServerTcpPort Condition="'$(ServerPort)' != ''">$(ServerPort)</ServerTcpPort> |
| 91 | + <GenerateCache Condition=" '$(GenerateCache)' == '' And '$(BuildingInsideVisualStudio)' == 'true' ">true</GenerateCache> |
| 92 | + <GenerateCache Condition=" '$(GenerateCache)' == '' And '$(BuildingInsideVisualStudio)' != 'true' ">false</GenerateCache> |
| 93 | + <ContinueOnDisconnected Condition="'$(ContinueOnDisconnected)' == ''">true</ContinueOnDisconnected> |
| 94 | + </PropertyGroup> |
| 95 | + |
| 96 | + <Warning Condition="'$(ServerPort)' != ''" Text="The 'ServerPort' property has been deprecated. Please consider using 'ServerSshPort' or 'ServerTcpPort' instead." /> |
| 97 | + |
| 98 | + <Message Importance="high" Condition="'$(ServerAddress)' != ''" Text="Executing SayHello Task to establish a connection to a Remote Server. |
| 99 | + Properties: |
| 100 | + SessionId=$(BuildSessionId), |
| 101 | + Addresss=$(ServerAddress), |
| 102 | + SshPort=$(ServerSshPort), |
| 103 | + TcpPort=$(ServerTcpPort), |
| 104 | + User=$(ServerUser), |
| 105 | + AppName=$(BuildAppName), |
| 106 | + VisualStudioProcessId=$(VisualStudioProcessId), |
| 107 | + DotNetRuntimePath=$(DotNetRuntimePath), |
| 108 | + DotNetSdkPath=$(_DotNetRootRemoteDirectory), |
| 109 | + ContinueOnDisconnected=$(ContinueOnDisconnected)" /> |
| 110 | + |
| 111 | + <SayHello Condition="'$(ServerAddress)' != ''" |
| 112 | + SessionId="$(BuildSessionId)" |
| 113 | + LocalBasePath="$(LocalBasePath)" |
| 114 | + LocalSettingsPath="$(LocalSettingsPath)" |
| 115 | + BasePath="$(BasePath)" |
| 116 | + BuildsPath="$(BuildsPath)" |
| 117 | + LogsPath="$(LogsPath)" |
| 118 | + IntermediateDir="$(IntermediateOutputPath)build_package\" |
| 119 | + DotNetRuntimePath="$(DotNetRuntimePath)" |
| 120 | + DotNetSdkPath="$(_DotNetRootRemoteDirectory)" |
| 121 | + ServerAddress="$(ServerAddress)" |
| 122 | + ServerSshPort="$(ServerSshPort)" |
| 123 | + ServerTcpPort="$(ServerTcpPort)" |
| 124 | + ServerUser="$(ServerUser)" |
| 125 | + ServerPassword="$(ServerPassword)" |
| 126 | + SSHKey="$(SSHKey)" |
| 127 | + SSHPassPhrase="$(SSHPassPhrase)" |
| 128 | + AppName="$(BuildAppName)" |
| 129 | + GenerateCache="$(GenerateCache)" |
| 130 | + ProjectDirectory="$(MSBuildProjectDirectory)" |
| 131 | + ContinueOnDisconnected="$(ContinueOnDisconnected)" |
| 132 | + VisualStudioProcessId="$(VisualStudioProcessId)" |
| 133 | + NoWarn="$(NoWarn)" |
| 134 | + AgentsDirectory="$(MessagingAgentsDirectory)"> |
| 135 | + <Output TaskParameter="DidEstablishConnection" PropertyName="_DidEstablishConnection" /> |
| 136 | + <Output TaskParameter="IsBuildServerAvailable" PropertyName="MtouchTargetsEnabled" /> |
| 137 | + <Output TaskParameter="IsBuildServerAvailable" PropertyName="IsMacEnabled" /> |
| 138 | + <Output TaskParameter="MacBuildPath" PropertyName="MacBuildPath" /> |
| 139 | + </SayHello> |
| 140 | + </Target> |
| 141 | + |
| 142 | + <!-- We don't want to execute _VerifyBuildSignature on Rebuild since the Rebuild implies a Clean before Build --> |
| 143 | + <!-- so we don't need to Clean again if the signature does not exist --> |
| 144 | + <!-- Also, if there is no Mac available and the signature file does not exist, we ignore this check because offline builds never produce a signature file and this would end up always rebuilding the project --> |
| 145 | + <Target Name="_VerifyBuildSignature" Condition="'$(IsRemoteBuild)' == 'true' And '$(IsRebuild)' != 'true' And ('$(IsMacEnabled)' == 'true' Or ('$(IsMacEnabled)' != 'true' And Exists('$(BuildSignatureFile)')))"> |
| 146 | + <VerifyBuildSignature SessionId="$(BuildSessionId)" SignatureDirectory="$(BuildSignatureDirectory)"> |
| 147 | + <Output TaskParameter="IsValidSignature" PropertyName="IsValidSignature" /> |
| 148 | + </VerifyBuildSignature> |
| 149 | + <MSBuild Condition="'$(IsValidSignature)' != 'true'" Projects="$(MSBuildProjectFile)" Targets="Clean" Properties="Configuration=$(Configuration); Platform=$(Platform); ShouldDisconnect=if-connection-established; BuildProjectReferences=false"></MSBuild> |
| 150 | + </Target> |
| 151 | + |
| 152 | + <Target Name="_SayGoodbye" Condition="'$(IsRemoteBuild)' == 'true'"> |
| 153 | + <SayGoodbye Condition="'$(IsMacEnabled)' == 'true'" SessionId="$(BuildSessionId)" SignatureFile="$(BuildSignatureFile)" /> |
| 154 | + <ItemGroup> |
| 155 | + <FileWrites Include="$(BuildSignatureFile)" /> |
| 156 | + </ItemGroup> |
| 157 | + </Target> |
| 158 | + |
| 159 | + <PropertyGroup> |
| 160 | + <MessagingBuildTargetsImported>True</MessagingBuildTargetsImported> |
| 161 | + </PropertyGroup> |
| 162 | +</Project> |
0 commit comments