Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Configuration.props
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
<AndroidMxeInstallPrefix Condition=" '$(HostOS)' == 'Darwin' ">$(HostHomebrewPrefix)</AndroidMxeInstallPrefix>
<AndroidSdkDirectory Condition=" '$(AndroidSdkDirectory)' == '' ">$(AndroidToolchainDirectory)\sdk</AndroidSdkDirectory>
<AndroidNdkDirectory Condition=" '$(AndroidNdkDirectory)' == '' ">$(AndroidToolchainDirectory)\ndk</AndroidNdkDirectory>
<DotNetPreviewPath Condition=" '$(DotNetPreviewPath)' == '' ">$(AndroidToolchainDirectory)\dotnet\</DotNetPreviewPath>
<DotNetPreviewTool Condition=" '$(DotNetPreviewTool)' == '' ">$(DotNetPreviewPath)dotnet</DotNetPreviewTool>
<AndroidCmakeVersion Condition=" '$(AndroidCmakeVersion)' == '' ">3.10.2</AndroidCmakeVersion>
<AndroidCmakeVersionPath Condition=" '$(AndroidCmakeVersionPath)' == '' ">$(AndroidCmakeVersion).4988404</AndroidCmakeVersionPath>
<AndroidSdkCmakeDirectory>$(AndroidSdkDirectory)\cmake\$(AndroidCmakeVersionPath)</AndroidSdkCmakeDirectory>
Expand Down
13 changes: 3 additions & 10 deletions build-tools/automation/azure-pipelines-oss.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@ variables:
EXTRA_MSBUILD_ARGS: /p:AutoProvision=True /p:AutoProvisionUsesSudo=True /p:IgnoreMaxMonoVersion=False
PREPARE_FLAGS: PREPARE_CI=1 PREPARE_CI_PR=1
DotNetCoreVersion: 3.1.201
# Version number from: https://github.com/dotnet/installer#installers-and-binaries
DotNetCorePreviewVersion: 5.0.100-rc.2.20459.1
GitHub.Token: $(github--pat--vs-mobiletools-engineering-service2)


stages:
- stage: mac_stage
displayName: Mac
Expand All @@ -52,13 +49,9 @@ stages:
clean: true # Executes: git clean -ffdx && git reset --hard HEAD
submodules: recursive

- template: yaml-templates/use-dot-net.yaml
parameters:
version: $(DotNetCorePreviewVersion)
remove_dotnet: true

- template: yaml-templates/use-dot-net.yaml
parameters:
- task: UseDotNet@2
displayName: install .NET Core $(DotNetCoreVersion)
inputs:
version: $(DotNetCoreVersion)

- bash: |
Expand Down
22 changes: 6 additions & 16 deletions build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ variables:
TestAssembliesArtifactName: test-assemblies
NUnitConsoleVersion: 3.11.1
DotNetCoreVersion: 3.1.201
# Version number from: https://github.com/dotnet/installer#installers-and-binaries
DotNetCorePreviewVersion: 5.0.100-rc.2.20480.7
HostedMacMojave: Hosted Mac Internal Mojave
HostedMac: Hosted Mac Internal
HostedWinVS2019: Hosted Windows 2019 with VS2019
Expand Down Expand Up @@ -137,13 +135,9 @@ stages:
- script: echo "##vso[task.setvariable variable=JI_JAVA_HOME]$HOME/Library/Android/$(XA.Jdk11.Folder)"
displayName: set JI_JAVA_HOME

- template: yaml-templates/use-dot-net.yaml
parameters:
version: $(DotNetCorePreviewVersion)
remove_dotnet: true

- template: yaml-templates/use-dot-net.yaml
parameters:
- task: UseDotNet@2
displayName: install .NET Core $(DotNetCoreVersion)
inputs:
version: $(DotNetCoreVersion)

- template: install-certificates.yml@yaml
Expand Down Expand Up @@ -287,13 +281,9 @@ stages:
echo ##vso[task.setvariable variable=JI_JAVA_HOME]%USERPROFILE%\android-toolchain\$(XA.Jdk11.Folder)
displayName: set JI_JAVA_HOME

