diff --git a/Documentation/building/windows/instructions.md b/Documentation/building/windows/instructions.md index 3e20038677a..eb34a08c4ca 100644 --- a/Documentation/building/windows/instructions.md +++ b/Documentation/building/windows/instructions.md @@ -20,7 +20,8 @@ MSBuild version 15 or later is required. 5. In a [Developer Command Prompt][developer-prompt], prepare the project: - dotnet msbuild Xamarin.Android.sln -t:Prepare + dotnet msbuild Xamarin.Android.sln -t:Prepare -nodeReuse:false + dotnet msbuild external\Java.Interop\Java.Interop.sln -t:Prepare -nodeReuse:false This will ensure that the build dependencies are installed, perform `git submodule update`, download NuGet dependencies, and other @@ -28,13 +29,9 @@ MSBuild version 15 or later is required. 6. Build the project: - dotnet-local.cmd build Xamarin.Android.sln -m:1 + dotnet-local.cmd build Xamarin.Android.sln -nodeReuse:false - 7. In order to use the in-tree Xamarin.Android, build xabuild: - - msbuild tools/xabuild/xabuild.csproj /restore - - 8. (For Microsoft team members only - Optional) In a [Developer Command + 7. (For Microsoft team members only - Optional) In a [Developer Command Prompt][developer-prompt], build external proprietary git dependencies: diff --git a/build-tools/automation/azure-pipelines.yaml b/build-tools/automation/azure-pipelines.yaml index f1213c08282..504a82311af 100644 --- a/build-tools/automation/azure-pipelines.yaml +++ b/build-tools/automation/azure-pipelines.yaml @@ -112,7 +112,7 @@ stages: restoreNUnitConsole: false updateMono: false xaprepareScenario: EmulatorTestDependencies - + - task: DownloadPipelineArtifact@2 inputs: artifactName: $(TestAssembliesArtifactName) @@ -140,7 +140,7 @@ stages: arguments: -t:PrepareJavaInterop -c $(XA.Build.Configuration) --no-restore displayName: prepare java.interop $(XA.Build.Configuration) continueOnError: false - + - template: yaml-templates/start-stop-emulator.yaml - template: yaml-templates/apk-instrumentation.yaml @@ -201,7 +201,7 @@ stages: extraBuildArgs: -p:TestsFlavor=AotLlvm -p:EnableLLVM=true -p:AndroidEnableProfiledAot=false artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab artifactFolder: $(DotNetTargetFramework)-AotLlvm - + - template: yaml-templates/apk-instrumentation.yaml parameters: configuration: $(XA.Build.Configuration) @@ -220,13 +220,19 @@ stages: artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Xamarin.Android.JcwGen_Tests-Signed.apk artifactFolder: $(DotNetTargetFramework)-FastDev_Assemblies_Dexes extraBuildArgs: /p:AndroidFastDeploymentType=Assemblies:Dexes - + - template: yaml-templates/run-nunit-tests.yaml parameters: testRunTitle: Xamarin.Android.Tools.Aidl-Tests - macOS testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/$(DotNetStableTargetFramework)/Xamarin.Android.Tools.Aidl-Tests.dll testResultsFile: TestResult-Aidl-Tests-macOS-$(XA.Build.Configuration).xml + - task: ShellScript@2 + displayName: Test dotnet-local.sh + inputs: + scriptPath: dotnet-local.sh + args: build samples/HelloWorld/HelloWorld/HelloWorld.DotNet.csproj + - ${{ if ne(parameters.macTestAgentsUseCleanImages, true) }}: - template: yaml-templates/start-stop-emulator.yaml parameters: @@ -276,6 +282,12 @@ stages: dotNetTestExtraArgs: --filter "TestCategory = SmokeTests" testResultsFile: TestResult-NETSmokeMSBuildTests-Linux-$(XA.Build.Configuration).xml + - task: ShellScript@2 + displayName: Test dotnet-local.sh + inputs: + scriptPath: dotnet-local.sh + args: build samples/HelloWorld/HelloWorld/HelloWorld.DotNet.csproj + - template: yaml-templates/upload-results.yaml parameters: configuration: $(XA.Build.Configuration) diff --git a/build-tools/automation/yaml-templates/build-windows.yaml b/build-tools/automation/yaml-templates/build-windows.yaml index ea65a643e0d..133c87ba616 100644 --- a/build-tools/automation/yaml-templates/build-windows.yaml +++ b/build-tools/automation/yaml-templates/build-windows.yaml @@ -98,6 +98,12 @@ stages: testResultsFile: TestResult-SmokeMSBuildTests-WinDotnetBuild-$(XA.Build.Configuration).xml dotNetTestExtraArgs: --filter "TestCategory = SmokeTests" + - task: BatchScript@1 + displayName: Test dotnet-local.cmd + inputs: + filename: dotnet-local.cmd + arguments: build samples\HelloWorld\HelloWorld\HelloWorld.DotNet.csproj + - template: upload-results.yaml parameters: artifactName: ${{ parameters.buildResultArtifactName }} diff --git a/build-tools/scripts/PrepareWindows.targets b/build-tools/scripts/PrepareWindows.targets index cadc50f52d0..4b69d9d8b5a 100644 --- a/build-tools/scripts/PrepareWindows.targets +++ b/build-tools/scripts/PrepareWindows.targets @@ -24,5 +24,6 @@ /> + diff --git a/build.cmd b/build.cmd index 3acc5fdf3f6..a8420ae0b86 100644 --- a/build.cmd +++ b/build.cmd @@ -8,23 +8,21 @@ IF ERRORLEVEL 1 CALL:FAILED_CASE IF ERRORLEVEL 1 CALL :DEFAULT_CASE :Prepare_CASE - dotnet build Xamarin.Android.sln -t:Prepare -nr:false + dotnet msbuild Xamarin.Android.sln -t:Prepare -nodeReuse:false GOTO END_CASE :PrepareExternal_CASE - dotnet build Xamarin.Android.sln -t:PrepareExternal -nr:false + dotnet build Xamarin.Android.sln -t:PrepareExternal -nodeReuse:false GOTO END_CASE :Build_CASE - dotnet-local.cmd build Xamarin.Android.sln -nr:false - dotnet-local.cmd build tools/xabuild/xabuild.csproj -nr:false + dotnet-local.cmd build Xamarin.Android.sln -nodeReuse:false GOTO END_CASE :Pack_CASE - dotnet-local.cmd build Xamarin.Android.sln -t:PackDotNet -nr:false + dotnet-local.cmd build Xamarin.Android.sln -t:PackDotNet -nodeReuse:false GOTO END_CASE :DEFAULT_CASE - dotnet build Xamarin.Android.sln -t:Prepare -nr:false - dotnet-local.cmd build Xamarin.Android.sln -nr:false - dotnet-local.cmd build tools/xabuild/xabuild.csproj -nr:false - dotnet-local.cmd build Xamarin.Android.sln -t:PackDotNet -nr:false + dotnet msbuild Xamarin.Android.sln -t:Prepare -nodeReuse:false + dotnet-local.cmd build Xamarin.Android.sln -nodeReuse:false + dotnet-local.cmd build Xamarin.Android.sln -t:PackDotNet -nodeReuse:false GOTO END_CASE :FAILED_CASE echo "Failed to find an instance of Visual Studio. Please check it is correctly installed." diff --git a/dotnet-local.cmd b/dotnet-local.cmd index 9238226fba6..5fad9a27b88 100644 --- a/dotnet-local.cmd +++ b/dotnet-local.cmd @@ -1,13 +1,22 @@ @echo off +SETLOCAL + SET ROOT=%~dp0 + IF EXIST "%ROOT%\bin\Release\dotnet\dotnet.exe" ( - SET DOTNETSDK_WORKLOAD_MANIFEST_ROOTS=%ROOT%\bin\Release\lib\sdk-manifests - SET DOTNETSDK_WORKLOAD_PACK_ROOTS=%ROOT%\bin\Release\lib - call "%ROOT%\bin\Release\dotnet\dotnet.exe" %* + SET XA_CONFIG=Release ) ELSE IF EXIST "%ROOT%\bin\Debug\dotnet\dotnet.exe" ( - SET DOTNETSDK_WORKLOAD_MANIFEST_ROOTS=%ROOT%\bin\Debug\lib\sdk-manifests - SET DOTNETSDK_WORKLOAD_PACK_ROOTS=%ROOT%\bin\Debug\lib - call "%ROOT%\bin\Debug\dotnet\dotnet.exe" %* + SET XA_CONFIG=Debug ) ELSE ( echo "You need to run 'msbuild Xamarin.Android.sln /t:Prepare' first." -) \ No newline at end of file + goto :exit +) + +SET XA_DOTNET_ROOT=%ROOT%\bin\%XA_CONFIG%\dotnet +SET PATH=%XA_DOTNET_ROOT%;%PATH% +SET DOTNETSDK_WORKLOAD_MANIFEST_ROOTS=%ROOT%\bin\%XA_CONFIG%\lib\sdk-manifests +SET DOTNETSDK_WORKLOAD_PACK_ROOTS=%ROOT%\bin\%XA_CONFIG%\lib + +call "%XA_DOTNET_ROOT%\dotnet.exe" %* + +:exit diff --git a/dotnet-local.sh b/dotnet-local.sh index 39738ff4355..f61c7cbf154 100755 --- a/dotnet-local.sh +++ b/dotnet-local.sh @@ -1,10 +1,15 @@ #!/bin/bash ROOT="$(dirname "${BASH_SOURCE}")" FULLROOT="$(cd "${ROOT}"; pwd)" -if [[ -x "${ROOT}/bin/Release/dotnet/dotnet" ]]; then - DOTNETSDK_WORKLOAD_MANIFEST_ROOTS=${FULLROOT}/bin/Release/lib/sdk-manifests DOTNETSDK_WORKLOAD_PACK_ROOTS=${FULLROOT}/bin/Release/lib exec ${ROOT}/bin/Release/dotnet/dotnet "$@" -elif [[ -x "${ROOT}/bin/Debug/dotnet/dotnet" ]]; then - DOTNETSDK_WORKLOAD_MANIFEST_ROOTS=${FULLROOT}/bin/Debug/lib/sdk-manifests DOTNETSDK_WORKLOAD_PACK_ROOTS=${FULLROOT}/bin/Debug/lib exec ${ROOT}/bin/Debug/dotnet/dotnet "$@" -else - echo "You need to run 'make prepare' first." -fi \ No newline at end of file +for config in Release Debug ; do + if [[ ! -x "${ROOT}/bin/${config}/dotnet/dotnet" ]] ; then + continue + fi + XA_DOTNET_ROOT="${FULLROOT}/bin/${config}/dotnet" + export PATH="${XA_DOTNET_ROOT}:${PATH}" + export DOTNETSDK_WORKLOAD_MANIFEST_ROOTS="${FULLROOT}/bin/${config}/lib/sdk-manifests" + export DOTNETSDK_WORKLOAD_PACK_ROOTS="${FULLROOT}/bin/${config}/lib" + exec "${ROOT}/bin/${config}/dotnet/dotnet" "$@" +done + +echo "You need to run 'make prepare' first." diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/DotNetCLI.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/DotNetCLI.cs index d049bcc61ee..e2631188050 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/DotNetCLI.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/DotNetCLI.cs @@ -152,7 +152,7 @@ List GetDefaultCommandLineArgs (string verb, string target = null, strin $"/flp1:LogFile=\"{BuildLogFile}\";Encoding=UTF-8;Verbosity={Verbosity}", $"/bl:\"{Path.Combine (testDir, $"{(string.IsNullOrEmpty (target) ? "msbuild" : target)}.binlog")}\"", "-m:1", - "-nr:false", + "-nodeReuse:false", "/p:_DisableParallelAot=true", }; if (!string.IsNullOrEmpty (target)) {