Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the Arcade-powered source-build wrapper. #4105

Merged
merged 19 commits into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
12 changes: 6 additions & 6 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ DOTNET="$(pwd)/cli/dotnet"
$DOTNET --info

# Get CLI Branches for testing
echo "dotnet msbuild build/config.props /v:m /nologo /t:GetCliBranchForTesting"
echo "$DOTNET msbuild build/config.props /v:m /nologo /t:GetCliBranchForTesting"
zivkan marked this conversation as resolved.
Show resolved Hide resolved

IFS=$'\n'
CMD_OUT_LINES=(`dotnet msbuild build/config.props /v:m /nologo /t:GetCliBranchForTesting`)
CMD_OUT_LINES=(`$DOTNET msbuild build/config.props /v:m /nologo /t:GetCliBranchForTesting`)
# Take only last the line which has the version information and strip all the spaces
DOTNET_BRANCHES=${CMD_OUT_LINES[-1]//[[:space:]]}
unset IFS
Expand Down Expand Up @@ -94,17 +94,17 @@ then
fi

# restore packages
echo "dotnet msbuild build/build.proj /t:Restore /p:VisualStudioVersion=16.0 /p:Configuration=Release /p:BuildNumber=1 /p:ReleaseLabel=beta"
dotnet msbuild build/build.proj /t:Restore /p:VisualStudioVersion=16.0 /p:Configuration=Release /p:BuildNumber=1 /p:ReleaseLabel=beta
echo "$DOTNET msbuild build/build.proj /t:Restore /p:VisualStudioVersion=16.0 /p:Configuration=Release /p:BuildNumber=1 /p:ReleaseLabel=beta"
$DOTNET msbuild build/build.proj /t:Restore /p:VisualStudioVersion=16.0 /p:Configuration=Release /p:BuildNumber=1 /p:ReleaseLabel=beta

if [ $? -ne 0 ]; then
echo "Restore failed!!"
exit 1
fi

# run tests
echo "dotnet msbuild build/build.proj /t:CoreUnitTests /p:VisualStudioVersion=16.0 /p:Configuration=Release /p:BuildNumber=1 /p:ReleaseLabel=beta"
dotnet msbuild build/build.proj /t:CoreUnitTests /p:VisualStudioVersion=16.0 /p:Configuration=Release /p:BuildNumber=1 /p:ReleaseLabel=beta
echo "$DOTNET msbuild build/build.proj /t:CoreUnitTests /p:VisualStudioVersion=16.0 /p:Configuration=Release /p:BuildNumber=1 /p:ReleaseLabel=beta"
$DOTNET msbuild build/build.proj /t:CoreUnitTests /p:VisualStudioVersion=16.0 /p:Configuration=Release /p:BuildNumber=1 /p:ReleaseLabel=beta

if [ $? -ne 0 ]; then
echo "Tests failed!!"
Expand Down
10 changes: 10 additions & 0 deletions eng/SourceBuild.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project>

<PropertyGroup>
<GitHubRepositoryName>nuget-client</GitHubRepositoryName>
<SourceBuildManagedOnly>true</SourceBuildManagedOnly>

<VersionPrefix>1.0.0</VersionPrefix>
</PropertyGroup>

</Project>
5 changes: 5 additions & 0 deletions eng/SourceBuildPrebuiltBaseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<UsageData>
<IgnorePatterns>
<UsagePattern IdentityGlob="*/*" />
</IgnorePatterns>
</UsageData>
27 changes: 27 additions & 0 deletions eng/pipelines/templates/Source_Build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
steps:
- task: PowerShell@2
displayName: "Update Build Number"
inputs:
targetType: "inline"
script: |
Write-Host "##vso[build.updatebuildnumber]$env:FULLVSTSBUILDNUMBER"
failOnStderr: "true"
condition: "always()"

- task: PowerShell@2
displayName: "Build source-build"
inputs:
targetType: "inline"
script: |
./eng/source-build/build.sh
condition: "always()"

- task: PublishBuildArtifacts@1
displayName: Upload source-build log
condition: "always()"
continueOnError: true
inputs:
PathToPublish: "artifacts/source-build/self/log/source-build.binlog"
ArtifactName: "Source-build log"
ArtifactType: Container

15 changes: 15 additions & 0 deletions eng/pipelines/templates/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,18 @@ jobs:

steps:
- template: Apex_Tests_On_Windows.yml

- job: Source_Build
dependsOn:
- Initialize_Build
timeoutInMinutes: 120
variables:
BuildNumber: $[dependencies.Initialize_Build.outputs['updatebuildnumber.BuildNumber']]
FullVstsBuildNumber: $[dependencies.Initialize_Build.outputs['updatebuildnumber.FullVstsBuildNumber']]
SDKVersionForBuild: $[dependencies.Initialize_Build.outputs['getSDKVersionForBuild.SDKVersionForBuild']]
BuildRTM: "false"
pool:
vmImage: ubuntu-latest
demands: sh
steps:
- template: Source_Build.yml
47 changes: 47 additions & 0 deletions eng/source-build/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash

source="${BASH_SOURCE[0]}"
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"

# resolve $SOURCE until the file is no longer a symlink
while [[ -h $source ]]; do
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
source="$(readlink "$source")"

# if $source was a relative symlink, we need to resolve it relative to the path where the
# symlink file was located
[[ $source != /* ]] && source="$scriptroot/$source"
done

function ReadGlobalVersion {
local key=$1
local global_json_file="$scriptroot/global.json"

if command -v jq &> /dev/null; then
_ReadGlobalVersion="$(jq -r ".[] | select(has(\"$key\")) | .\"$key\"" "$global_json_file")"
elif [[ "$(cat "$global_json_file")" =~ \"$key\"[[:space:]\:]*\"([^\"]+) ]]; then
_ReadGlobalVersion=${BASH_REMATCH[1]}
fi

if [[ -z "$_ReadGlobalVersion" ]]; then
Write-PipelineTelemetryError -category 'Build' "Error: Cannot find \"$key\" in $global_json_file"
ExitWithExitCode 1
fi
}

function GetNuGetPackageCachePath {
if [[ -z ${NUGET_PACKAGES:-} ]]; then
if [[ "$use_global_nuget_cache" == true ]]; then
export NUGET_PACKAGES="$HOME/.nuget/packages"
else
export NUGET_PACKAGES="$repo_root/.packages"
export RESTORENOCACHE=true
fi
fi
}

export DOTNET=${DOTNET:-dotnet}

ReadGlobalVersion Microsoft.DotNet.Arcade.Sdk
export ARCADE_VERSION=$_ReadGlobalVersion
"$DOTNET" msbuild "$scriptroot/source-build.proj" /p:DotNetBuildFromSource=true /p:ArcadeBuildFromSource=true "/p:RepoRoot=$scriptroot/../../" "/bl:$scriptroot/../../artifacts/source-build/self/log/source-build.binlog"
5 changes: 5 additions & 0 deletions eng/source-build/global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "6.0.0-beta.21309.7"
}
}
52 changes: 52 additions & 0 deletions eng/source-build/source-build.proj
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<Project Sdk="Microsoft.DotNet.Arcade.Sdk" DefaultTargets="Build">

<Import Project="../SourceBuild.props" />

<PropertyGroup>
<ProjectRoot>$(MSBuildThisFileDirectory)../../</ProjectRoot>
</PropertyGroup>

<Target Name="Build" DependsOnTargets="SourceBuildPostBuild">
<Message Text="Running source-build Build target" Importance="High" />
</Target>

<Target Name="SourceBuildPreBuild">
crummel marked this conversation as resolved.
Show resolved Hide resolved
<Message Text="Running source-build PreBuild target" Importance="High" />

</Target>

<Target Name="SourceBuildPostBuild" DependsOnTargets="SourceBuildInnerBuild">
<Message Text="Running source-build PostBuild target" Importance="High" />

<MSbuild Projects="$(NuGetPackageRoot)/microsoft.dotnet.arcade.sdk/$(ARCADE_VERSION)/tools/Build.proj"
Properties="_NETCORE_ENGINEERING_TELEMETRY=AfterSourceBuild;ArcadeBuildFromSource=true;Restore=true;Build=false;Pack=false;Publish=false;Rebuild=false;Test=false;IntegrationTest=false;PerformanceTest=false;PreventPrebuiltBuild=false;BaseInnerSourceBuildCommand=echo skipping internal build with args: "
Targets="Execute"
/>

<Message Text="Finished restoring Arcade" Importance="High" />

<MSbuild Projects="$(NuGetPackageRoot)/microsoft.dotnet.arcade.sdk/$(ARCADE_VERSION)/tools/SourceBuild/AfterSourceBuild.proj"
Properties="_NETCORE_ENGINEERING_TELEMETRY=AfterSourceBuild;ArcadeBuildFromSource=true;CurrentRepoSourceBuildArtifactsPackagesDir=$(ProjectRoot)artifacts/nupkgs/"
/>

</Target>

<Target Name="SourceBuildInnerBuild" DependsOnTargets="SourceBuildPreBuild">
<Message Text="Running source-build InnerBuild target" Importance="High" />

<MSBuild Projects="$(ProjectRoot)build/build.proj"
Properties="Configuration=$(BuildConfiguration);DotNetBuildFromSource=true"
Targets="RestoreXPlat" />

<MSBuild Projects="$(ProjectRoot)build/build.proj"
Properties="Configuration=$(BuildConfiguration);DotNetBuildFromSource=true"
Targets="BuildXPlat" />

<MSBuild Projects="$(ProjectRoot)build/build.proj"
Properties="Configuration=$(BuildConfiguration);DotNetBuildFromSource=true"
Targets="PackXPlat" />

</Target>

</Project>

9 changes: 9 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
crummel marked this conversation as resolved.
Show resolved Hide resolved
// This empty file has no effect and is here to support Arcade-powered source-build.
// The Arcade build process requires a global.json at the root of the repo and normally
// uses it to restore the necessary SDK and tools to build the repo.
// However, NuGet explitcly wants to use the ambient SDK (normally latest), not any particular
// version. We also don't want to introduce MS.DN.Arcade.SDK into the non-source-build build.
// eng/source-build/global.json has the entry for the Arcade version we need for
// Arcade-powered source-build.
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,5 @@
</ItemGroup>
<Import Project="$(BuildCommonDirectory)common.targets" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != '' and '$(DotNetBuildFromSource)' != 'true'" />
</Project>
2 changes: 1 addition & 1 deletion src/NuGet.Clients/NuGet.Tools/NuGet.Tools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,5 @@
</ItemGroup>
<Import Project="$(BuildCommonDirectory)common.targets" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != '' and '$(DotNetBuildFromSource)' != 'true'" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,5 @@
</ItemGroup>
<Import Project="$(BuildCommonDirectory)common.targets" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != '' and '$(DotNetBuildFromSource)' != 'true'" />
</Project>