Download and unzip ADB from android tools (#27)

This commit is contained in:
Matt Galbraith 2020-04-15 11:58:59 -07:00 коммит произвёл GitHub
Родитель 0d91472e0a
Коммит 24462da9a0
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 33 добавлений и 5 удалений

3
.gitignore поставляемый
Просмотреть файл

@ -352,3 +352,6 @@ MigrationBackup/
# Local installations of .net core
.dotnet/
# Locally restored packages (when simulating AzDO build)
.packages/

Просмотреть файл

@ -1,6 +1,6 @@
{
"tools": {
"dotnet": "3.1.101",
"dotnet": "3.1.201",
"runtimes": {
"dotnet": [
"2.1.11"

Просмотреть файл

@ -15,14 +15,14 @@ namespace Microsoft.DotNet.XHarness.Android
{
#region Constructor and state variables
// When packaged as a DotNet CLI tool, this should always be a minimal adb.exe
private const string DefaultAdbExePath = @"..\..\..\content\adb\adb.exe";
private const string AdbEnvironmentVariableName = "ADB_EXE_PATH";
private readonly string _absoluteAdbExePath;
private readonly ILogger _log;
public AdbRunner(ILogger log, string adbExePath = ".\\adb.exe")
public AdbRunner(ILogger log, string adbExePath = DefaultAdbExePath)
{
_log = log ?? throw new ArgumentNullException(nameof(log));

Просмотреть файл

@ -10,8 +10,9 @@
<NoWarn>CS8002;</NoWarn>
</PropertyGroup>
<!-- Suppress NU5100 because there are ADB .DLLs we don't reference which we want as 'content' type -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>$(NoWarn);1701;1702;1705;1591;NU5105</NoWarn>
<NoWarn>$(NoWarn);1701;1702;1705;1591;NU5105;NU5100</NoWarn>
</PropertyGroup>
<ItemGroup>
@ -22,4 +23,28 @@
<ItemGroup>
<ProjectReference Include="..\Microsoft.DotNet.XHarness.Android\Microsoft.DotNet.XHarness.Android.csproj" />
</ItemGroup>
<PropertyGroup>
<!-- When updating, avoid using 'latest' url as this can make the same commit build differently on different days -->
<WindowsAndroidSdkUrl>https://dl.google.com/android/repository/platform-tools_r29.0.6-windows.zip</WindowsAndroidSdkUrl>
<WindowsAndroidSdkFileName>windows-android-platform-tools.zip</WindowsAndroidSdkFileName>
<!-- TODO: Figure out minimal set of binaries for linux, then copy them. Until then this is unused. -->
<LinuxAndroidSdkUrl>https://dl.google.com/android/repository/platform-tools_r29.0.6-linux.zip</LinuxAndroidSdkUrl>
<LinuxAndroidSdkFileName>linux-android-platform-tools.zip</LinuxAndroidSdkFileName>
</PropertyGroup>
<Target Name="DownloadAndroidSdks" BeforeTargets="Build" >
<DownloadFile SourceUrl="$(WindowsAndroidSdkUrl)" DestinationFolder="$(IntermediateOutputPath)/android-tools/" DestinationFileName="$(WindowsAndroidSdkFileName)" SkipUnchangedFiles="True" />
<Unzip SourceFiles="$(IntermediateOutputPath)/android-tools/$(WindowsAndroidSdkFileName)" DestinationFolder="$(IntermediateOutputPath)/android-tools-unzipped/windows" OverwriteReadOnlyFiles="true" />
<ItemGroup>
<WindowsAdbFiles Include="$(IntermediateOutputPath)/android-tools-unzipped/windows/platform-tools/adb*" />
<Content Include="@(WindowsAdbFiles)">
<Pack>true</Pack>
<PackagePath>content/adb</PackagePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Target>
</Project>