dotnet_runtime/eng/testing/tests.mobile.targets

137 lines
6.8 KiB
XML

<Project>
<PropertyGroup>
<!-- OutDir is not set early enough to set this property in .props file. -->
<BundleDir>$([MSBuild]::NormalizeDirectory('$(OutDir)', 'AppBundle'))</BundleDir>
<RunScriptOutputPath>$([MSBuild]::NormalizePath('$(BundleDir)', '$(RunScriptOutputName)'))</RunScriptOutputPath>
<RunAOTCompilation Condition="'$(TargetOS)' == 'iOS' and $(TargetArchitecture.StartsWith('arm'))">true</RunAOTCompilation>
</PropertyGroup>
<!-- Generate a self-contained app bundle for Android with tests. -->
<UsingTask Condition="'$(TargetOS)' == 'Android'"
TaskName="AndroidAppBuilderTask"
AssemblyFile="$(AndroidAppBuilderTasksAssemblyPath)" />
<Target Condition="'$(TargetOS)' == 'Android'" Name="BundleTestAndroidApp">
<PropertyGroup>
<AndroidAbi Condition="'$(TargetArchitecture)' == 'arm64'">arm64-v8a</AndroidAbi>
<AndroidAbi Condition="'$(TargetArchitecture)' == 'arm'">armeabi-v7a</AndroidAbi>
<AndroidAbi Condition="'$(TargetArchitecture)' == 'x64'">x86_64</AndroidAbi>
<AndroidAbi Condition="'$(TargetArchitecture)' == 'x86'">x86</AndroidAbi>
</PropertyGroup>
<Error Condition="!Exists('$(RuntimePackRidDir)')" Text="RuntimePackRidDir=$(RuntimePackRidDir) doesn't exist" />
<!-- TEMP: consume OpenSSL binaries from external sources via env. variables -->
<Copy Condition="'$(ANDROID_OPENSSL_AAR)' != ''"
SourceFiles="$(ANDROID_OPENSSL_AAR)\prefab\modules\crypto\libs\android.$(AndroidAbi)\libcrypto.so"
DestinationFolder="$(PublishDir)" SkipUnchangedFiles="true"/>
<Copy Condition="'$(ANDROID_OPENSSL_AAR)' != ''"
SourceFiles="$(ANDROID_OPENSSL_AAR)\prefab\modules\ssl\libs\android.$(AndroidAbi)\libssl.so"
DestinationFolder="$(PublishDir)" SkipUnchangedFiles="true"/>
<WriteLinesToFile File="$(PublishDir)xunit-excludes.txt" Lines="$(_withoutCategories.Replace(';', '%0dcategory='))" />
<RemoveDir Directories="$(BundleDir)" />
<AndroidAppBuilderTask
Abi="$(AndroidAbi)"
ProjectName="$(AssemblyName)"
MonoRuntimeHeaders="$(RuntimePackNativeDir)include\mono-2.0"
MainLibraryFileName="AndroidTestRunner.dll"
StripDebugSymbols="False"
OutputDir="$(BundleDir)"
SourceDir="$(PublishDir)">
<Output TaskParameter="ApkPackageId" PropertyName="ApkPackageId" />
<Output TaskParameter="ApkBundlePath" PropertyName="ApkBundlePath" />
</AndroidAppBuilderTask>
<Message Importance="High" Text="PackageId: $(ApkPackageId)"/>
<Message Importance="High" Text="Instrumentation: net.dot.MonoRunner"/>
<Message Importance="High" Text="Apk: $(ApkBundlePath)"/>
</Target>
<!-- Generate a self-contained app bundle for iOS with tests. -->
<UsingTask Condition="'$(TargetOS)' == 'iOS' or '$(TargetOS)' == 'tvOS'"
TaskName="AppleAppBuilderTask"
AssemblyFile="$(AppleAppBuilderTasksAssemblyPath)" />
<UsingTask TaskName="MonoAOTCompiler"
AssemblyFile="$(MonoAOTCompilerTasksAssemblyPath)" />
<Import Project="$(MonoAOTCompilerDir)MonoAOTCompiler.props" />
<Target Condition="'$(TargetOS)' == 'iOS'" Name="BundleTestAppleApp">
<Error Condition="!Exists('$(RuntimePackRidDir)')" Text="RuntimePackRidDir=$(RuntimePackRidDir) doesn't exist" />
<Error Condition="('$(TargetArchitecture)' == 'arm64' or '$(TargetArchitecture)' == 'arm') and '$(DevTeamProvisioning)' == ''"
Text="'DevTeamProvisioning' needs to be set for device builds. Set it to 'UBF8T346G9' if you're part of the Microsoft team account." />
<WriteLinesToFile File="$(PublishDir)xunit-excludes.txt" Lines="$(_withoutCategories.Replace(';', '%0dcategory='))" />
<ItemGroup>
<AotInputAssemblies Condition="'$(RunAOTCompilation)' == 'true'" Include="$(PublishDir)*.dll" Exclude="$(PublishDir)System.Runtime.WindowsRuntime.dll">
<AotArguments>@(MonoAOTCompilerDefaultAotArguments, ';')</AotArguments>
<ProcessArguments>@(MonoAOTCompilerDefaultProcessArguments, ';')</ProcessArguments>
</AotInputAssemblies>
<BundleAssemblies Condition="'$(RunAOTCompilation)' != 'true'" Include="$(PublishDir)*.dll" />
</ItemGroup>
<MonoAOTCompiler Condition="'$(RunAOTCompilation)' == 'true'"
CompilerBinaryPath="$(RuntimePackNativeDir)cross\mono-aot-cross"
Mode="Full"
OutputType="AsmOnly"
Assemblies="@(AotInputAssemblies)"
UseLLVM="$(MonoEnableLLVM)"
LLVMPath="$(RuntimePackNativeDir)cross">
<Output TaskParameter="CompiledAssemblies" ItemName="BundleAssemblies" />
</MonoAOTCompiler>
<!-- Run App bundler, it uses AOT libs (if needed), link all native bits, compile simple UI (written in ObjC)
and produce an app bundle (with xcode project) -->
<RemoveDir Directories="$(BundleDir)" />
<AppleAppBuilderTask
Arch="$(TargetArchitecture)"
ProjectName="$(AssemblyName)"
MonoRuntimeHeaders="$(RuntimePackNativeDir)include\mono-2.0"
Assemblies="@(BundleAssemblies)"
MainLibraryFileName="AppleTestRunner.dll"
UseConsoleUITemplate="True"
GenerateXcodeProject="True"
BuildAppBundle="True"
Optimized="True"
DevTeamProvisioning="$(DevTeamProvisioning)"
OutputDirectory="$(BundleDir)"
AppDir="$(PublishDir)">
<Output TaskParameter="AppBundlePath" PropertyName="AppBundlePath" />
<Output TaskParameter="XcodeProjectPath" PropertyName="XcodeProjectPath" />
</AppleAppBuilderTask>
<Message Importance="High" Text="Xcode: $(XcodeProjectPath)"/>
<Message Importance="High" Text="App: $(AppBundlePath)"/>
<!-- This app is now can be consumed by xharness CLI to deploy on a device or simulator -->
</Target>
<Target Name="AddTestRunnersToPublishedFiles"
AfterTargets="ComputeFilesToPublish">
<ItemGroup>
<_runnerFilesToPublish Include="$(AndroidTestRunnerDir)*" Condition="'$(TargetOS)' == 'Android'" />
<_runnerFilesToPublish Include="$(AppleTestRunnerDir)*" Condition="'$(TargetOS)' == 'iOS' or '$(TargetOS)' == 'tvOS'" />
<ResolvedFileToPublish Include="@(_runnerFilesToPublish)" RelativePath="%(FileName)%(Extension)" CopyToPublishDirectory="PreserveNewest" />
</ItemGroup>
</Target>
<Target Name="AddFrameworkReference">
<ItemGroup>
<FrameworkReference Include="$(SharedFrameworkName)" />
</ItemGroup>
</Target>
<Target Name="UpdateRuntimePack"
DependsOnTargets="AddFrameworkReference;ResolveFrameworkReferences">
<ItemGroup>
<ResolvedRuntimePack Update="@(ResolvedRuntimePack)" PackageDirectory="$(RuntimePackDir)" />
</ItemGroup>
</Target>
<Target Name="PublishTestAsSelfContained"
Condition="'$(IsCrossTargetingBuild)' != 'true'"
AfterTargets="Build"
DependsOnTargets="UpdateRuntimePack;Publish;BundleTestAppleApp;BundleTestAndroidApp" />
</Project>