From e987ac458536e59a8329a06d5c5d5f4d4ea2c6b6 Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Thu, 15 Feb 2024 23:36:06 +0000 Subject: [PATCH] [xabuild] Remove xabuild, unused pipelines (#8720) Context: 4b33a6229c9babde795dea48d20ca86d8f9f9c97 Remove `tools/xabuild` completely. It is no longer required; use `dotnet-local.*` instead (4b33a622). Additionally, remove unneeded pipelines. `build.groovy` and `azure-pipelines-oss.yaml` (among others) haven't been executed in *years*; there is no need to keep these files around. --- .github/CODEOWNERS | 1 - Documentation/guides/profiling.md | 44 -- Makefile | 12 - before.Xamarin.Android.sln.targets | 1 - .../automation/azure-pipelines-oss.yaml | 201 -------- build-tools/automation/build.groovy | 458 ------------------ build-tools/automation/build.linux.groovy | 266 ---------- build-tools/scripts/RunTests.targets | 208 -------- .../Utilities}/SymbolicLink.cs | 0 .../Xamarin.Android.Build.Tests.csproj | 1 - .../AndroidManifest.xml | 1 - tests/RunApkTests.targets | 137 ------ .../api-compatibility.targets | 1 + tools/scripts/xabuild | 189 -------- tools/xabuild/App.config | 70 --- tools/xabuild/XABuild.cs | 191 -------- tools/xabuild/XABuildPaths.cs | 334 ------------- tools/xabuild/xabuild.csproj | 46 -- 18 files changed, 1 insertion(+), 2160 deletions(-) delete mode 100644 build-tools/automation/azure-pipelines-oss.yaml delete mode 100644 build-tools/automation/build.groovy delete mode 100644 build-tools/automation/build.linux.groovy delete mode 100644 build-tools/scripts/RunTests.targets rename {tools/xabuild => src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities}/SymbolicLink.cs (100%) delete mode 100644 tests/RunApkTests.targets delete mode 100755 tools/scripts/xabuild delete mode 100644 tools/xabuild/App.config delete mode 100644 tools/xabuild/XABuild.cs delete mode 100644 tools/xabuild/XABuildPaths.cs delete mode 100644 tools/xabuild/xabuild.csproj diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 2e4fb471386..2b363aeffed 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -64,4 +64,3 @@ /tools/jit-times @jonpryor /tools/setup-windows @jonathanpeppers @jonpryor /tools/tmt @grendello -/tools/xabuild @jonathanpeppers @jonpryor diff --git a/Documentation/guides/profiling.md b/Documentation/guides/profiling.md index 4947c449368..cd2c121c30f 100644 --- a/Documentation/guides/profiling.md +++ b/Documentation/guides/profiling.md @@ -517,47 +517,3 @@ in the build output window. [projectsystemtools]: https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.ProjectSystemTools [diagnostic]: https://docs.microsoft.com/xamarin/android/troubleshooting/troubleshooting#diagnostic-msbuild-output - -## Profiling MSBuild with the Mono Profiler - -Similiar to how you can [use the Mono Profiler](#profiling-managed-code) -on Android, you can also profile MSBuild with `mono --profile`. With a -local build of xamarin-android on macOS, you can run: - - $ mono --profile=log:calls,alloc ./bin/Release/bin/xabuild.exe YourProject.csproj - -`xabuild.exe` is a tool for running MSBuild using your local -xamarin-android working tree. I would also recommend using a `Release` -build of Xamarin.Android when profiling. - -This will create an `output.mlpd` file in the current directory. To -view its contents: - - $ mprof-report output.mlpd - -This will display output such as: - - Allocation summary - Bytes Count Average Type name - 165520032 19363 8548 System.Byte[] - 28813336 432701 66 System.String - - Method call summary - Total(ms) Self(ms) Calls Method name - 139368 1 703 (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr) - 132472 132472 287 (wrapper managed-to-native) System.Threading.WaitHandle:Wait_internal (intptr*,int,bool,int) - 71685 2 2 Microsoft.Build.BackEnd.RequestBuilder/DedicatedThreadsTaskScheduler:b__6_0 () - -> NOTE: I've hit an error in the past such as: `unhandled profiler -> event: 0x6f at file offset: 3095192 + 60144 (len: 62655)`. Sometimes -> I have just tried again, making sure I'm profiling a `Release` build. - -You can also get stacktrace information: - - $ mprof-report --traces output.mlpd > output.txt - -I would recomment redirecting this output to a file, as it can -generate text well over 100MB! - -See the [Mono documentation][mono_docs] for more details about the -profiler. diff --git a/Makefile b/Makefile index 2e52baddf1c..01a115fe84f 100644 --- a/Makefile +++ b/Makefile @@ -117,18 +117,6 @@ ifneq ($(PACKAGES),) APK_TESTS_PROP = /p:ApkTests='"$(PACKAGES)"' endif -run-apk-tests: - _r=0 ; \ - $(call MSBUILD_BINLOG,run-apk-tests,,Test) $(TEST_TARGETS) /t:RunApkTests /p:RunApkTestsTarget=RunPerformanceApkTests $(APK_TESTS_PROP) || _r=1 ; \ - $(call MSBUILD_BINLOG,run-apk-tests,,Test) $(TEST_TARGETS) /t:RunApkTests $(APK_TESTS_PROP) || _r=1 ; \ - exit $$_r - -run-performance-tests: - _r=0 ; \ - $(call MSBUILD_BINLOG,run-apk-tests,,Test) $(TEST_TARGETS) /t:RunApkTests /p:RunApkTestsTarget=RunPerformanceApkTests $(APK_TESTS_PROP) || _r=1 ; \ - $(call MSBUILD_BINLOG,run-performance-tests,,Test) $(TEST_TARGETS) /t:RunPerformanceTests || _r=1 ; \ - exit $$_r - list-nunit-tests: $(MSBUILD) $(MSBUILD_FLAGS) $(TEST_TARGETS) /t:ListNUnitTests diff --git a/before.Xamarin.Android.sln.targets b/before.Xamarin.Android.sln.targets index 2daa6bc6865..2df7f564816 100644 --- a/before.Xamarin.Android.sln.targets +++ b/before.Xamarin.Android.sln.targets @@ -3,6 +3,5 @@ - \ No newline at end of file diff --git a/build-tools/automation/azure-pipelines-oss.yaml b/build-tools/automation/azure-pipelines-oss.yaml deleted file mode 100644 index 0fbbed4d95f..00000000000 --- a/build-tools/automation/azure-pipelines-oss.yaml +++ /dev/null @@ -1,201 +0,0 @@ -# Xamarin.Android-OSS Pipeline - -name: $(Build.SourceBranchName)-$(Build.SourceVersion)-$(Rev:r) - -trigger: -- main -- d16-* -- release/* - -pr: - autoCancel: false - branches: - include: - - main - - d16-* - - release/* - -# Global variables -# Predefined variables: https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml -# https://dev.azure.com/xamarin/public/_apps/hub/ms.vss-ciworkflow.build-ci-hub?_a=edit-build-definition&id=48&view=Tab_Variables -variables: -- template: yaml-templates/variables.yaml -- name: EXTRA_MSBUILD_ARGS - value: /p:AutoProvision=True /p:AutoProvisionUsesSudo=True /p:IgnoreMaxMonoVersion=False -- name: PREPARE_FLAGS - value: PREPARE_CI=1 PREPARE_CI_PR=1 - -stages: -- stage: mac_stage - displayName: Mac - condition: eq(variables['EnableMacStage'], 'true') # The variable is defined on the pipeline definition - jobs: - - job: mac_build - displayName: macOS > Build - pool: - name: VSEng-Xamarin-RedmondMac-Android-OSS - demands: - - agent.osversionfamily -equals 10.15 - timeoutInMinutes: 180 - cancelTimeoutInMinutes: 5 - workspace: - clean: all - - steps: - - checkout: self # https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema#checkout - path: xamarin-android - clean: true # Executes: git clean -ffdx && git reset --hard HEAD - submodules: recursive - - - template: yaml-templates/use-dot-net.yaml - parameters: - remove_dotnet: true - - - bash: | - keychains=`security list-keychains` - if [[ "$keychains" =~ "\"/Users/${USER}/Library/Keychains/builder.keychain-db\"" ]]; then - security unlock-keychain -p $(login-xambot-azure-devops-agent-password) builder.keychain - else - security create-keychain -p $(login-xambot-azure-devops-agent-password) builder.keychain - fi - security -v list-keychains -s builder.keychain - security -v default-keychain -s builder.keychain - security -v set-keychain-settings -lut 7200 - displayName: swap default keychain - - - task: provisionator@2 - displayName: Install Xcode - inputs: - github_token: $(GitHub.Token) - provisioning_script: $(Build.SourcesDirectory)/build-tools/provisioning/xcode.csx - provisioning_extra_args: '-v -v -v -v' - - - bash: | - keychains=`security list-keychains` - if [[ "$keychains" =~ "\"/Users/${USER}/Library/Keychains/builder.keychain-db\"" ]]; then - security unlock-keychain -p $(login-xambot-azure-devops-agent-password) builder.keychain - security -v delete-keychain builder.keychain - security -v default-keychain -s login.keychain - security -v list-keychains -s login.keychain - fi - displayName: restore default keychain - - # Prepare and build everything - - script: > - echo "make prepare-update-mono CONFIGURATION=$(XA.Build.Configuration) $(PREPARE_FLAGS) MSBUILD_ARGS='$(EXTRA_MSBUILD_ARGS)'" && - make prepare-update-mono CONFIGURATION=$(XA.Build.Configuration) $(PREPARE_FLAGS) MSBUILD_ARGS='$(EXTRA_MSBUILD_ARGS)' - workingDirectory: $(Build.SourcesDirectory) - displayName: make prepare-update-mono - - - script: > - echo "make prepare CONFIGURATION=$(XA.Build.Configuration) $(PREPARE_FLAGS) MSBUILD_ARGS='$(EXTRA_MSBUILD_ARGS)'" && - make prepare CONFIGURATION=$(XA.Build.Configuration) $(PREPARE_FLAGS) MSBUILD_ARGS='$(EXTRA_MSBUILD_ARGS)' - workingDirectory: $(Build.SourcesDirectory) - displayName: make prepare - - - script: > - echo "make jenkins CONFIGURATION=$(XA.Build.Configuration) PREPARE_CI=1 PREPARE_AUTOPROVISION=1" && - make jenkins CONFIGURATION=$(XA.Build.Configuration) PREPARE_CI=1 PREPARE_AUTOPROVISION=1 - workingDirectory: $(Build.SourcesDirectory) - displayName: make jenkins - - - script: > - echo "make create-installers CONFIGURATION=$(XA.Build.Configuration)" && - make create-installers CONFIGURATION=$(XA.Build.Configuration) - workingDirectory: $(Build.SourcesDirectory) - displayName: create installers - - - script: > - mkdir -p bin/Build$(XA.Build.Configuration)/$(InstallerArtifactName) && - cp bin/Build$(XA.Build.Configuration)/*.vsix bin/Build$(XA.Build.Configuration)/$(InstallerArtifactName) && - cp bin/Build$(XA.Build.Configuration)/*.pkg bin/Build$(XA.Build.Configuration)/$(InstallerArtifactName) - workingDirectory: $(Build.SourcesDirectory) - displayName: copy installers - - - task: PublishPipelineArtifact@1 - displayName: upload installers - inputs: - artifactName: $(InstallerArtifactName) - macOS and Windows - targetPath: $(Build.SourcesDirectory)/bin/Build$(XA.Build.Configuration)/$(InstallerArtifactName) - - - task: PublishPipelineArtifact@1 - displayName: upload nupkgs - inputs: - artifactName: $(NuGetArtifactName) - macOS - targetPath: $(Build.SourcesDirectory)/bin/Build$(XA.Build.Configuration)/$(NuGetArtifactName) - - - script: > - echo "all-tests CONFIGURATION=$(XA.Build.Configuration)" && - make all-tests CONFIGURATION=$(XA.Build.Configuration) - workingDirectory: $(Build.SourcesDirectory) - displayName: make all-tests - - - script: > - echo "make run-performance-tests CONFIGURATION=$(XA.Build.Configuration)" && - make run-performance-tests CONFIGURATION=$(XA.Build.Configuration) - workingDirectory: $(Build.SourcesDirectory) - displayName: run performance tests - condition: and(succeeded(), eq(variables['EnableTestExecution'], 'true')) # The variable is defined on the pipeline definition - - - template: yaml-templates/upload-results.yaml - parameters: - includeBuildResults: true - artifactName: OSS Build Results - macOS - -- stage: linux_stage - displayName: Linux - condition: eq(variables['EnableLinuxStage'], 'true') # The variable is defined on the pipeline definition - dependsOn: [] # Run stage in parallel - jobs: - - job: linux_build_package - displayName: Linux > Build - pool: android-public-ubuntu-vmss - timeoutInMinutes: 180 - cancelTimeoutInMinutes: 5 - workspace: - clean: all - variables: - CXX: g++-10 - CC: gcc-10 - steps: - - checkout: self - submodules: recursive - - - template: yaml-templates/setup-ubuntu.yaml - - - script: make prepare PREPARE_CI_PR=1 PREPARE_AUTOPROVISION=1 CONFIGURATION=$(XA.Build.Configuration) - displayName: make prepare - - - script: make jenkins PREPARE_CI_PR=1 PREPARE_AUTOPROVISION=1 CONFIGURATION=$(XA.Build.Configuration) - displayName: make jenkins - - - script: make create-nupkgs CONFIGURATION=$(XA.Build.Configuration) - displayName: make create-nupkgs - - - script: make package-deb CONFIGURATION=$(XA.Build.Configuration) - displayName: make package-deb - - - script: > - mkdir -p $(System.DefaultWorkingDirectory)/bin/Build$(XA.Build.Configuration)/linux-artifacts && - cp $(System.DefaultWorkingDirectory)/*xamarin.android*.tar.bz2 $(System.DefaultWorkingDirectory)/bin/Build$(XA.Build.Configuration)/linux-artifacts && - cp $(System.DefaultWorkingDirectory)/*.changes $(System.DefaultWorkingDirectory)/bin/Build$(XA.Build.Configuration)/linux-artifacts && - cp $(System.DefaultWorkingDirectory)/*.dsc $(System.DefaultWorkingDirectory)/bin/Build$(XA.Build.Configuration)/linux-artifacts && - cp $(System.DefaultWorkingDirectory)/*.deb $(System.DefaultWorkingDirectory)/bin/Build$(XA.Build.Configuration)/linux-artifacts - displayName: copy linux artifacts - - - task: PublishPipelineArtifact@1 - displayName: publish linux artifacts - inputs: - artifactName: $(InstallerArtifactName) - Linux - targetPath: $(System.DefaultWorkingDirectory)/bin/Build$(XA.Build.Configuration)/linux-artifacts - - - task: PublishPipelineArtifact@1 - displayName: upload nupkgs - inputs: - artifactName: $(NuGetArtifactName) - Linux - targetPath: $(System.DefaultWorkingDirectory)/bin/Build$(XA.Build.Configuration)/$(NuGetArtifactName) - - - template: yaml-templates/upload-results.yaml - parameters: - artifactName: OSS Build Results - Linux - includeBuildResults: true diff --git a/build-tools/automation/build.groovy b/build-tools/automation/build.groovy deleted file mode 100644 index 32a119af200..00000000000 --- a/build-tools/automation/build.groovy +++ /dev/null @@ -1,458 +0,0 @@ -// This file is based on the Jenkins scripted pipeline (as opposed to the declarative pipeline) syntax -// https://jenkins.io/doc/book/pipeline/syntax/#scripted-pipeline -def XADir = 'xamarin-android' -def packageDir = 'package' - -def EXTRA_MSBUILD_ARGS="/p:AutoProvision=True /p:AutoProvisionUsesSudo=True /p:IgnoreMaxMonoVersion=False" - -def isCommercial = false -def commercialPath = '' -def packagePath = '' -def storageVirtualPath = '' - -def isPr = false // Default to CI - -def gitRepo = '' -def branch = '' -def commit = '' - -def skipSigning = false -def skipTest = false - -def hasPrLabelFullMonoIntegrationBuild = false - -def prepareFlags = 'PREPARE_CI=1' -def buildTarget = 'jenkins' - -def utils = null - -prLabels = null // Globally defined "static" list accessible within the hasPrLabel function - -@NonCPS -def getBuildTasksRedirect() { - def connection = "https://dl.internalx.com/build-tools/latest/Xamarin.Build.Tasks.nupkg".toURL().openConnection() - connection.instanceFollowRedirects = false - // should be in scope at the time of this call (called within a withCredentials block) - connection.setRequestProperty("Authorization", "token ${env.GITHUB_AUTH_TOKEN}") - def response = connection.responseCode - connection.disconnect() - if (response == 302) { - return connection.getHeaderField("Location") - } else { - throw new Exception("DL link failed ${response}: ${content}") - } -} - -timestamps { - node("${env.BotLabel}") { - def scmVars = null - - stage ("checkout") { - def ctAttempts = 3 - def retryAttempt = 0 - def waitSecondsBeforeRetry = 15 - retry(ctAttempts) { // Retry will always invoke the body at least once for an attempt count of 0 or 1 - dir (XADir) { - if (retryAttempt > 0) { - echo "WARNING : Stage checkout failed on try #${retryAttempt}. Waiting ${waitSecondsBeforeRetry} seconds" - sleep(waitSecondsBeforeRetry) - echo "Retrying ..." - waitSecondsBeforeRetry = waitSecondsBeforeRetry * 2 - } - - retryAttempt++ - scmVars = checkout scm - } - } - } - - utils = load "${XADir}/build-tools/automation/utils.groovy" - - utils.stageWithTimeout('init', 30, 'SECONDS', XADir, true) { // Typically takes less than a second - isCommercial = env.IsCommercial == '1' - commercialPath = "external/${env.CommercialDirectory}" - packagePath = "${env.WORKSPACE}/${packageDir}" - storageVirtualPath = env.StorageVirtualPath - - skipSigning = env.SkipSigning == '1' - skipTest = env.SkipTest == '1' - - gitRepo = scmVars.GIT_URL.replace("git@github.com:", "").split("/").takeRight(2).join("/").replace(".git", "") // Example result: xamarin/xamarin-android - - // Note: PR plugin environment variable settings available here: https://wiki.jenkins.io/display/JENKINS/GitHub+pull+request+builder+plugin - isPr = env.ghprbActualCommit != null - branch = isPr ? env.GIT_BRANCH : scmVars.GIT_BRANCH - commit = isPr ? env.ghprbActualCommit : scmVars.GIT_COMMIT - - def buildType = isPr ? 'PR' : 'CI' - - echo "Git repo: ${gitRepo}" // Example: xamarin/xamarin-android - echo "Job: ${env.JOB_BASE_NAME}" - echo "Job name: ${env.JOB_NAME}" - echo "Workspace: ${env.WORKSPACE}" - echo "Branch: ${branch}" - echo "Commit: ${commit}" - echo "Build type: ${buildType}" - echo "Build number: ${env.BUILD_NUMBER}" - echo "IsCommercial: ${isCommercial}" - - if (isCommercial) { - echo "Commercial path: ${commercialPath}" - storageVirtualPath = "${env.JOB_NAME}-${env.BUILD_NUMBER}/${branch}/${commit}" // This needs to be unique for commercial builds since the path determines where artifacts.json used for GitHub statuses will be published - } - - echo "Package path: ${packagePath}" - echo "Storage path: ${storageVirtualPath}" - - echo "SkipSigning: ${skipSigning}" - echo "SkipTest: ${skipTest}" - - if (isPr) { - echo "PR id: ${env.ghprbPullId}" - echo "PR link: ${env.ghprbPullLink}" - - // Clear out the PR title and description. This is the equivalent of $JENKINS_HOME/global-pre-script/remove-problematic-ghprb-parameters.groovy used by freestyle builds - echo "Clearing the PR title and description environment variables to avoid any special characters contained within from tripping up the build" - env.ghprbPullTitle = '' - env.ghprbPullLongDescription = '' - - if (utils.hasPrLabel(gitRepo, env.ghprbPullId, 'full-mono-integration-build')) { - hasPrLabelFullMonoIntegrationBuild = true - buildTarget = 'jenkins' - } else { - prepareFlags = 'PREPARE_CI_PR=1' - buildTarget = 'all' - // Also compile host libs for windows so that a complete VSIX can be created - if (isUnix()) { - def uname = sh script: 'uname', returnStdout: true - if (uname.startsWith("Darwin")) { - EXTRA_MSBUILD_ARGS += " /p:AndroidSupportedHostJitAbis=Darwin:mxe-Win32:mxe-Win64" - } - } - } - } - - echo "${buildType} buildTarget: ${buildTarget}" - - sh "env" - } - - utils.stageWithTimeout('clean', 30, 'SECONDS', XADir, true) { // Typically takes less than a second - // We need to make sure there's no test AVD present and that the Android emulator isn't running - // This is to assure that all tests start from the same state - sh "killall -9 qemu-system-x86_64 || true" - sh "rm -rf \$HOME/.android/avd/XamarinAndroidTestRunner.*" - if (fileExists(packagePath)) { - sh "rm -rf ${packagePath}" - } - - sh "git clean -xdff" - sh "git submodule foreach --recursive git clean -xdff" - sh "git submodule foreach --recursive git reset --hard HEAD" - sh "git submodule sync" - sh "git submodule update --recursive --init --force" - - sh "mkdir -p ${packagePath}" - } - - utils.stageWithTimeout('prepare deps', 30, 'MINUTES', XADir, true) { // Typically takes less than 2 minutes, but can take longer if any prereqs need to be provisioned - if (isCommercial) { - sh "make prepare-external-git-dependencies ${prepareFlags} V=1 " - - utils.stageWithTimeout('provisionator', 30, 'MINUTES', "${commercialPath}/build-tools/provisionator", true) { - sh('./provisionator.sh profile.csx -v') - } - - utils.stageWithTimeout('build tasks', 30, 'MINUTES', env.WORKSPACE, true) { - withCredentials([string(credentialsId: "${env.GitHubAuthTokenCredentialId}", variable: 'GITHUB_AUTH_TOKEN')]) { - def redirect = getBuildTasksRedirect() - sh "curl -o Xamarin.Build.Tasks.nupkg \"${redirect}\"" - dir("BuildTasks") { - deleteDir() - sh "unzip ../Xamarin.Build.Tasks.nupkg" - } - } - } - } - // Install .NET Core and temporarily append it to PATH - sh "curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin -version 3.1.100" - } - - utils.stageWithTimeout('build', 6, 'HOURS', XADir, true) { // Typically takes less than one hour except a build on a new bot to populate local caches can take several hours - // The 'prepare*' targets must run separately to '${buildTarget}` as preparation generates the 'rules.mk' file conditionally included by - // Makefile and it will **NOT** be included if we call e.g `make prepare jenkins` so the 'jenkns' target will **NOT** build all the supported - // targets and architectures leading to test errors later on (e.g. in EmbeddedDSOs tests) - sh "make prepare-update-mono CONFIGURATION=${env.BuildFlavor} V=1 ${prepareFlags} MSBUILD_ARGS='$EXTRA_MSBUILD_ARGS'" - sh "make prepare CONFIGURATION=${env.BuildFlavor} V=1 ${prepareFlags} MSBUILD_ARGS='$EXTRA_MSBUILD_ARGS'" - sh "make ${buildTarget} CONFIGURATION=${env.BuildFlavor} V=1 ${prepareFlags} MSBUILD_ARGS='$EXTRA_MSBUILD_ARGS'" - - if (isCommercial) { - sh ''' - VERSION=`LANG=C; export LANG && git log --no-color --first-parent -n1 --pretty=format:%ct` - echo "d1ec039f-f3db-468b-a508-896d7c382999 $VERSION" > ../package/updateinfo - ''' - } - } - - utils.stageWithTimeout('create installers', 30, 'MINUTES', XADir, true) { // Typically takes less than 5 minutes - if (isPr) { - // Override _MSBUILD_ARGS to ensure we only package the `AndroidSupportedTargetJitAbis` which are built. - // Also ensure that we don't require mono bundle components in the installer if this is not a full mono integration build. - def msbuildInstallerArgs = hasPrLabelFullMonoIntegrationBuild ? '' : '/p:IncludeMonoBundleComponents=False' - sh "make create-installers CONFIGURATION=${env.BuildFlavor} V=1 _MSBUILD_ARGS='${msbuildInstallerArgs}'" - } else { - sh "make create-installers CONFIGURATION=${env.BuildFlavor} V=1" - } - - if (isCommercial) { - sh "cp bin/Build*/xamarin.android*.pkg ${packagePath}" - sh "cp bin/Build*/Xamarin.Android*.vsix ${packagePath}" - } - } - - utils.stageWithTimeout('package oss', 30, 'MINUTES', XADir, true) { // Typically takes less than 5 minutes - if (!isCommercial) { - sh "make package-oss CONFIGURATION=${env.BuildFlavor} V=1" - } - } - - utils.stageWithTimeout('sign packages', 3, 'MINUTES', packageDir, false) { // Typically takes less than 10 seconds - if (isPr || !isCommercial || skipSigning) { - echo "Skipping 'sign packages' stage. Packages are only signed for commercial CI builds. IsPr: ${isPr} / IsCommercial: ${isCommercial} / SkipSigning: ${skipSigning}" - return - } - - def packages = findFiles(glob: '*.pkg') - def tmpPrefix = "/tmp/${env.JOB_NAME}" - def tmpdir = sh (script: "mkdir -p ${tmpPrefix} && mktemp -d ${tmpPrefix}/XXXXXXXXX", returnStdout: true).trim() - withCredentials([string(credentialsId: 'codesign_keychain_pw', variable: 'KEYCHAIN_PASSWORD')]) { - for (pkg in packages) { - def tmp = "${tmpdir}/${pkg.name}" - sh("mv ${pkg} ${tmpdir}") - sh("security unlock-keychain -p ${env.KEYCHAIN_PASSWORD} login.keychain") - sh("/usr/bin/productsign -s \"Developer ID Installer: Xamarin Inc\" \"${tmp}\" \"${pkg}\"") - } - } - } - - utils.stageWithTimeout('build tests', 30, 'MINUTES', XADir, true) { // Typically takes less than 10 minutes - if (skipTest) { - echo "Skipping 'build tests' stage. Clear the SkipTest variable setting to build and run tests" - return - } - - sh "make all-tests CONFIGURATION=${env.BuildFlavor} V=1" - } - - utils.stageWithTimeout('process build results', 10, 'MINUTES', XADir, true) { // Typically takes less than a minute - try { - echo "processing build status" - sh "make package-build-status CONFIGURATION=${env.BuildFlavor} V=1" - - if (isCommercial) { - sh "cp bin/Build${env.BuildFlavor}/xa-build-status-*.zip ${packagePath}" - } - } catch (error) { - echo "ERROR : NON-FATAL : processBuildStatus: Unexpected error: ${error}" - } - } - - utils.stageWithTimeout('publish packages to Azure', 30, 'MINUTES', '', true, 3) { // Typically takes less than a minute, but provide ample time in situations where logs may be quite large - def publishRootDir = '' - def publishBuildFilePaths = "${XADir}/xamarin.android-oss*.zip,${XADir}/bin/Build*/Xamarin.Android.Sdk-OSS*,${XADir}/build-status*,${XADir}/bin/Build${env.BuildFlavor}/xa-build-status*" - if (isCommercial) { - publishRootDir = packageDir - publishBuildFilePaths = "xamarin.android*.pkg,Xamarin.Android*.vsix,build-status*,xa-build-status*,*updateinfo" - } - - dir(publishRootDir) { - echo "publishBuildFilePaths: ${publishBuildFilePaths}" - def commandStatus = utils.publishPackages(env.StorageCredentialId, env.ContainerName, storageVirtualPath, publishBuildFilePaths) - if (commandStatus != 0) { - error "publish packages to Azure FAILED, status: ${commandStatus}" // Ensure stage is labeled as 'failed' and red failure indicator is displayed in Jenkins pipeline steps view - } - } - - if (isCommercial) { - utils.stageWithTimeout('report artifacts', 30, 'MINUTES', 'BuildTasks', false) { - withCredentials([string(credentialsId: "${env.GitHubAuthTokenCredentialId}", variable: 'GITHUB_AUTH_TOKEN'), usernamePassword(credentialsId: "${env.UserNamePasswordCredentialId}", passwordVariable: 'STORAGE_PASSWORD', usernameVariable: 'STORAGE_ACCOUNT')]) { - // Default search directory for Jenkins build artifacts is '${env.WORKSPACE}/package' - sh "mono tools/BuildTasks/build-tasks.exe artifacts -s ${env.WORKSPACE}/${XADir} -a ${env.STORAGE_ACCOUNT} -c ${env.STORAGE_PASSWORD} -u ${env.ContainerName}/${storageVirtualPath} -t ${env.GITHUB_AUTH_TOKEN}" - } - } - - utils.stageWithTimeout('sign artifacts', 30, 'MINUTES', '', false) { - if (isPr || skipSigning) { - echo "Skipping 'sign artifacts' stage. Artifact signing is only performed for commercial CI builds. SkipSigning: ${skipSigning}" - return - } - - // 'jenkins-internal artifacts' is the GitHub status context (name) used by build-tasks.exe - httpRequest httpMode: 'POST', ignoreSslErrors: true, responseHandle: 'NONE', url: "http://code-sign.guest.corp.microsoft.com:8080/job/sign-from-github-esrp/buildWithParameters?SIGN_TYPE=Real&REPO=${gitRepo}&COMMIT=${commit}&GITHUB_CONTEXT=jenkins-internal%20artifacts&FILES_TO_SIGN=%2E*%2Evsix" - } - } - } - - utils.stageWithTimeout('run performance tests', 60, 'MINUTES', XADir, false) { - if (skipTest) { - echo "Skipping 'run performance tests' stage. Clear the SkipTest variable setting to build and run tests" - return - } - - echo "running performance tests" - - commandStatus = sh (script: "make run-performance-tests CONFIGURATION=${env.BuildFlavor} V=1", returnStatus: true) - if (commandStatus != 0) { - error "run-performance-tests FAILED, status: ${commandStatus}" // Ensure stage is labeled as 'failed' and red failure indicator is displayed in Jenkins pipeline steps view - } - } - - utils.stageWithTimeout('publish test error logs to Azure', 30, 'MINUTES', '', false, 3) { // Typically takes less than a minute, but provide ample time in situations where logs may be quite large - if (skipTest) { - echo "Skipping 'publish test error logs' stage. Clear the SkipTest variable setting to build and run tests" - return - } - - echo "packaging test error logs" - - publishHTML target: [ - allowMissing: true, - alwaysLinkToLastBuild: false, - escapeUnderscores: true, - includes: '**/*', - keepAll: true, - reportDir: "xamarin-android/bin/Test${env.BuildFlavor}/compatibility", - reportFiles: '*.html', - reportName: 'API Compatibility Checks' - ] - - sh "make -C ${XADir} -k package-test-results CONFIGURATION=${env.BuildFlavor}" - - def publishTestFilePaths = "${XADir}/bin/Test${env.BuildFlavor}/xa-test-results*,${XADir}/test-errors.zip" - - echo "publishTestFilePaths: ${publishTestFilePaths}" - def commandStatus = utils.publishPackages(env.StorageCredentialId, env.ContainerName, storageVirtualPath, publishTestFilePaths) - if (commandStatus != 0) { - error "publish test error logs to Azure FAILED, status: ${commandStatus}" // Ensure stage is labeled as 'failed' and red failure indicator is displayed in Jenkins pipeline steps view - } - } - - utils.stageWithTimeout('Plot build & test metrics', 30, 'SECONDS', XADir, false, 3) { // Typically takes less than a second - if (isPr || skipTest) { - echo "Skipping 'plot metrics' stage for PR build. IsPr: ${isPr} / SkipTest: ${skipTest}" - return - } - - plot( - title: 'Jcw', - csvFileName: 'plot-jcw-test-times.csv', - csvSeries: [[ - displayTableFlag: true, file: 'TestResult-Xamarin.Android.JcwGen_Tests-times.csv', inclusionFlag: 'OFF' - ]], - group: 'Tests times', - logarithmic: true, - style: 'line', - yaxis: 'ms' - ) - plot( - title: 'Locale', - csvFileName: 'plot-locale-times.csv', - csvSeries: [[ - displayTableFlag: true, file: 'TestResult-Xamarin.Android.Locale_Tests-times.csv', inclusionFlag: 'OFF' - ]], - group: 'Tests times', - logarithmic: true, - style: 'line', - yaxis: 'ms' - ) - plot( - title: 'Runtime test sizes', - csvFileName: 'plot-runtime-test-sizes.csv', - csvSeries: [[ - displayTableFlag: true, file: "TestResult-Mono.Android_Tests-values-${env.BuildFlavor}.csv", inclusionFlag: 'OFF' - ]], - group: 'Tests size', - logarithmic: true, - style: 'line', - yaxis: 'ms' - ) - plot( - title: 'Runtime merged', - csvFileName: 'plot-runtime-merged-test-times.csv', - csvSeries: [[ - displayTableFlag: true, file: 'TestResult-Mono.Android_Tests-times.csv', inclusionFlag: 'OFF' - ]], - group: 'Tests times', - logarithmic: true, - style: 'line', - yaxis: 'ms' - ) - plot( - title: 'Xamarin.Forms app startup', - csvFileName: 'plot-xamarin-forms-startup-test-times.csv', - csvSeries: [[ - displayTableFlag: true, file: 'TestResult-Xamarin.Forms_Test-times.csv', inclusionFlag: 'OFF' - ]], - group: 'Tests times', - logarithmic: true, - style: 'line', - yaxis: 'ms' - ) - plot( - title: 'Xamarin.Forms app', - csvFileName: 'plot-xamarin-forms-tests-size.csv', - csvSeries: [[ - displayTableFlag: true, file: "TestResult-Xamarin.Forms_Tests-values-${env.BuildFlavor}.csv", inclusionFlag: 'OFF' - ]], - group: 'Tests size', - ogarithmic: true, - style: 'line', - yaxis: 'ms' - ) - - plot( - title: 'Hello World', - csvFileName: 'plot-hello-world-build-times.csv', - csvSeries: [[ - displayTableFlag: true, file: 'TestResult-Timing-HelloWorld.csv', inclusionFlag: 'OFF' - ]], - group: 'Build times', - logarithmic: true, - style: 'line', - yaxis: 'ms' - ) - - plot( - title: 'Xamarin.Forms', - csvFileName: 'plot-xamarin-forms-integration-build-times.csv', - csvSeries: [[ - displayTableFlag: true, file: 'TestResult-Timing-Xamarin.Forms-Integration.csv', inclusionFlag: 'OFF' - ]], - group: 'Build times', - logarithmic: true, - style: 'line', - yaxis: 'ms' - ) - } - - utils.stageWithTimeout('Publish test results', 5, 'MINUTES', XADir, false, 3) { // Typically takes under 1 minute to publish test results - def initialStageResult = currentBuild.currentResult - - xunit thresholds: [ - failed(unstableNewThreshold: '0', unstableThreshold: '0'), - skipped() // Note: Empty threshold settings per settings in the xamarin-android freestyle build are not permitted here - ], - tools: [ - NUnit2(deleteOutputFiles: true, - failIfNotNew: true, - pattern: 'TestResult-*.xml', - skipNoTestFiles: true, - stopProcessingIfError: false) - ] - - if (initialStageResult == 'SUCCESS' && currentBuild.currentResult == 'UNSTABLE') { - error "One or more tests failed" // Force an error condition if there was a test failure to indicate that this stage was the source of the build failure - } - } - } -} diff --git a/build-tools/automation/build.linux.groovy b/build-tools/automation/build.linux.groovy deleted file mode 100644 index ffe138e7690..00000000000 --- a/build-tools/automation/build.linux.groovy +++ /dev/null @@ -1,266 +0,0 @@ -// This file is based on the Jenkins scripted pipeline (as opposed to the declarative pipeline) syntax -// https://jenkins.io/doc/book/pipeline/syntax/#scripted-pipeline - -def XADir = "xamarin-android" -def buildTarget = 'jenkins' -def chRootPackages = ''' - autoconf - automake - build-essential - ca-certificates-mono - clang - cli-common-dev - cmake - curl - debhelper - devscripts - fakeroot - fsharp - g++-mingw-w64 - g++-multilib - gcc-mingw-w64 - gcc-multilib - gettext - git - intltool - lib32stdc++6 - lib32z1 - libc++-dev - libgdk-pixbuf2.0-dev - libmono-btls-interface4.0-cil - libncurses5-dev - libsqlite3-dev - libtinfo-dev:i386 - libtool - libtool-bin - libz-mingw-w64-dev - linux-libc-dev:i386 - mono-csharp-shell - mono-devel - msbuild - ninja-build - nuget - p7zip-full - pkg-config - psmisc - referenceassemblies-pcl - ruby - scons - sqlite3 - unzip - vim-common - wget - xauth - xvfb - xz-utils - zip - zlib1g-dev:i386 - zulu-8 -''' -def isPr = false // Default to CI -def isStable = false // Stable build workflow -def publishPackages = false -def pBuilderBindMounts = null -def utils = null -def hasPrLabelFullMonoIntegrationBuild = false - -prLabels = null // Globally defined "static" list accessible within the hasPrLabel function - -def execChRootCommand(chRootName, chRootPackages, pBuilderBindMounts, makeCommand) { - chroot chrootName: chRootName, - additionalPackages: chRootPackages, - bindMounts: pBuilderBindMounts, - command: """ - export LC_ALL=en_US.UTF-8 - export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games - locale - - ${makeCommand} - """ -} - -timestamps { - node("${env.BotLabel}") { - def scmVars = null - - stage ("checkout") { - def ctAttempts = 3 - def retryAttempt = 0 - def waitSecondsBeforeRetry = 15 - retry(ctAttempts) { // Retry will always invoke the body at least once for an attempt count of 0 or 1 - dir (XADir) { - if (retryAttempt > 0) { - echo "WARNING : Stage checkout failed on try #${retryAttempt}. Waiting ${waitSecondsBeforeRetry} seconds" - sleep(waitSecondsBeforeRetry) - echo "Retrying ..." - waitSecondsBeforeRetry = waitSecondsBeforeRetry * 2 - } - - retryAttempt++ - scmVars = checkout scm - } - } - } - - utils = load "${XADir}/build-tools/automation/utils.groovy" - - utils.stageWithTimeout('init', 30, 'SECONDS', XADir, true) { // Typically takes less than a second for CI builds - // Note: PR plugin environment variable settings available here: https://wiki.jenkins.io/display/JENKINS/GitHub+pull+request+builder+plugin - isPr = env.ghprbActualCommit != null - isStable = env.IsStable == '1' - publishPackages = env.PublishPackages == '1' - def branch = isPr ? env.GIT_BRANCH : scmVars.GIT_BRANCH - def commit = isPr ? env.ghprbActualCommit : scmVars.GIT_COMMIT - - def buildType = isPr ? 'PR' : 'CI' - - echo "HostName: ${env.NODE_NAME}" - echo "Git repo: ${env.GitRepo}" // Defined as an environment variable in the jenkins build definition - echo "Job: ${env.JOB_BASE_NAME}" - echo "Workspace: ${env.WORKSPACE}" - echo "Branch: ${branch}" - echo "Commit: ${commit}" - echo "Build type: ${buildType}" - echo "Stable build workflow: ${isStable}" - - pBuilderBindMounts = "/mnt/scratch" - echo "pBuilderBindMounts: ${pBuilderBindMounts}" - echo "chRootPackages: ${chRootPackages}" - - if (env.AdditionalPackages) { - echo "AdditionalPackages (build configuration): ${env.AdditionalPackages}" - chRootPackages = "${chRootPackages} ${env.AdditionalPackages}" - } - - if (isPr) { - echo "PR id: ${env.ghprbPullId}" - echo "PR link: ${env.ghprbPullLink}" - - // Clear out the PR title and description. This is the equivalent of $JENKINS_HOME/global-pre-script/remove-problematic-ghprb-parameters.groovy used by freestyle builds - echo "Clearing the PR title and description environment variables to avoid any special characters contained within from tripping up the build" - env.ghprbPullTitle = '' - env.ghprbPullLongDescription = '' - - if (utils.hasPrLabel(env.GitRepo, env.ghprbPullId, 'full-mono-integration-build')) { - hasPrLabelFullMonoIntegrationBuild = true - buildTarget = 'jenkins' - } else { - buildTarget = 'all' - } - } - - sh "env" - } - - utils.stageWithTimeout('build and package', 7, 'HOURS', XADir, true) { // Typically takes 4-5 hours - execChRootCommand(env.ChRootName, chRootPackages, pBuilderBindMounts, - """ - export AndroidToolchainDirectory=/mnt/scratch/android-toolchain - export AndroidToolchainCacheDirectory=/mnt/scratch/android-archives - - if [ -z "\$JAVA_HOME" ]; then - if [ -f /etc/profile.d/jdk.sh ]; then - echo 'STAGE: jdk' - source /etc/profile.d/jdk.sh - fi - fi - - echo 'STAGE: build' - make prepare ${buildTarget} CONFIGURATION=${env.BuildFlavor} V=1 NO_SUDO=true MSBUILD_ARGS='/p:MonoRequiredMinimumVersion=5.12' PREPARE_CI=1 - - if [[ "${isPr}" != "true" ]]; then - echo 'STAGE: package deb' - make package-deb CONFIGURATION=${env.BuildFlavor} V=1 - else - echo 'Skipping debian packaging for PR builds' - fi - - if [[ "${isPr}" != "true" && "${isStable}" != "true" ]]; then - echo 'STAGE: build tests' - xvfb-run -a -- make all-tests CONFIGURATION=${env.BuildFlavor} V=1 - else - echo 'Skipping build tests for PR and stable builds' - fi - - echo 'STAGE: package build status' - make package-build-status CONFIGURATION=${env.BuildFlavor} - """) - } - - utils.stageWithTimeout('publish packages to Azure', 30, 'MINUTES', '', true, 3) { // Typically takes less than a minute, but provide ample time in situations where logs may be quite large - if (!publishPackages) { - echo "Skipping package publishing. Set PublishPackages to 1 as a property setting in the build configuration " - return - } - - def publishBuildFilePaths = "${XADir}/*xamarin.android*.tar*"; - publishBuildFilePaths = "${publishBuildFilePaths},${XADir}/bin/${env.BuildFlavor}/bundle-*.zip" - publishBuildFilePaths = "${publishBuildFilePaths},${XADir}/*.changes" - publishBuildFilePaths = "${publishBuildFilePaths},${XADir}/*.dsc" - publishBuildFilePaths = "${publishBuildFilePaths},${XADir}/*.deb" - publishBuildFilePaths = "${publishBuildFilePaths},${XADir}/build-status*" - publishBuildFilePaths = "${publishBuildFilePaths},${XADir}/bin/Build${env.BuildFlavor}/xa-build-status*" - - echo "publishBuildFilePaths: ${publishBuildFilePaths}" - def commandStatus = utils.publishPackages(env.StorageCredentialId, env.ContainerName, env.StorageVirtualPath, publishBuildFilePaths) - if (commandStatus != 0) { - error "publish packages to Azure FAILED, status: ${commandStatus}" // Ensure stage is labeled as 'failed' and red failure indicator is displayed in Jenkins pipeline steps view - } - } - - utils.stageWithTimeout('run all tests and package results', 360, 'MINUTES', XADir, false) { - if (isPr || isStable) { - echo "Skipping test run for PR and stable builds" - return - } - - echo "running tests" - - execChRootCommand(env.ChRootName, chRootPackages, pBuilderBindMounts, - """ - export AndroidToolchainDirectory=/mnt/scratch/android-toolchain - export AndroidToolchainCacheDirectory=/mnt/scratch/android-archives - - echo "STAGE: run all tests" - xvfb-run -a -- make run-all-tests CONFIGURATION=${env.BuildFlavor} V=1 || (killall adb && false) - killall adb || true - - echo "STAGE: package test error logs" - make -C ${XADir} -k package-test-results CONFIGURATION=${env.BuildFlavor} - """) - - def publishTestFilePaths = "${XADir}/bin/Test${env.BuildFlavor}/xa-test-results*,${XADir}/test-errors.zip" - - echo "publishTestFilePaths: ${publishTestFilePaths}" - def commandStatus = utils.publishPackages(env.StorageCredentialId, env.ContainerName, env.StorageVirtualPath, publishTestFilePaths) - if (commandStatus != 0) { - error "publish test error logs to Azure FAILED, status: ${commandStatus}" // Ensure stage is labeled as 'failed' and red failure indicator is displayed in Jenkins pipeline steps view - } - } - - utils.stageWithTimeout('Publish test results', 5, 'MINUTES', XADir, false, 3) { // Typically takes under 1 minute to publish test results - if (isPr || isStable) { - echo "Skipping publishing of test results for PR and stable builds" - return - } - - def initialStageResult = currentBuild.currentResult - - xunit thresholds: [ - failed(unstableNewThreshold: '0', unstableThreshold: '0'), - skipped() // Note: Empty threshold settings per settings in the xamarin-android freestyle build are not permitted here - ], - tools: [ - NUnit2(deleteOutputFiles: true, - failIfNotNew: true, - pattern: 'TestResult-*.xml', - skipNoTestFiles: true, - stopProcessingIfError: false) - ] - - if (initialStageResult == 'SUCCESS' && currentBuild.currentResult == 'UNSTABLE') { - error "One or more tests failed" // Force an error condition if there was a test failure to indicate that this stage was the source of the build failure - } - } - } -} diff --git a/build-tools/scripts/RunTests.targets b/build-tools/scripts/RunTests.targets deleted file mode 100644 index 1542b584483..00000000000 --- a/build-tools/scripts/RunTests.targets +++ /dev/null @@ -1,208 +0,0 @@ - - - - - <_TopDir>$(MSBuildThisFileDirectory)..\.. - - - - - - <_Test Condition=" '$(TEST)' != '' ">--test="$(TEST)" - <_XABuild>$(_TopDir)\bin\$(Configuration)\bin\xabuild - <_XABinLogPrefix>/v:normal /binaryLogger:"$(MSBuildThisFileDirectory)\..\..\bin\Test$(Configuration)\msbuild - <_XABuildDiag Condition=" '$(USE_MSBUILD)' == '0' And '$(V)' != '' ">/v:diag - <_XABuildProperties>$(_XABuildDiag)/p:Configuration=$(Configuration) - - - <_TestAssembly Include="$(_TopDir)\bin\Test$(Configuration)\net472\Xamarin.Android.Build.Tests.dll" /> - <_TestAssembly Include="$(_TopDir)\bin\Test$(Configuration)\net472\Xamarin.Android.Tools.Aidl-Tests.dll" /> - <_ApkTestProject Include="$(_TopDir)\tests\Mono.Android-Tests\Mono.Android-Tests.csproj" /> - <_ApkTestProject Include="$(_TopDir)\tests\CodeGen-Binding\Xamarin.Android.JcwGen-Tests\Xamarin.Android.JcwGen-Tests.csproj" /> - <_ApkTestProject Include="$(_TopDir)\tests\CodeGen-MkBundle\Xamarin.Android.MakeBundle-Tests\Xamarin.Android.MakeBundle-Tests.csproj" /> - <_ApkTestProject Include="$(_TopDir)\tests\locales\Xamarin.Android.Locale-Tests\Xamarin.Android.Locale-Tests.csproj" /> - <_ApkTestProject Include="$(_TopDir)\tests\BCL-Tests\Xamarin.Android.Bcl-Tests\Xamarin.Android.Bcl-Tests.csproj" /> - <_ApkTestProject Include="$(_TopDir)\tests\Xamarin.Forms-Performance-Integration\Droid\Xamarin.Forms.Performance.Integration.Droid.csproj" /> - <_ApkTestProject Include="$(_TopDir)\tests\EmbeddedDSOs\EmbeddedDSO\EmbeddedDSO.csproj" /> - <_ApkTestProject Include="$(_TopDir)\tests\Mono.Android-Tests\Runtime-AppBundle\Mono.Android-TestsAppBundle.csproj" /> - <_ApkTestProject Include="$(_TopDir)\tests\Mono.Android-Tests\Runtime-MultiDex\Mono.Android-TestsMultiDex.csproj" /> - <_ApkTestProjectAot Include="$(_TopDir)\tests\Mono.Android-Tests\Mono.Android-Tests.csproj" /> - <_ApkTestProjectAot Include="$(_TopDir)\tests\locales\Xamarin.Android.Locale-Tests\Xamarin.Android.Locale-Tests.csproj" /> - <_ApkTestProjectAot Include="$(_TopDir)\tests\Xamarin.Forms-Performance-Integration\Droid\Xamarin.Forms.Performance.Integration.Droid.csproj" /> - <_ApkTestProjectBundle Include="$(_TopDir)\tests\Mono.Android-Tests\Mono.Android-Tests.csproj" /> - <_ApkTestProjectBundle Include="$(_TopDir)\tests\Xamarin.Forms-Performance-Integration\Droid\Xamarin.Forms.Performance.Integration.Droid.csproj" /> - - - - - - - - - %(_TestAssembly.Filename) - | tee "bin\Test$(Configuration)\TestOutput-%(_TestAssembly.Filename).txt" - --output="bin\Test$(Configuration)\TestOutput-%(_TestAssembly.Filename).txt" - - - - - <_RenameNUnitTestCasesGlob Include="$(_TopDir)\TestResult-*Tests.xml" /> - - - <_RenamedTestCases>@(_RenameNUnitTestCasesGlob) - - - - - - - - - - - <_RenameJITestCasesGlob Include="$(JavaInteropSourceDirectory)\TestResult-*Tests.xml" /> - - - <_RenamedTestCases>@(_RenameJITestCasesGlob) - - - - <_JavaInteropTestResults Include="$(JavaInteropSourceDirectory)\TestResult-*.xml" /> - - - - - - - <_ApkTestProject> - <_BinLog>$(_XABinLogPrefix)-$([System.DateTime]::Now.ToString ("yyyyMMddTHHmmss"))-%(Filename).binlog" - - - - - - <_HostOS>$(HostOS) - <_ExeExtension> - <_HostOS Condition=" '$(_HostOS)' == 'Windows' "> - <_ExeExtension Condition=" '$(_HostOS)' == 'Windows' ">.exe - <_CrossCompilerAvailable Condition="Exists('$(_TopDir)\bin\$(Configuration)\lib\xamarin.android\xbuild\Xamarin\Android\$(_HostOS)\cross-arm$(_ExeExtension)')">True - <_CrossCompilerAvailable Condition=" '$(_CrossCompilerAvailable)' == '' ">False - - - <_ApkTestProjectAot> - <_BinLog>$(_XABinLogPrefix)-$([System.DateTime]::Now.ToString ("yyyyMMddTHHmmss"))-%(Filename)-AOT.binlog" - - - - - - <_ApkTestProjectProfiledAot> - <_BinLog>$(_XABinLogPrefix)-$([System.DateTime]::Now.ToString ("yyyyMMddTHHmmss"))-%(Filename)-profiled-AOT.binlog" - - - - - - - - - - - - - <_RunParallelTestTarget Include="RunNUnitTests" /> - <_RunParallelTestTarget Include="RunApkTests" /> - - - <_RunTestTarget Include="RunJavaInteropTests"> - - - <_RunTestTarget Include="RunPerformanceTests"> - - - <_RunTestTarget Include="RunApkTests"> - RunApkTestsTarget=RunPerformanceApkTests - - <_RunTestTarget Include="RunNUnitDeviceTests"> - - - - - - - - diff --git a/tools/xabuild/SymbolicLink.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/SymbolicLink.cs similarity index 100% rename from tools/xabuild/SymbolicLink.cs rename to src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/SymbolicLink.cs diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Xamarin.Android.Build.Tests.csproj b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Xamarin.Android.Build.Tests.csproj index 2b0eb2702ea..3411f1480e5 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Xamarin.Android.Build.Tests.csproj +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Xamarin.Android.Build.Tests.csproj @@ -32,7 +32,6 @@ - ..\Expected\GenerateDesignerFileExpected.cs diff --git a/tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/AndroidManifest.xml b/tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/AndroidManifest.xml index 4a0f610906d..bd713ff9c8b 100644 --- a/tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/AndroidManifest.xml +++ b/tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/AndroidManifest.xml @@ -1,5 +1,4 @@  - diff --git a/tests/RunApkTests.targets b/tests/RunApkTests.targets deleted file mode 100644 index 0b2bccc7d23..00000000000 --- a/tests/RunApkTests.targets +++ /dev/null @@ -1,137 +0,0 @@ - - - - - - $(TestOutputDirectory) - <_TopDir>$(MSBuildThisFileDirectory).. - - - - - - - - - - - - - <_ApkTests Include="$(ApkTests)"> - %(Identity) - - - - - <_DeviceTestAssembly Include="$(_TopDir)\bin\Test$(Configuration)\MSBuildDeviceIntegration\net472\MSBuildDeviceIntegration.dll" /> - - - - - AcquireAndroidTarget; - RunMSBuildDeviceIntegration; - ReleaseAndroidTarget; - - - - - - - - - %(_DeviceTestAssembly.Filename) - | tee "bin\Test$(Configuration)\TestOutput-%(_DeviceTestAssembly.Filename).txt" - --output="bin\Test$(Configuration)\TestOutput-%(_DeviceTestAssembly.Filename).txt" - - - - - <_RenameNUnitTestCasesGlob Include="@(NUnitTarget->'$(_TopDir)\TestResult-%(TestFilename).xml')" /> - - - <_RenamedTestCases>@(_RenameNUnitTestCasesGlob) - - - - - - - FilterApkTests; - AcquireAndroidTarget; - UndeployTestApks; - DeployTestApks; - DeployTestAabs; - CheckAndRecordApkSizes; - RunTestApks; - ReleaseAndroidTarget; - RenameApkTestCases; - ReportComponentFailures; - - - - - - - - - - - - - - - - - - <_ApkPerfTests Include="Mono.Android_Tests;Xamarin.Android.Locale_Tests;Xamarin.Forms_Performance_Integration"> - %(Identity) - - - - - - <_AllArchives Remove="@(_AllArchives)" Condition=" '%(Package)' != '' And '@(_ApkPerfTests)' == '' " /> - - - - - - - - - - <_AllArchives Remove="@(_AllArchives)" Condition=" '%(Package)' != '' And '@(_ApkPerfTests)' != '' " /> - - - - - - - - - - - - diff --git a/tests/api-compatibility/api-compatibility.targets b/tests/api-compatibility/api-compatibility.targets index 4d06ec354ce..5a0ba77308d 100644 --- a/tests/api-compatibility/api-compatibility.targets +++ b/tests/api-compatibility/api-compatibility.targets @@ -1,5 +1,6 @@ + diff --git a/tools/scripts/xabuild b/tools/scripts/xabuild deleted file mode 100755 index 3bd459f4e40..00000000000 --- a/tools/scripts/xabuild +++ /dev/null @@ -1,189 +0,0 @@ -#!/bin/bash -e - -# -# MSBuild wrapper to build Xamarin.Android apps from the command-line, -# without pesky IDE interference. -# -# Supported MSBuild targets and properties: -# https://developer.xamarin.com/guides/android/under_the_hood/build_process/ -# -# Overridable environment variables: -# ANDROID_NDK_PATH: -# Path to Android NDK. -# Defaults to `$(AndroidNdkDirectory)` in ../../Configuration.props. -# ANDROID_SDK_PATH: -# Path to Android SDK. -# Defaults to `$(AndroidNdkDirectory)` in ../../Configuration.props. -# CONFIGURATION: -# For in-source-tree invocations, the `bin/$(CONFIGURATION)` directory to -# use as the installation prefix. If not specified, defaults to `Debug`. -# MSBUILD: -# MSBuild engine to use. Defaults to `xbuild`, assumed to be in `$PATH` -# TARGETS_DIR: -# The MSBuild `$(MSBuildExtensionsPath)` root location. -# Defaults to `$prefix/lib/xamarin.android/xbuild`. -# -# Examples: -# To create a .apk for the HelloWorld sample: -# tools/scripts/xabuild /t:SignAndroidPackage samples/HelloWorld/HelloWorld/HelloWorld.csproj -# -# To explicitly use `msbuild` for builds: -# MSBUILD=msbuild tools/scripts/xabuild /t:SignAndroidPackage samples/HelloWorld/HelloWorld/HelloWorld.csproj -# -# To explicitly use `xbuild` for builds: -# MSBUILD=xbuild tools/scripts/xabuild /t:SignAndroidPackage samples/HelloWorld/HelloWorld/HelloWorld.csproj -# - -name=$(basename "$0") -truepath=$(readlink "$0" || echo "$0") -prefix="$(cd `dirname "${truepath}"` && pwd)" - -if [ -z "$MSBUILD" ] ; then - MSBUILD=msbuild -fi - -if [ -z "$CONFIGURATION" ]; then - for p in "$@"; do - case $p in - /property:Configuration=*| \ - /p:Configuration=*| \ - -p:Configuration=*| \ - --property:Configuration=*) CONFIGURATION="`echo $p | cut -d '=' -f 2`" ;; - esac - - if [ -n "$CONFIGURATION" ]; then - break - fi - done -fi - -if [[ "$prefix" == */tools/scripts ]] ; then - Paths_targets="$prefix/../../build-tools/scripts/Paths.targets" - for c in "$CONFIGURATION" Debug Release ; do - if [ -z "$c" ]; then - continue - fi - if [ -d "$prefix/../../bin/$c" ]; then - real_prefix="$prefix/../../bin/$c" - break - fi - done - if [ -z "$real_prefix" ]; then - (>&2 echo "$name: Could not determine Xamarin.Android prefix.") - exit 1 - fi - prefix="$real_prefix" - xa_prefix="$real_prefix/lib/xamarin.android" -elif [[ "$prefix" == */bin ]] ; then - prefix="$prefix/.." - xa_prefix="$prefix/lib/xamarin.android" -else - (>&2 echo "$name: Could not determine Xamarin.Android prefix.") - exit 1 -fi - -if [[ "$MSBUILD" == "msbuild" ]] ; then - exec mono "$prefix/bin/xabuild.exe" "$@" "/p:MonoDroidInstallDirectory=$prefix" - exit $? -fi - -for t in "$TARGETS_DIR" "$prefix/lib/mono/xbuild" "$xa_prefix/xbuild" ; do - if [ -z "$t" -o ! -d "$t" ]; then - continue - fi - TARGETS_DIR="$t" - break -done - -if [ ! -d "$TARGETS_DIR" ]; then - (>&2 echo "$name: Could not determine Xamarin.Android targets path.") - exit 1 -fi -export TARGETS_DIR -export MONO_ANDROID_PATH="$prefix" - -if [ -f "$Paths_targets" ] ; then - ANDROID_NDK_PATH=$($MSBUILD /nologo /v:minimal /t:GetAndroidNdkFullPath "$Paths_targets") - ANDROID_NDK_PATH=$(echo $ANDROID_NDK_PATH | sed 's/^\w*//g') - export ANDROID_NDK_PATH - - ANDROID_SDK_PATH=$($MSBUILD /nologo /v:minimal /t:GetAndroidSdkFullPath "$Paths_targets") - ANDROID_SDK_PATH=$(echo $ANDROID_SDK_PATH | sed 's/^\w*//g') - export ANDROID_SDK_PATH -fi - -declare -a XABUILD_FLAGS - -XABUILD_FLAGS=( - /p:MonoAndroidToolsDirectory="$xa_prefix/xbuild/Xamarin/Android" - /p:MonoDroidInstallDirectory="$MONO_ANDROID_PATH" -) - -if [ -n "$ANDROID_NDK_PATH" ] ; then - XABUILD_FLAGS+=(/p:AndroidNdkDirectory="$ANDROID_NDK_PATH") -fi -if [ -n "$ANDROID_SDK_PATH" ] ; then - XABUILD_FLAGS+=(/p:AndroidSdkDirectory="$ANDROID_SDK_PATH") -fi - -export MSBuildExtensionsPath="$TARGETS_DIR" - -case "$MSBUILD" in - *msbuild*) - XABUILD_FLAGS+=(/p:TargetFrameworkRootPath="$TARGETS_DIR-frameworks/") - ;; - *xbuild*) - if [ -z "$XBUILD_FRAMEWORK_FOLDERS_PATH" ]; then - export XBUILD_FRAMEWORK_FOLDERS_PATH="$TARGETS_DIR-frameworks" - else - export XBUILD_FRAMEWORK_FOLDERS_PATH="$XBUILD_FRAMEWORK_FOLDERS_PATH" - fi - ;; -esac - -function GetXbuildDir() -{ - read -r -d '' get_xbuild_dir_cmd <<-'EOF' || true - using System.IO; - var corlib_loc = typeof (int).Assembly.Location; - // e.g. corlib_dir=/Library/Frameworks/Mono.framework/Versions/5.2.0/lib/mono/4.5 - var corlib_dir = Path.GetDirectoryName (corlib_loc); - // e.g. xbuild_dir=/Library/Frameworks/Mono.framework/Versions/5.2.0/lib/mono/xbuild - var xbuild_dir = Path.Combine (corlib_dir, "..", "xbuild"); - print (Path.GetFullPath (xbuild_dir)); - EOF - echo "$get_xbuild_dir_cmd" | csharp -} - -function ConfigureLocalXbuild() -{ - if [ -d "$prefix/lib/mono" ]; then - # System installation, e.g. Linux? - return 0 - fi - xbuild_dir=`GetXbuildDir` - local sys_entry=`ls -1 "$xbuild_dir" | head -1` - if [ -f "$TARGETS_DIR/.__sys_links.txt" ] ; then - # already configured; bail - return 0 - fi - local sys_links="$TARGETS_DIR/.__sys_links.txt" - echo ".__sys_links.txt" > "$sys_links" - local e - for e in "$xbuild_dir"/* ; do - local b=`basename "$e"` - if [ -e "$TARGETS_DIR/$b" -o -f "$TARGETS_DIR/$b" -o -L "$TARGETS_DIR/$b" ]; then - rm -rf "$TARGETS_DIR/$b" - fi - ln -s "$e" "$TARGETS_DIR" - if [ -d "$e" ]; then - echo "$b"'/*' >> "$sys_links" - else - echo $b >> "$sys_links" - fi - done -} - -ConfigureLocalXbuild - -exec $MSBUILD "${XABUILD_FLAGS[@]}" "$@" diff --git a/tools/xabuild/App.config b/tools/xabuild/App.config deleted file mode 100644 index df79e5196a3..00000000000 --- a/tools/xabuild/App.config +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tools/xabuild/XABuild.cs b/tools/xabuild/XABuild.cs deleted file mode 100644 index 8e00cc94b3b..00000000000 --- a/tools/xabuild/XABuild.cs +++ /dev/null @@ -1,191 +0,0 @@ -using Microsoft.Build.CommandLine; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Threading; -using System.Xml; - -namespace Xamarin.Android.Build -{ - class XABuild - { - [MTAThread] - static int Main () - { - var paths = new XABuildPaths (); - try { - //HACK: running on Mono, MSBuild cannot resolve System.Reflection.Metadata - if (!paths.IsWindows) { - AppDomain.CurrentDomain.AssemblyResolve += (sender, args) => { - var name = new AssemblyName (args.Name); - if (name.Name == "System.Reflection.Metadata") { - var path = Path.Combine (paths.MSBuildBin, $"{name.Name}.dll"); - return Assembly.LoadFile (path); - } - //Return null, to revert to default .NET behavior - return null; - }; - } - if (!Directory.Exists (paths.XamarinAndroidBuildOutput)) { - Console.WriteLine ($"Unable to find Xamarin.Android build output at {paths.XamarinAndroidBuildOutput}"); - return 1; - } - - // Create a custom xabuild.exe.config - CreateConfig (paths); - // Create a Microsoft.Build.NuGetSdkResolver.xml - CreateSdkResolverConfig (paths); - - //Symbolic links to be created: key=in-tree-dir, value=system-dir - var symbolicLinks = new Dictionary (); - if (paths.IsMacOS || paths.IsLinux) { - foreach (var dir in Directory.EnumerateDirectories (paths.MonoSystemFrameworkRoot)) { - if (Path.GetFileName (dir).EndsWith ("-api", StringComparison.OrdinalIgnoreCase)){ - var inTreeFramework = Path.Combine (paths.XamarinAndroidBuildOutput, "lib", "xamarin.android", Path.GetFileName (dir)); - symbolicLinks [inTreeFramework] = dir; - } - } - } - foreach (var dir in Directory.EnumerateDirectories (paths.SystemFrameworks)) { - if (Path.GetFileName (dir) != "MonoAndroid") { - var inTreeFramework = Path.Combine (paths.FrameworksDirectory, Path.GetFileName (dir)); - symbolicLinks [inTreeFramework] = dir; - } - } - foreach (var dir in paths.SystemTargetsDirectories) { - var inTreeTargetsDir = Path.Combine (paths.MSBuildExtensionsPath, Path.GetFileName (dir)); - if (!symbolicLinks.ContainsKey (inTreeTargetsDir)) { - symbolicLinks [inTreeTargetsDir] = dir; - continue; - } - var prevTargetDir = symbolicLinks [inTreeTargetsDir]; - symbolicLinks.Remove (inTreeTargetsDir); - if (Directory.Exists (inTreeTargetsDir) && SymbolicLink.IsPathSymlink (inTreeTargetsDir)) { - Console.WriteLine ($"Removing old symlink: {inTreeTargetsDir}"); - Directory.Delete (inTreeTargetsDir); - } - var subTargetDirs = Directory.EnumerateDirectories (prevTargetDir) - .Concat (Directory.EnumerateDirectories (dir)); - foreach (var subDir in subTargetDirs) { - var inTreeTargetSubdir = Path.Combine (inTreeTargetsDir, Path.GetFileName (subDir)); - symbolicLinks [inTreeTargetSubdir] = subDir; - } - } - if (symbolicLinks.Keys.Any (d => !Directory.Exists (d))) { - //Hold open the file while creating the symbolic links - using (var writer = OpenSysLinksFile (paths)) { - foreach (var pair in symbolicLinks) { - var systemDirectory = pair.Value; - var symbolicLink = pair.Key; - Console.WriteLine ($"[xabuild] creating symbolic link '{symbolicLink}' -> '{systemDirectory}'"); - if (!SymbolicLink.Create (symbolicLink, systemDirectory)) { - return 1; - } - writer.WriteLine (Path.GetFileName (symbolicLink)); - } - } - } - - return MSBuildApp.Main (); - } finally { - //NOTE: this is a temporary directory - Directory.Delete (paths.MSBuildTempPath, recursive: true); - } - } - - static StreamWriter OpenSysLinksFile (XABuildPaths paths) - { - string path = Path.Combine (paths.FrameworksDirectory, ".__sys_links.txt"); - - //NOTE: on Windows, the NUnit tests can throw IOException when running xabuild in parallel - for (int i = 0;; i++) { - try { - return File.AppendText (path); - } catch (IOException) { - if (i == 2) - throw; //Fail after 3 tries - Thread.Sleep (100); - } - } - } - - static void CreateConfig (XABuildPaths paths) - { - var xml = new XmlDocument { XmlResolver = null }; - - using (var reader = XmlReader.Create (paths.MSBuildConfig, new XmlReaderSettings { XmlResolver = null })) - xml.Load (reader); - - var toolsets = xml.SelectSingleNode ("configuration/msbuildToolsets/toolset"); - SetProperty (toolsets, "XABuild", "true"); // Enables MSBuild .targets to check for xabuild - SetProperty (toolsets, "VsInstallRoot", paths.VsInstallRoot); - SetProperty (toolsets, "MSBuildToolsPath", paths.MSBuildBin); - SetProperty (toolsets, "MSBuildToolsPath32", paths.MSBuildBin); - SetProperty (toolsets, "MSBuildToolsPath64", paths.MSBuildBin); - SetProperty (toolsets, "MSBuildExtensionsPath", paths.MSBuildExtensionsPath); - SetProperty (toolsets, "MSBuildExtensionsPath32", paths.MSBuildExtensionsPath); - if (!string.IsNullOrEmpty (paths.RoslynTargetsPath)) - SetProperty (toolsets, "RoslynTargetsPath", paths.RoslynTargetsPath); - SetProperty (toolsets, "NuGetProps", paths.NuGetProps); - SetProperty (toolsets, "NuGetTargets", paths.NuGetTargets); - SetProperty (toolsets, "NuGetRestoreTargets", paths.NuGetRestoreTargets); - SetProperty (toolsets, "MonoAndroidToolsDirectory", paths.MonoAndroidToolsDirectory); - SetProperty (toolsets, "TargetFrameworkRootPath", paths.FrameworksDirectory + Path.DirectorySeparatorChar); //NOTE: Must include trailing \ - if (!string.IsNullOrEmpty (paths.AndroidSdkDirectory)) - SetProperty (toolsets, "AndroidSdkDirectory", paths.AndroidSdkDirectory); - - var projectImportSearchPaths = toolsets.SelectSingleNode ("projectImportSearchPaths"); - var searchPaths = projectImportSearchPaths.SelectSingleNode ($"searchPaths[@os='{paths.SearchPathsOS}']") as XmlElement; - if (searchPaths != null) { - foreach (XmlNode property in searchPaths.SelectNodes ("property[starts-with(@name, 'MSBuildExtensionsPath')]/@value")) { - property.Value = ""; - } - } - - Directory.CreateDirectory (paths.MSBuildTempPath); - File.WriteAllText (paths.MSBuildExeTempPath, ""); // File just has to *exist* - xml.Save (paths.XABuildConfig); - - if (Directory.Exists (paths.MSBuildSdksPath)) { - Environment.SetEnvironmentVariable ("MSBuildSDKsPath", paths.MSBuildSdksPath, EnvironmentVariableTarget.Process); - } - Environment.SetEnvironmentVariable ("MSBUILD_EXE_PATH", paths.MSBuildExeTempPath, EnvironmentVariableTarget.Process); - } - - /// - /// If the value exists, sets value attribute, else creates the element - /// - static void SetProperty (XmlNode toolsets, string name, string value) - { - if (string.IsNullOrEmpty (value)) - return; - - var valueAttribute = toolsets.SelectSingleNode ($"property[@name='{name}']/@value"); - if (valueAttribute != null) { - valueAttribute.Value = value; - } else { - var property = toolsets.OwnerDocument.CreateElement ("property"); - property.SetAttribute ("name", name); - property.SetAttribute ("value", value); - toolsets.PrependChild (property); - } - } - - static void CreateSdkResolverConfig (XABuildPaths paths) - { - if (string.IsNullOrEmpty (paths.SdkResolverConfigPath) || string.IsNullOrEmpty (paths.NuGetSdkResolverPath)) - return; - var dir = Path.GetDirectoryName (paths.SdkResolverConfigPath); - Directory.CreateDirectory (dir); - using (var writer = File.CreateText (paths.SdkResolverConfigPath)) { - writer.WriteLine (""); - writer.Write ("\t"); - writer.Write (paths.NuGetSdkResolverPath); - writer.WriteLine (""); - writer.WriteLine (""); - } - } - } -} diff --git a/tools/xabuild/XABuildPaths.cs b/tools/xabuild/XABuildPaths.cs deleted file mode 100644 index 9243d218e52..00000000000 --- a/tools/xabuild/XABuildPaths.cs +++ /dev/null @@ -1,334 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Runtime.InteropServices; -using Xamarin.Android.Tools.VSWhere; - -namespace Xamarin.Android.Build -{ - /// - /// Various paths needed by xabuild.exe - /// - class XABuildPaths - { - public bool IsWindows { get; private set; } - - public bool IsMacOS { get; private set; } - - public bool IsLinux { get; private set; } - - /// - /// Directory to xabuild.exe - /// - public string XABuildDirectory { get; private set; } - - /// - /// Path to xabuild.exe's config file, this is now a temporary file based on MSBuildExeTempPath - /// - public string XABuildConfig { get; private set; } - - /// - /// The build output directory of Xamarin.Android, which is a submodule in this repo. Assumes it is already built. - /// - public string XamarinAndroidBuildOutput { get; private set; } - - /// - /// $(VsInstallRoot), normally C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise - /// - public string VsInstallRoot { get; private set; } - - /// - /// Path to MSBuild directory - /// - public string MSBuildPath { get; private set; } - - /// - /// Path to directory of MSBuild.exe - /// - public string MSBuildBin { get; private set; } - - /// - /// Temporary directory used for MSBUILD_EXE_PATH - /// - public string MSBuildTempPath { get; private set; } - - /// - /// Temporary file used for MSBUILD_EXE_PATH - /// - public string MSBuildExeTempPath { get; private set; } - - /// - /// Config file needed for Microsoft.Build.NuGetSdkResolver.dll to work - /// - public string SdkResolverConfigPath { get; private set; } - - /// - /// Full path to the system Microsoft.Build.NuGetSdkResolver.dll - /// - public string NuGetSdkResolverPath { get; private set; } - - /// - /// Path to MSBuild's App.config file - /// - public string MSBuildConfig { get; private set; } - - /// - /// Path to the system directory containing .NETPortable and .NETFramework - /// - public string SystemFrameworks { get; private set; } - - /// - /// Path to the system directory containing .NET Framework assembly directories (e.g. `4.7.2-api`) on macOS. - /// The .NETFramework directories identified in redirect to this location. - /// - public string MonoSystemFrameworkRoot { get; private set; } - - /// - /// Path to the system directories for MSBuild targets, such as 15.0 and Microsoft, under $(MSBuildExtensionsPath) to be merged with in-tree MSBuildExtensionsPath - /// - public string [] SystemTargetsDirectories { get; private set; } - - /// - /// Used as the MSBuildSDKsPath environment variable, required for .NET standard projects to build - /// - public string MSBuildSdksPath { get; private set; } - - /// - /// Our default $(MSBuildExtensionPath) which should be the "xbuild" directory in the Xamarin.Android build output - /// - public string MSBuildExtensionsPath { get; private set; } - - /// - /// The xbuild-frameworks directory inside the Xamarin.Android build output - /// - public string FrameworksDirectory { get; private set; } - - /// - /// Search paths for MSBuildExtensionsPath are specified by an "os" attribute - /// NOTE: Values are "windows", "osx", or "unix" - /// - public string SearchPathsOS { get; set; } - - public string MonoAndroidToolsDirectory { get; private set; } - - public string AndroidSdkDirectory { get; private set; } - - public string AndroidNdkDirectory { get; private set; } - - public string DotNetSdkPath { get; private set; } - - public string NuGetTargets { get; private set; } - - public string NuGetProps { get; private set; } - - public string NuGetRestoreTargets { get; private set; } - - /// - /// The directory containing Microsoft.CSharp.Core.Targets - /// - /// In VS 2017 and 2019, this would be: %VsInstallDir%\MSBuild\15.0\Bin\Roslyn - /// - public string RoslynTargetsPath { get; private set; } - - public XABuildPaths () - { - IsWindows = Environment.OSVersion.Platform == PlatformID.Win32NT; - IsMacOS = !IsWindows && IsDarwin (); - IsLinux = !IsWindows && !IsMacOS; - XABuildDirectory = Path.GetDirectoryName (GetType ().Assembly.Location); - XamarinAndroidBuildOutput = Path.GetFullPath (Path.Combine (XABuildDirectory, "..")); - - string programFiles = Environment.GetFolderPath (Environment.SpecialFolder.ProgramFilesX86); - string prefix = Path.Combine (XamarinAndroidBuildOutput, "lib", "xamarin.android"); - - string DOTNET_ROOT = Environment.GetEnvironmentVariable ("DOTNET_ROOT"); - string dotnetRootSdkDir = DOTNET_ROOT == null ? null : Path.Combine (DOTNET_ROOT, "sdk"); - - if (IsWindows) { - var instance = MSBuildLocator.QueryLatest (); - VsInstallRoot = instance.VisualStudioRootPath; - - MSBuildPath = Path.Combine (VsInstallRoot, "MSBuild"); - MSBuildBin = Path.GetDirectoryName (instance.MSBuildPath); - MSBuildConfig = Path.Combine (MSBuildBin, "MSBuild.exe.config"); - DotNetSdkPath = FindLatestDotNetSdk (Path.Combine (Environment.GetEnvironmentVariable ("ProgramW6432"), "dotnet", "sdk"), dotnetRootSdkDir); - MSBuildSdksPath = DotNetSdkPath ?? Path.Combine (MSBuildPath, "Sdks"); - SystemFrameworks = Path.Combine (programFiles, "Reference Assemblies", "Microsoft", "Framework"); - string msbuildDir = Path.GetDirectoryName (MSBuildBin); - SystemTargetsDirectories = new [] { - msbuildDir, - Path.Combine (MSBuildPath, "Microsoft"), - Path.Combine (programFiles, "MSBuild", "Microsoft"), - }; - SearchPathsOS = "windows"; - string nuget = Path.Combine (MSBuildPath, "Microsoft", "NuGet", "17.0"); - if (!Directory.Exists (nuget)) { - nuget = Path.Combine (MSBuildPath, "Microsoft", "NuGet", "16.0"); - } - NuGetProps = Path.Combine (nuget, "Microsoft.NuGet.props"); - NuGetTargets = Path.Combine (nuget, "Microsoft.NuGet.targets"); - var nugetDirectory = Path.Combine (VsInstallRoot, "Common7", "IDE", "CommonExtensions", "Microsoft", "NuGet"); - NuGetRestoreTargets = Path.Combine (nugetDirectory, "NuGet.targets"); - NuGetSdkResolverPath = Path.Combine (nugetDirectory, "Microsoft.Build.NuGetSdkResolver.dll"); - } else { - string[] vsVersions = new [] {"Current", "15.0"}; - string mono = IsMacOS ? "/Library/Frameworks/Mono.framework/Versions/Current/lib/mono" : "/usr/lib/mono"; - string monoExternal = IsMacOS ? "/Library/Frameworks/Mono.framework/External/" : "/usr/lib/mono"; - MSBuildPath = Path.Combine (mono, "msbuild"); - - MSBuildBin = null; - foreach (string vsVersion in vsVersions) { - MSBuildBin = Path.Combine (MSBuildPath, vsVersion, "bin"); - if (Directory.Exists (MSBuildBin)) - break; - } - if (string.IsNullOrEmpty (MSBuildBin)) - throw new InvalidOperationException ("Unable to locate MSBuild binaries directory"); - - MSBuildConfig = Path.Combine (MSBuildBin, "MSBuild.dll.config"); - DotNetSdkPath = FindLatestDotNetSdk ("/usr/local/share/dotnet/sdk", dotnetRootSdkDir); - MSBuildSdksPath = DotNetSdkPath ?? Path.Combine (MSBuildBin, "Sdks"); - SystemFrameworks = Path.Combine (mono, "xbuild-frameworks"); - MonoSystemFrameworkRoot = mono; - - var systemTargetDirs = new List (); - foreach (string vsVersion in vsVersions) { - string xbuildDir = Path.Combine (mono, "xbuild", vsVersion); - if (!Directory.Exists (xbuildDir)) - continue; - systemTargetDirs.Add (xbuildDir); - } - if (systemTargetDirs.Count == 0) - throw new InvalidOperationException ("Unable to locate xbuild directory"); - systemTargetDirs.Add (Path.Combine (mono, "xbuild", "Microsoft")); - SystemTargetsDirectories = systemTargetDirs.ToArray (); - SearchPathsOS = IsMacOS ? "osx" : "unix"; - - string nuget = Path.Combine (mono, "xbuild", "Microsoft", "NuGet"); - if (Directory.Exists (nuget)) { - NuGetTargets = Path.Combine (nuget, "Microsoft.NuGet.targets"); - NuGetProps = Path.Combine (nuget, "Microsoft.NuGet.props"); - } - NuGetRestoreTargets = Path.Combine (MSBuildBin, "NuGet.targets"); - NuGetSdkResolverPath = Path.Combine (MSBuildBin, "Microsoft.Build.NuGetSdkResolver.dll"); - if (!File.Exists (NuGetRestoreTargets) && !string.IsNullOrEmpty (DotNetSdkPath)) { - NuGetRestoreTargets = Path.Combine (DotNetSdkPath, "..", "NuGet.targets"); - NuGetSdkResolverPath = Path.Combine (DotNetSdkPath, "..", "Microsoft.Build.NuGetSdkResolver.dll"); - } - } - - FrameworksDirectory = Path.Combine (prefix, "xbuild-frameworks"); - MSBuildExtensionsPath = Path.Combine (prefix, "xbuild"); - MonoAndroidToolsDirectory = Path.Combine (prefix, "xbuild", "Xamarin", "Android"); - MSBuildTempPath = Path.Combine (Path.GetTempPath (), Path.GetRandomFileName ()); - MSBuildExeTempPath = Path.Combine (MSBuildTempPath, Path.GetRandomFileName ()); - SdkResolverConfigPath = Path.Combine (MSBuildTempPath, "SdkResolvers", "Microsoft.Build.NuGetSdkResolver", "Microsoft.Build.NuGetSdkResolver.xml"); - XABuildConfig = MSBuildExeTempPath + ".config"; - - var roslyn = Path.Combine (MSBuildBin, "Roslyn"); - if (Directory.Exists (roslyn)) { - RoslynTargetsPath = roslyn; - } else { - //NOTE: this codepath happens with VS 2019, Roslyn is located in a 15.0 directory... - roslyn = Path.Combine (MSBuildPath, "15.0", "Bin", "Roslyn"); - if (Directory.Exists (roslyn)) - RoslynTargetsPath = roslyn; - } - - //Android SDK and NDK - var pathsTargets = Path.Combine (XABuildDirectory, "..", "..", "..", "build-tools", "scripts", "Paths.targets"); - if (File.Exists (pathsTargets)) { - var androidSdkPath = Environment.GetEnvironmentVariable ("ANDROID_SDK_PATH"); - if (string.IsNullOrEmpty (androidSdkPath)) { - androidSdkPath = RunPathsTargets (pathsTargets, "GetAndroidSdkFullPath"); - } - AndroidSdkDirectory = androidSdkPath; - - var androidNdkPath = Environment.GetEnvironmentVariable ("ANDROID_NDK_PATH"); - if (string.IsNullOrEmpty (androidNdkPath)) { - androidNdkPath = RunPathsTargets (pathsTargets, "GetAndroidNdkFullPath"); - } - AndroidNdkDirectory = androidNdkPath; - } - } - - [DllImport ("libc")] - static extern int uname (IntPtr buf); - - static bool IsDarwin () - { - IntPtr buf = IntPtr.Zero; - try { - buf = Marshal.AllocHGlobal (8192); - if (uname (buf) == 0) { - string os = Marshal.PtrToStringAnsi (buf); - return os == "Darwin"; - } - } catch { - } finally { - if (buf != IntPtr.Zero) - Marshal.FreeHGlobal (buf); - } - return false; - } - - string RunPathsTargets (string pathsTargets, string target) - { - var path = IsWindows ? Path.Combine(MSBuildBin, "MSBuild.exe") : "mono"; - var args = $"/nologo /v:minimal /t:{target} \"{pathsTargets}\""; - if (!IsWindows) { - args = $"\"{Path.Combine (MSBuildBin, "MSBuild.dll")}\" {args}"; - } - - var psi = new ProcessStartInfo (path, args) { - CreateNoWindow = true, - RedirectStandardOutput = true, - WindowStyle = ProcessWindowStyle.Hidden, - UseShellExecute = false, - }; - - using (var p = Process.Start (psi)) { - p.WaitForExit (); - return p.StandardOutput.ReadToEnd ().Trim (); - } - } - - string FindLatestDotNetSdk (params string[] dotNetPaths) - { - Version latest = new Version (0,0); - string Sdk = null; - - foreach (var dotNetPath in dotNetPaths) { - if (!Directory.Exists (dotNetPath)) - continue; - foreach (var dir in Directory.EnumerateDirectories (dotNetPath)) { - var version = GetVersionFromDirectory (dir); - var sdksDir = Path.Combine (dir, "Sdks"); - if (!Directory.Exists (sdksDir)) - sdksDir = Path.Combine (dir, "bin", "Sdks"); - if (version != null && version > latest) { - // Mono does not yet support MSBuild 16.8 and .NET 5+. If we want xabuild to be aware of .NET 5+ in the future, - // we will need to workaround the fact that the .NET 5 targets now require a version of `NuGet.Frameworks.dll` next to `MSBuildExeTempPath`: - // https://github.com/dotnet/msbuild/blob/755d4d1e3d2a89f72f659fc3d7d2933cab619828/src/Build/Utilities/NuGetFrameworkWrapper.cs#L32 - if (version >= new Version (5, 0, 100)) { - continue; - } - if (Directory.Exists (sdksDir) && File.Exists (Path.Combine (sdksDir, "Microsoft.NET.Sdk", "Sdk", "Sdk.props"))) { - latest = version; - Sdk = sdksDir; - } - } - } - } - return Sdk; - } - - static Version GetVersionFromDirectory(string dir) - { - Version v; - Version.TryParse (Path.GetFileName (dir), out v); - return v; - } - } -} diff --git a/tools/xabuild/xabuild.csproj b/tools/xabuild/xabuild.csproj deleted file mode 100644 index fcb181aaf69..00000000000 --- a/tools/xabuild/xabuild.csproj +++ /dev/null @@ -1,46 +0,0 @@ - - - Exe - Xamarin.Android.Build - xabuild - x86 - net472 - ..\..\bin\$(Configuration)\bin - false - <_MSBuildExtension Condition=" '$(OS)' == 'Windows_NT' ">exe - <_MSBuildExtension Condition=" '$(OS)' != 'Windows_NT' ">dll - true - ..\..\product.snk - - - - - - - - - - - $(MSBuildToolsPath)\MSBuild.$(_MSBuildExtension) - - - $(MSBuildToolsPath)\Microsoft.Build.dll - - - $(MSBuildToolsPath)\Microsoft.Build.Framework.dll - - - $(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll - - - $(MSBuildToolsPath)\Microsoft.Build.Utilities.Core.dll - - - - - - xabuild - PreserveNewest - - - \ No newline at end of file