- template: yaml-templates\use-dot-net.yaml
parameters:
version: $(DotNetCorePreviewVersion)
remove_dotnet: true

- template: yaml-templates\use-dot-net.yaml
parameters:
- task: UseDotNet@2
displayName: install .NET Core $(DotNetCoreVersion)
inputs:
version: $(DotNetCoreVersion)

# Downgrade the XA .vsix installed into the instance of VS that we are building with so that we don't restore/build against a test version.
Expand Down
23 changes: 15 additions & 8 deletions build-tools/automation/yaml-templates/run-nunit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,22 @@ parameters:

steps:
- powershell: |
if ("${{ parameters.useDotNet }}" -eq $true) {
Write-Host '##vso[task.setvariable variable=TestResultsFormat]VSTest'
dotnet test ${{ parameters.testAssembly }} --results-directory . --logger "trx;LogFileName=${{ parameters.testResultsFile }}" ${{ parameters.dotNetTestExtraArgs }} -- NUnit.NumberOfTestWorkers=${{ parameters.workers }}
} elseif ([Environment]::OSVersion.Platform -eq "Unix") {
Write-Host '##vso[task.setvariable variable=TestResultsFormat]NUnit'
mono ${{ parameters.nunitConsole }} ${{ parameters.testAssembly }} --result ${{ parameters.testResultsFile }} --workers=${{ parameters.workers }} ${{ parameters.nunitConsoleExtraArgs }}
if ([Environment]::OSVersion.Platform -eq "Unix") {
if ("${{ parameters.useDotNet }}" -eq $true) {
Write-Host '##vso[task.setvariable variable=TestResultsFormat]VSTest'
& $env:HOME/Library/Android/dotnet/dotnet test ${{ parameters.testAssembly }} --results-directory . --logger "trx;LogFileName=${{ parameters.testResultsFile }}" ${{ parameters.dotNetTestExtraArgs }} -- NUnit.NumberOfTestWorkers=${{ parameters.workers }}
} else {
Write-Host '##vso[task.setvariable variable=TestResultsFormat]NUnit'
mono ${{ parameters.nunitConsole }} ${{ parameters.testAssembly }} --result ${{ parameters.testResultsFile }} --workers=${{ parameters.workers }} ${{ parameters.nunitConsoleExtraArgs }}
}
} else {
Write-Host '##vso[task.setvariable variable=TestResultsFormat]NUnit'
${{ parameters.nunitConsole }} ${{ parameters.testAssembly }} --result ${{ parameters.testResultsFile }} --workers=${{ parameters.workers }} ${{ parameters.nunitConsoleExtraArgs }}
if ("${{ parameters.useDotNet }}" -eq $true) {
Write-Host '##vso[task.setvariable variable=TestResultsFormat]VSTest'
& $env:USERPROFILE\android-toolchain\dotnet\dotnet.exe test ${{ parameters.testAssembly }} --results-directory . --logger "trx;LogFileName=${{ parameters.testResultsFile }}" ${{ parameters.dotNetTestExtraArgs }} -- NUnit.NumberOfTestWorkers=${{ parameters.workers }}
} else {
Write-Host '##vso[task.setvariable variable=TestResultsFormat]NUnit'
${{ parameters.nunitConsole }} ${{ parameters.testAssembly }} --result ${{ parameters.testResultsFile }} --workers=${{ parameters.workers }} ${{ parameters.nunitConsoleExtraArgs }}
}
}
if ($LASTEXITCODE -ne 0) {
Write-Host "##vso[task.logissue type=error]Test suite had $LASTEXITCODE failure(s)."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,9 @@ steps:
displayName: set JI_JAVA_HOME
condition: and(succeeded(), eq(variables['agent.os'], 'Windows_NT'))

- template: use-dot-net.yaml
parameters:
version: $(DotNetCorePreviewVersion)
remove_dotnet: true

- template: use-dot-net.yaml
parameters:
- task: UseDotNet@2
displayName: install .NET Core $(DotNetCoreVersion)
inputs:
version: $(DotNetCoreVersion)

- script: |
Expand Down
33 changes: 0 additions & 33 deletions build-tools/automation/yaml-templates/use-dot-net.yaml

This file was deleted.

14 changes: 7 additions & 7 deletions build-tools/create-packs/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@
</Target>

<Target Name="CreateAllRuntimePacks" >
<Exec Command="dotnet pack -p:Configuration=$(Configuration) -p:AndroidRID=android.21-arm -p:AndroidABI=armeabi-v7a &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Runtime.proj&quot;" />
<Exec Command="dotnet pack -p:Configuration=$(Configuration) -p:AndroidRID=android.21-arm64 -p:AndroidABI=arm64-v8a &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Runtime.proj&quot;" />
<Exec Command="dotnet pack -p:Configuration=$(Configuration) -p:AndroidRID=android.21-x86 -p:AndroidABI=x86 &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Runtime.proj&quot;" />
<Exec Command="dotnet pack -p:Configuration=$(Configuration) -p:AndroidRID=android.21-x64 -p:AndroidABI=x86_64 &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Runtime.proj&quot;" />
<Exec Command="$(DotNetPreviewTool) pack -p:Configuration=$(Configuration) -p:AndroidRID=android.21-arm -p:AndroidABI=armeabi-v7a &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Runtime.proj&quot;" />
<Exec Command="$(DotNetPreviewTool) pack -p:Configuration=$(Configuration) -p:AndroidRID=android.21-arm64 -p:AndroidABI=arm64-v8a &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Runtime.proj&quot;" />
<Exec Command="$(DotNetPreviewTool) pack -p:Configuration=$(Configuration) -p:AndroidRID=android.21-x86 -p:AndroidABI=x86 &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Runtime.proj&quot;" />
<Exec Command="$(DotNetPreviewTool) pack -p:Configuration=$(Configuration) -p:AndroidRID=android.21-x64 -p:AndroidABI=x86_64 &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Runtime.proj&quot;" />
</Target>

<Target Name="CreateAllPacks"
DependsOnTargets="CreateAllRuntimePacks" >
<Exec Command="dotnet pack -p:Configuration=$(Configuration) &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Ref.proj&quot;" />
<Exec Command="dotnet pack -p:Configuration=$(Configuration) &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Sdk.proj&quot;" />
<Exec Command="dotnet pack -p:Configuration=$(Configuration) &quot;$(MSBuildThisFileDirectory)Xamarin.Android.Sdk.Lite.proj&quot;" />
<Exec Command="$(DotNetPreviewTool) pack -p:Configuration=$(Configuration) &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Ref.proj&quot;" />
<Exec Command="$(DotNetPreviewTool) pack -p:Configuration=$(Configuration) &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Sdk.proj&quot;" />
<Exec Command="$(DotNetPreviewTool) pack -p:Configuration=$(Configuration) &quot;$(MSBuildThisFileDirectory)Xamarin.Android.Sdk.Lite.proj&quot;" />
</Target>

</Project>
6 changes: 6 additions & 0 deletions build-tools/scripts/Paths.targets
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,10 @@
Importance="High"
/>
</Target>
<Target Name="GetDotNetPreviewPath">
<Message
Text="$(DotNetPreviewPath)"
Importance="High"
/>
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ static class KnownProperties
public const string Configuration = "Configuration";
public const string CommandLineToolsVersion = nameof (CommandLineToolsVersion);
public const string CommandLineToolsFolder = nameof (CommandLineToolsFolder);
public const string DotNetPreviewPath = "DotNetPreviewPath";
public const string EmulatorVersion = "EmulatorVersion";
public const string EmulatorPkgRevision = "EmulatorPkgRevision";
public const string IgnoreMaxMonoVersion = "IgnoreMaxMonoVersion";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace Xamarin.Android.Prepare
properties.Add (KnownProperties.Configuration, StripQuotes ("@Configuration@"));
properties.Add (KnownProperties.CommandLineToolsFolder, StripQuotes ("@CommandLineToolsFolder@"));
properties.Add (KnownProperties.CommandLineToolsVersion, StripQuotes ("@CommandLineToolsVersion@"));
properties.Add (KnownProperties.DotNetPreviewPath, StripQuotes (@"@DotNetPreviewPath@"));
properties.Add (KnownProperties.EmulatorVersion, StripQuotes ("@EmulatorVersion@"));
properties.Add (KnownProperties.EmulatorPkgRevision, StripQuotes ("@EmulatorPkgRevision@"));
properties.Add (KnownProperties.IgnoreMaxMonoVersion, StripQuotes ("@IgnoreMaxMonoVersion@"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,10 @@ partial class Paths

static string? hostRuntimeDir;
}

partial class Urls
{
public static readonly Uri DotNetInstallScript = new Uri ("https://dot.net/v1/dotnet-install.sh");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@ partial class Paths
public static readonly string MonoRuntimeHostMingwNativeLibraryPrefix = Path.Combine ("..", "bin");
public const string NdkToolchainOSTag = "windows-x86_64";
}

partial class Urls
{
public static readonly Uri DotNetInstallScript = new Uri ("https://dot.net/v1/dotnet-install.ps1");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public static partial class Defaults
public static readonly Version JetBrainsOpenJDK8Version = new Version (Configurables.JetBrainsOpenJDK8VersionFull);
public static readonly Version JetBrainsOpenJDK8Release = new Version (Configurables.JetBrainsOpenJDK8Release);

// Version number from: https://github.com/dotnet/installer#installers-and-binaries
public const string DotNetPreviewVersion = "5.0.100-rc.2.20480.7";
public const string DotNetTestRuntimeVersion = "3.1.3";

// Mono runtimes
public const string DebugFileExtension = ".pdb";
public const string MonoHostMingwRuntimeNativeLibraryExtension = WindowsDLLSuffix;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ protected override void AddSteps (Context context)
// Install essential tools, should they be missing
context.SetCondition (KnownConditions.EnsureEssential, true);

Steps.Add (new Step_InstallDotNetPreview ());
Steps.Add (new Step_GenerateFiles (atBuildStart: true, onlyRequired: true));
Steps.Add (new Step_PrepareExternalJavaInterop ());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ protected override void AddSteps (Context context)
throw new ArgumentNullException (nameof (context));

Steps.Add (new Step_ShowEnabledRuntimes ());
Steps.Add (new Step_InstallDotNetPreview ());
Steps.Add (new Step_InstallJetBrainsOpenJDK8 ());
Steps.Add (new Step_InstallJetBrainsOpenJDK11 ());
Steps.Add (new Step_Android_SDK_NDK ());
Expand Down
118 changes: 118 additions & 0 deletions build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading.Tasks;

namespace Xamarin.Android.Prepare
{
class Step_InstallDotNetPreview : StepWithDownloadProgress
{
public Step_InstallDotNetPreview ()
: base ("Install required .NET Preview SDK locally")
{ }

protected override async Task<bool> Execute (Context context)
{
var dotnetPath = context.Properties.GetRequiredValue (KnownProperties.DotNetPreviewPath);
dotnetPath = dotnetPath.TrimEnd (new char [] { Path.DirectorySeparatorChar });
var dotnetPreviewVersion = Configurables.Defaults.DotNetPreviewVersion;
var dotnetTestRuntimeVersion = Configurables.Defaults.DotNetTestRuntimeVersion;

// Delete any custom Microsoft.Android packs that may have been installed by test runs. Other ref/runtime packs will be ignored.
var packsPath = Path.Combine (dotnetPath, "packs");
if (Directory.Exists (packsPath)) {
foreach (var packToRemove in Directory.EnumerateDirectories (packsPath).Where (p => new DirectoryInfo (p).Name.Contains ("Android"))) {
Log.StatusLine ($"Removing Android pack: {packToRemove}");
Utilities.DeleteDirectory (packToRemove);
}
}

// Delete any unnecessary SDKs if they exist.
var sdkPath = Path.Combine (dotnetPath, "sdk");
if (Directory.Exists (sdkPath)) {
foreach (var sdkToRemove in Directory.EnumerateDirectories (sdkPath).Where (s => new DirectoryInfo (s).Name != dotnetPreviewVersion)) {
Log.StatusLine ($"Removing out of date SDK: {sdkToRemove}");
Utilities.DeleteDirectory (sdkToRemove);
}
}

if (!await InstallDotNetAsync (context, dotnetPath, dotnetPreviewVersion)) {
Log.ErrorLine ($"Installation of dotnet SDK {dotnetPreviewVersion} failed.");
return false;
}

if (!await InstallDotNetAsync (context, dotnetPath, dotnetTestRuntimeVersion, runtimeOnly: true)) {
Log.ErrorLine ($"Installation of dotnet runtime {dotnetTestRuntimeVersion} failed.");
return false;
}

return true;
}

async Task<bool> InstallDotNetAsync (Context context, string dotnetPath, string version, bool runtimeOnly = false)
{
if (Directory.Exists (Path.Combine (dotnetPath, "sdk", version)) && !runtimeOnly) {
Log.Status ($"dotnet SDK version ");
Log.Status (version, ConsoleColor.Yellow);
Log.StatusLine (" already installed in: ", Path.Combine (dotnetPath, "sdk", version), tailColor: ConsoleColor.Cyan);
return true;
}

if (Directory.Exists (Path.Combine (dotnetPath, "shared", "Microsoft.NETCore.App", version)) && runtimeOnly) {
Log.Status ($"dotnet runtime version ");
Log.Status (version, ConsoleColor.Yellow);
Log.StatusLine (" already installed in: ", Path.Combine (dotnetPath, "shared", "Microsoft.NETCore.App", version), tailColor: ConsoleColor.Cyan);
return true;
}

Uri dotnetScriptUrl = Configurables.Urls.DotNetInstallScript;
string dotnetScriptPath = Path.Combine (dotnetPath, Path.GetFileName (dotnetScriptUrl.LocalPath));
if (File.Exists (dotnetScriptPath))
Utilities.DeleteFile (dotnetScriptPath);

Log.StatusLine ("Downloading dotnet-install...");

(bool success, ulong size, HttpStatusCode status) = await Utilities.GetDownloadSizeWithStatus (dotnetScriptUrl);
if (!success) {
if (status == HttpStatusCode.NotFound)
Log.ErrorLine ("dotnet-install URL not found");
else
Log.ErrorLine ("Failed to obtain dotnet-install size. HTTP status code: {status} ({(int)status})");
return false;
}

DownloadStatus downloadStatus = Utilities.SetupDownloadStatus (context, size, context.InteractiveSession);
Log.StatusLine ($" {context.Characters.Link} {dotnetScriptUrl}", ConsoleColor.White);
await Download (context, dotnetScriptUrl, dotnetScriptPath, "dotnet-install", Path.GetFileName (dotnetScriptUrl.LocalPath), downloadStatus);

if (!File.Exists (dotnetScriptPath)) {
Log.ErrorLine ($"Download of dotnet-install from {dotnetScriptUrl} failed");
return false;
}

Log.StatusLine ($"Installing dotnet SDK/runtime '{version}'...");

if (Context.IsWindows) {
var args = new List<string> {
"-NoProfile", "-ExecutionPolicy", "unrestricted", "-file", dotnetScriptPath,
"-Version", version, "-InstallDir", dotnetPath, "-Verbose"
};
if (runtimeOnly)
args.AddRange (new string [] { "-Runtime", "dotnet" });

return Utilities.RunCommand ("powershell.exe", args.ToArray ());
} else {
var args = new List<string> {
dotnetScriptPath, "--version", version, "--install-dir", dotnetPath, "--verbose"
};
if (runtimeOnly)
args.AddRange (new string [] { "-Runtime", "dotnet" });

return Utilities.RunCommand ("bash", args.ToArray ());
}
}

}
}
1 change: 1 addition & 0 deletions build-tools/xaprepare/xaprepare/xaprepare.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
<Compile Include="Steps\Step_GenerateCGManifest.cs" />
<Compile Include="Steps\Step_GenerateFiles.cs" />
<Compile Include="Steps\Step_Get_Windows_Binutils.cs" />
<Compile Include="Steps\Step_InstallDotNetPreview.cs" />
<Compile Include="Steps\Step_InstallJetBrainsOpenJDK.cs" />
<Compile Include="Steps\Step_InstallMonoRuntimes.cs" />
<Compile Include="Steps\Step_PrepareExternal.cs" />
Expand Down
Loading