diff --git a/.azure/pipelines/ci.yml b/.azure/pipelines/ci.yml
index d6a660b48bb2..caa6557d494c 100644
--- a/.azure/pipelines/ci.yml
+++ b/.azure/pipelines/ci.yml
@@ -471,3 +471,52 @@ 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
+ # 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
+ 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/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)" />
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
@@ -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/ref/Microsoft.AspNetCore.App.Ref.csproj b/src/Framework/ref/Microsoft.AspNetCore.App.Ref.csproj
index 2a73d0fb44fa..44e668d45281 100644
--- a/src/Framework/ref/Microsoft.AspNetCore.App.Ref.csproj
+++ b/src/Framework/ref/Microsoft.AspNetCore.App.Ref.csproj
@@ -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/Framework/src/Microsoft.AspNetCore.App.Runtime.csproj b/src/Framework/src/Microsoft.AspNetCore.App.Runtime.csproj
index 7bc95d9fe5ef..d483371a187a 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.
@@ -361,8 +363,8 @@ This package is an internal implementation of the .NET Core SDK and is not meant
Targets related to creating .zip/.tar.gz
#########################################
-->
-
-
+
@@ -412,7 +414,9 @@ This package is an internal implementation of the .NET Core SDK and is not meant
-
+
@@ -437,7 +441,9 @@ This package is an internal implementation of the .NET Core SDK and is not meant
Condition="'$(ArchiveExtension)' == '.tar.gz'" />
-
+
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 @@
-
+
+
-
+
+
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-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 @@
-
+
+
-
+
+