From 6f8d9ba8dfcd69d6bd9424c2a616d95c081ce9f7 Mon Sep 17 00:00:00 2001 From: John Luo Date: Sat, 29 Jun 2019 17:33:44 -0700 Subject: [PATCH 1/9] Add support for source-build --- .azure/pipelines/ci.yml | 47 ++++++ Directory.Build.targets | 3 + eng/Build.props | 10 +- eng/Dependencies.props | 143 ++++++++++-------- eng/Workarounds.targets | 7 +- eng/WorkaroundsImported.targets | 5 + eng/scripts/ci-source-build.sh | 39 +++++ eng/targets/CSharp.Common.props | 2 +- eng/targets/ResolveReferences.targets | 6 +- eng/tools/RepoTasks/RepoTasks.csproj | 2 + .../Microsoft.AspNetCore.App.Runtime.csproj | 14 +- .../Microsoft.AspNetCore.Identity.UI.csproj | 6 +- 12 files changed, 207 insertions(+), 77 deletions(-) create mode 100644 eng/WorkaroundsImported.targets create mode 100755 eng/scripts/ci-source-build.sh diff --git a/.azure/pipelines/ci.yml b/.azure/pipelines/ci.yml index d6a660b48bb2..80935a2a4273 100644 --- a/.azure/pipelines/ci.yml +++ b/.azure/pipelines/ci.yml @@ -471,3 +471,50 @@ jobs: - name: Linux_Test_Results path: artifacts/TestResults/ publishOnError: true + +# Source build +- job: Source_Build + displayName: 'Test: Linux Source Build' + container: centos:7 + pool: + vmImage: 'ubuntu-16.04' + variables: + DotNetCoreSdkDir: $(Agent.ToolsDirectory)/dotnet + DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: true + steps: + - script: | + source eng/common/native/common-library.sh + mkdir -p $HOME/bin + GetFile https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 $HOME/bin/jq + chmod +x $HOME/bin/jq + echo "##vso[task.prependpath]$HOME/bin" + displayName: Install jq + - task: UseDotNet@2 + displayName: 'Use .NET Core sdk' + inputs: + packageType: sdk + # The SDK version selected here is intentionally supposed to use the latest release + # For the purpose of building Linux distros, we can't depend on features of the SDK + # which may not exist in pre-built versions of the SDK + version: 3.0.x + installationPath: $(DotNetCoreSdkDir) + includePreviewVersions: true + - script: ./eng/scripts/ci-source-build.sh --ci --configuration Release /p:BuildManaged=true + displayName: Run ci-source-build.sh + - task: PublishBuildArtifacts@1 + displayName: Upload logs + condition: always() + continueOnError: true + inputs: + pathtoPublish: artifacts/log/ + artifactName: Source_Build_Logs + artifactType: Container + parallel: true + - task: PublishBuildArtifacts@1 + displayName: Upload package artifacts + condition: always() + inputs: + pathtoPublish: artifacts/packages/ + artifactName: Source_Build_Packages + artifactType: Container + parallel: true diff --git a/Directory.Build.targets b/Directory.Build.targets index 9f6393d13241..104fb22306a9 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -14,6 +14,9 @@ By default, assemblies which are only in the Microsoft.AspNetCore.App shared framework are not available as NuGet packages. --> false + + + true diff --git a/eng/Build.props b/eng/Build.props index eba7a2ac911a..7f1a45116f68 100644 --- a/eng/Build.props +++ b/eng/Build.props @@ -121,6 +121,12 @@ Use caution to avoid deep recursion. If the globbing pattern picks up something which exceeds MAX_PATH, the entire pattern will silently fail to evaluate correctly. --> + + + + + - - - - - - - - - - - - - - - - + - - - - - @@ -52,17 +30,9 @@ and are generated based on the last package release. - - - - - - - - @@ -94,13 +64,11 @@ and are generated based on the last package release. - - @@ -112,42 +80,15 @@ and are generated based on the last package release. - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -155,15 +96,8 @@ and are generated based on the last package release. - - - - - - - @@ -177,4 +111,79 @@ and are generated based on the last package release. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/eng/Workarounds.targets b/eng/Workarounds.targets index 029cbbc390c8..83e176a4a875 100644 --- a/eng/Workarounds.targets +++ b/eng/Workarounds.targets @@ -21,10 +21,15 @@ - + + + + diff --git a/eng/WorkaroundsImported.targets b/eng/WorkaroundsImported.targets new file mode 100644 index 000000000000..3b6f29f36215 --- /dev/null +++ b/eng/WorkaroundsImported.targets @@ -0,0 +1,5 @@ + + + + + diff --git a/eng/scripts/ci-source-build.sh b/eng/scripts/ci-source-build.sh new file mode 100755 index 000000000000..8b4c801d3af7 --- /dev/null +++ b/eng/scripts/ci-source-build.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + + # +# This script is meant for testing source build by imitating some of the input parameters and conditions. +# + +set -euo pipefail + +scriptroot="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +reporoot="$(dirname "$(dirname "$scriptroot")")" + + # For local development, make a backup copy of this file first +if [ ! -f "$reporoot/global.bak.json" ]; then + mv "$reporoot/global.json" "$reporoot/global.bak.json" +fi + + # Detect the current version of .NET Core installed +export SDK_VERSION=$(dotnet --version) +echo "The ambient version of .NET Core SDK version = $SDK_VERSION" + + # Update the global.json file to match the current .NET environment +cat "$reporoot/global.bak.json" | \ + jq '.sdk.version=env.SDK_VERSION' | \ + jq '.tools.dotnet=env.SDK_VERSION' | \ + jq 'del(.tools.runtimes)' \ + > "$reporoot/global.json" + + # Restore the original global.json file +trap "{ + mv "$reporoot/global.bak.json" "$reporoot/global.json" +}" EXIT + +export DotNetBuildFromSource='true' + + # Build repo tasks +"$reporoot/eng/common/build.sh" --restore --build --ci --configuration Release /p:ProjectToBuild=$reporoot/eng/tools/RepoTasks/RepoTasks.csproj + + # Build projects +"$reporoot/eng/common/build.sh" --restore --build --pack "$@" \ No newline at end of file diff --git a/eng/targets/CSharp.Common.props b/eng/targets/CSharp.Common.props index 64966a92d3ce..6cc6bd2dd81f 100644 --- a/eng/targets/CSharp.Common.props +++ b/eng/targets/CSharp.Common.props @@ -11,7 +11,7 @@ - + diff --git a/eng/targets/ResolveReferences.targets b/eng/targets/ResolveReferences.targets index 684660fed175..263edf3eaa04 100644 --- a/eng/targets/ResolveReferences.targets +++ b/eng/targets/ResolveReferences.targets @@ -19,6 +19,8 @@ + true + ResolveCustomReferences; $(ResolveReferencesDependsOn); @@ -60,7 +62,7 @@ - + true @@ -129,7 +131,7 @@ This target resolves remaining Referene items to Packages, if possible. If not, they are left as Reference items fo the SDK to resolve. This executes on NuGet restore and during DesignTimeBuild. It should not run in the outer, cross-targeting build. --> - + diff --git a/eng/tools/RepoTasks/RepoTasks.csproj b/eng/tools/RepoTasks/RepoTasks.csproj index f62865e20323..0bf6be98ae93 100644 --- a/eng/tools/RepoTasks/RepoTasks.csproj +++ b/eng/tools/RepoTasks/RepoTasks.csproj @@ -7,6 +7,8 @@ false embedded true + + false diff --git a/src/Framework/src/Microsoft.AspNetCore.App.Runtime.csproj b/src/Framework/src/Microsoft.AspNetCore.App.Runtime.csproj index 7bc95d9fe5ef..6df35e172392 100644 --- a/src/Framework/src/Microsoft.AspNetCore.App.Runtime.csproj +++ b/src/Framework/src/Microsoft.AspNetCore.App.Runtime.csproj @@ -8,6 +8,8 @@ false $(MSBuildProjectName).$(RuntimeIdentifier) true + + false false Provides a default set of APIs for building an ASP.NET Core application. Contains assets used for self-contained deployments. @@ -362,11 +364,17 @@ This package is an internal implementation of the .NET Core SDK and is not meant ######################################### --> - + + + + @@ -412,7 +420,9 @@ This package is an internal implementation of the .NET Core SDK and is not meant - + diff --git a/src/Identity/UI/src/Microsoft.AspNetCore.Identity.UI.csproj b/src/Identity/UI/src/Microsoft.AspNetCore.Identity.UI.csproj index f34b186e0df3..49f3f003b666 100644 --- a/src/Identity/UI/src/Microsoft.AspNetCore.Identity.UI.csproj +++ b/src/Identity/UI/src/Microsoft.AspNetCore.Identity.UI.csproj @@ -40,7 +40,8 @@ - + + - + + From a34d389701f4043adcd0c96de41f28fe715fa73c Mon Sep 17 00:00:00 2001 From: = Date: Tue, 2 Jul 2019 18:35:22 -0700 Subject: [PATCH 2/9] Try to exclude Ref package This should be excluded already, and is already excluded locally not sure why it's being built on the CI --- eng/Build.props | 4 ++-- src/Framework/ref/Microsoft.AspNetCore.App.Ref.csproj | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/eng/Build.props b/eng/Build.props index 7f1a45116f68..f0a6dac08162 100644 --- a/eng/Build.props +++ b/eng/Build.props @@ -154,8 +154,8 @@ $(RepoRoot)src\Analyzers\**\*.csproj; $(RepoRoot)src\ProjectTemplates\*\*.csproj; $(RepoRoot)src\ProjectTemplates\testassets\*\*.csproj; - " /> - false + + true $(TargetingPackName) $(TargetingPackVersionPrefix) From fb600f677ffd4f5296833e141afd032726d9eba1 Mon Sep 17 00:00:00 2001 From: = Date: Tue, 2 Jul 2019 18:53:32 -0700 Subject: [PATCH 3/9] Try exclusion --- eng/Build.props | 6 ++++-- src/Framework/ref/Microsoft.AspNetCore.App.Ref.csproj | 2 -- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/eng/Build.props b/eng/Build.props index f0a6dac08162..aa2a05070664 100644 --- a/eng/Build.props +++ b/eng/Build.props @@ -122,9 +122,11 @@ the entire pattern will silently fail to evaluate correctly. --> - + + false - - true $(TargetingPackName) $(TargetingPackVersionPrefix) From 7d6d90d504fcec7a707fe9ad06471a830d4b3842 Mon Sep 17 00:00:00 2001 From: = Date: Wed, 3 Jul 2019 17:37:36 -0700 Subject: [PATCH 4/9] Update --- eng/AfterSolutionBuild.targets | 2 +- eng/Build.props | 7 ------- src/Framework/ref/Microsoft.AspNetCore.App.Ref.csproj | 7 +++++-- src/Tools/dotnet-dev-certs/src/dotnet-dev-certs.csproj | 2 ++ src/Tools/dotnet-sql-cache/src/dotnet-sql-cache.csproj | 2 ++ .../dotnet-user-secrets/src/dotnet-user-secrets.csproj | 2 ++ src/Tools/dotnet-watch/src/dotnet-watch.csproj | 2 ++ src/Tools/dotnet-watch/test/dotnet-watch.Tests.csproj | 6 ++++-- 8 files changed, 18 insertions(+), 12 deletions(-) diff --git a/eng/AfterSolutionBuild.targets b/eng/AfterSolutionBuild.targets index 3857e1523950..24f5a1b8b258 100644 --- a/eng/AfterSolutionBuild.targets +++ b/eng/AfterSolutionBuild.targets @@ -17,7 +17,7 @@ SharedFrameworkTargetFramework="netcoreapp$(AspNetCoreMajorVersion).$(AspNetCoreMinorVersion)" /> - + - - - - + + $(BuildDependsOn); GeneratePackageConflictManifest; _ResolveTargetingPackContent; @@ -76,6 +76,9 @@ This package is an internal implementation of the .NET Core SDK and is not meant _InstallTargetingPackIntoLocalDotNet; _CreateTargetingPackArchive; + + + diff --git a/src/Tools/dotnet-dev-certs/src/dotnet-dev-certs.csproj b/src/Tools/dotnet-dev-certs/src/dotnet-dev-certs.csproj index a7903fc79c72..1b143b69b736 100644 --- a/src/Tools/dotnet-dev-certs/src/dotnet-dev-certs.csproj +++ b/src/Tools/dotnet-dev-certs/src/dotnet-dev-certs.csproj @@ -9,6 +9,8 @@ true false + + true diff --git a/src/Tools/dotnet-sql-cache/src/dotnet-sql-cache.csproj b/src/Tools/dotnet-sql-cache/src/dotnet-sql-cache.csproj index b40f89eece2c..0e080f191de9 100644 --- a/src/Tools/dotnet-sql-cache/src/dotnet-sql-cache.csproj +++ b/src/Tools/dotnet-sql-cache/src/dotnet-sql-cache.csproj @@ -7,6 +7,8 @@ cache;distributedcache;sqlserver true true + + true diff --git a/src/Tools/dotnet-user-secrets/src/dotnet-user-secrets.csproj b/src/Tools/dotnet-user-secrets/src/dotnet-user-secrets.csproj index f9e7f56f0baa..3b444be84ce0 100644 --- a/src/Tools/dotnet-user-secrets/src/dotnet-user-secrets.csproj +++ b/src/Tools/dotnet-user-secrets/src/dotnet-user-secrets.csproj @@ -10,6 +10,8 @@ true false + + true diff --git a/src/Tools/dotnet-watch/src/dotnet-watch.csproj b/src/Tools/dotnet-watch/src/dotnet-watch.csproj index b289e142877f..c124bcb00dc1 100644 --- a/src/Tools/dotnet-watch/src/dotnet-watch.csproj +++ b/src/Tools/dotnet-watch/src/dotnet-watch.csproj @@ -9,6 +9,8 @@ true false + + true diff --git a/src/Tools/dotnet-watch/test/dotnet-watch.Tests.csproj b/src/Tools/dotnet-watch/test/dotnet-watch.Tests.csproj index 349e681dbf68..49aebd14822b 100644 --- a/src/Tools/dotnet-watch/test/dotnet-watch.Tests.csproj +++ b/src/Tools/dotnet-watch/test/dotnet-watch.Tests.csproj @@ -28,13 +28,15 @@ - + + - + + From 42912c3d3029a2fd4175d27f4de01e13978dc1c7 Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 5 Jul 2019 14:39:45 -0700 Subject: [PATCH 5/9] Do not build redist tarball in source build --- eng/Build.props | 1 - .../src/Microsoft.AspNetCore.App.Runtime.csproj | 13 ++++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/eng/Build.props b/eng/Build.props index 11c7f15c251e..eba7a2ac911a 100644 --- a/eng/Build.props +++ b/eng/Build.props @@ -121,7 +121,6 @@ Use caution to avoid deep recursion. If the globbing pattern picks up something which exceeds MAX_PATH, the entire pattern will silently fail to evaluate correctly. --> - - - + - - - @@ -447,7 +441,8 @@ This package is an internal implementation of the .NET Core SDK and is not meant Condition="'$(ArchiveExtension)' == '.tar.gz'" /> - From 8d367b58a9eaffab85bdc3f891640c2e059402a3 Mon Sep 17 00:00:00 2001 From: = Date: Fri, 5 Jul 2019 14:58:42 -0700 Subject: [PATCH 6/9] Add comment --- src/Framework/src/Microsoft.AspNetCore.App.Runtime.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Framework/src/Microsoft.AspNetCore.App.Runtime.csproj b/src/Framework/src/Microsoft.AspNetCore.App.Runtime.csproj index f5632a82afb7..d483371a187a 100644 --- a/src/Framework/src/Microsoft.AspNetCore.App.Runtime.csproj +++ b/src/Framework/src/Microsoft.AspNetCore.App.Runtime.csproj @@ -441,6 +441,7 @@ This package is an internal implementation of the .NET Core SDK and is not meant Condition="'$(ArchiveExtension)' == '.tar.gz'" /> + Date: Fri, 5 Jul 2019 15:07:40 -0700 Subject: [PATCH 7/9] Cleanup --- .../src/Microsoft.AspNetCore.DeveloperCertificates.XPlat.csproj | 1 + src/Tools/dotnet-dev-certs/src/dotnet-dev-certs.csproj | 2 -- src/Tools/dotnet-sql-cache/src/dotnet-sql-cache.csproj | 2 -- src/Tools/dotnet-user-secrets/src/dotnet-user-secrets.csproj | 2 -- src/Tools/dotnet-watch/src/dotnet-watch.csproj | 2 -- 5 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/Tools/FirstRunCertGenerator/src/Microsoft.AspNetCore.DeveloperCertificates.XPlat.csproj b/src/Tools/FirstRunCertGenerator/src/Microsoft.AspNetCore.DeveloperCertificates.XPlat.csproj index 3d7ce08b7263..e0500429ab43 100644 --- a/src/Tools/FirstRunCertGenerator/src/Microsoft.AspNetCore.DeveloperCertificates.XPlat.csproj +++ b/src/Tools/FirstRunCertGenerator/src/Microsoft.AspNetCore.DeveloperCertificates.XPlat.csproj @@ -9,6 +9,7 @@ false false + false diff --git a/src/Tools/dotnet-dev-certs/src/dotnet-dev-certs.csproj b/src/Tools/dotnet-dev-certs/src/dotnet-dev-certs.csproj index 1b143b69b736..a7903fc79c72 100644 --- a/src/Tools/dotnet-dev-certs/src/dotnet-dev-certs.csproj +++ b/src/Tools/dotnet-dev-certs/src/dotnet-dev-certs.csproj @@ -9,8 +9,6 @@ true false - - true diff --git a/src/Tools/dotnet-sql-cache/src/dotnet-sql-cache.csproj b/src/Tools/dotnet-sql-cache/src/dotnet-sql-cache.csproj index 0e080f191de9..b40f89eece2c 100644 --- a/src/Tools/dotnet-sql-cache/src/dotnet-sql-cache.csproj +++ b/src/Tools/dotnet-sql-cache/src/dotnet-sql-cache.csproj @@ -7,8 +7,6 @@ cache;distributedcache;sqlserver true true - - true diff --git a/src/Tools/dotnet-user-secrets/src/dotnet-user-secrets.csproj b/src/Tools/dotnet-user-secrets/src/dotnet-user-secrets.csproj index 3b444be84ce0..f9e7f56f0baa 100644 --- a/src/Tools/dotnet-user-secrets/src/dotnet-user-secrets.csproj +++ b/src/Tools/dotnet-user-secrets/src/dotnet-user-secrets.csproj @@ -10,8 +10,6 @@ true false - - true diff --git a/src/Tools/dotnet-watch/src/dotnet-watch.csproj b/src/Tools/dotnet-watch/src/dotnet-watch.csproj index c124bcb00dc1..b289e142877f 100644 --- a/src/Tools/dotnet-watch/src/dotnet-watch.csproj +++ b/src/Tools/dotnet-watch/src/dotnet-watch.csproj @@ -9,8 +9,6 @@ true false - - true From c2f9ac7eeffd4bd8e86355a431503255935acfb3 Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 5 Jul 2019 20:28:13 -0700 Subject: [PATCH 8/9] Update .azure/pipelines/ci.yml Co-Authored-By: Doug Bunting <6431421+dougbu@users.noreply.github.com> --- .azure/pipelines/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.azure/pipelines/ci.yml b/.azure/pipelines/ci.yml index 80935a2a4273..caa6557d494c 100644 --- a/.azure/pipelines/ci.yml +++ b/.azure/pipelines/ci.yml @@ -512,7 +512,9 @@ jobs: parallel: true - task: PublishBuildArtifacts@1 displayName: Upload package artifacts - condition: always() + # Only capture source build artifacts in PRs for the sake of inspecting + # changes that impact source-build. The artifacts from this build pipeline are never actually used. + condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest')) inputs: pathtoPublish: artifacts/packages/ artifactName: Source_Build_Packages From e59f1f9a9613e5e91679c4c351fc36066fb72574 Mon Sep 17 00:00:00 2001 From: = Date: Fri, 5 Jul 2019 20:52:42 -0700 Subject: [PATCH 9/9] Feedback --- src/Framework/ref/Microsoft.AspNetCore.App.Ref.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Framework/ref/Microsoft.AspNetCore.App.Ref.csproj b/src/Framework/ref/Microsoft.AspNetCore.App.Ref.csproj index 1510cb6fb059..44e668d45281 100644 --- a/src/Framework/ref/Microsoft.AspNetCore.App.Ref.csproj +++ b/src/Framework/ref/Microsoft.AspNetCore.App.Ref.csproj @@ -66,8 +66,8 @@ This package is an internal implementation of the .NET Core SDK and is not meant - - + + $(BuildDependsOn); GeneratePackageConflictManifest; _ResolveTargetingPackContent;