|
| 1 | +# Local onboarding |
| 2 | + |
| 3 | +Local onboarding involves setting up files in `eng/` that determine the behavior |
| 4 | +of source-build in the repo. |
| 5 | + |
| 6 | + |
| 7 | +## Source-build configuration overview |
| 8 | + |
| 9 | +### `eng/SourceBuild.props` |
| 10 | + |
| 11 | +```xml |
| 12 | +<Project> |
| 13 | + |
| 14 | + <PropertyGroup> |
| 15 | + <GitHubRepositoryName>this-repo</GitHubRepositoryName> |
| 16 | + <SourceBuildManagedOnly>true</SourceBuildManagedOnly> |
| 17 | + </PropertyGroup> |
| 18 | + |
| 19 | +</Project> |
| 20 | +``` |
| 21 | + |
| 22 | +This file contains basic configuration used to restore the correct dependencies |
| 23 | +(managed-only or not) and produce the right name for the repo's [intermediate |
| 24 | +nupkg]. |
| 25 | + |
| 26 | +* `this-repo` should be the same as the repo's name on GitHub, without the |
| 27 | + GitHub organization name. |
| 28 | +* `SourceBuildManagedOnly` defaults to false if omitted. `true` means that the |
| 29 | + repo doesn't produce any RID-specific artifacts like |
| 30 | + `Microsoft.NETCore.App.Runtime.linux-x64`, only managed code. |
| 31 | + |
| 32 | +These two properties determine the name of the [intermediate nupkg]: |
| 33 | +`Microsoft.SourceBuild.Intermediate.$(GitHubRepositoryName)[.$(RidSuffix)]`. |
| 34 | + |
| 35 | +It's possible more configuration will be required for specific repos. |
| 36 | +`eng/SourceBuild.props`, similar to `eng/Build.props`, is a place to add extra |
| 37 | +MSBuild code that can change the way source-build behaves. |
| 38 | + |
| 39 | +### `eng/SourceBuildPrebuiltBaseline.xml` |
| 40 | + |
| 41 | +```xml |
| 42 | +<UsageData> |
| 43 | + <IgnorePatterns> |
| 44 | + <UsagePattern IdentityGlob="*/*" /> |
| 45 | + </IgnorePatterns> |
| 46 | +</UsageData> |
| 47 | +``` |
| 48 | + |
| 49 | +This defines which prebuilt NuGet packages are allowed to be used during the |
| 50 | +build. Initially, all package IDs and versions are permitted (`*/*`). |
| 51 | + |
| 52 | +The `*/*` glob means "any nupkg id, any version". It will be replaced with more |
| 53 | +specific rules at a later phase of the implementation plan. The goal is to make |
| 54 | +it specific, so when a PR introduces an unexpected prebuilt, PR validation will |
| 55 | +fail and let us resolve the source-buildability issue before the PR gets merged. |
| 56 | + |
| 57 | +### `eng/Version.Details.xml` |
| 58 | + |
| 59 | +```xml |
| 60 | +... |
| 61 | + <Dependency Name="Microsoft.NETCore.App.Runtime.win-x64" Version="6.0.0-alpha.1.20468.7" CoherentParentDependency="Microsoft.NET.Sdk"> |
| 62 | + <Uri>https://github.com/dotnet/runtime</Uri> |
| 63 | + <Sha>a820ca1c4f9cb5892331e2624d3999c39161fe2a</Sha> |
| 64 | + <SourceBuild RepoName="runtime" /> |
| 65 | + </Dependency> |
| 66 | +... |
| 67 | + <Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="5.0.0-alpha.1.20473.1"> |
| 68 | + <Uri>https://github.com/dotnet/source-build-reference-packages</Uri> |
| 69 | + <Sha>def2e2c6dc5064319250e2868a041a3dc07f9579</Sha> |
| 70 | + <SourceBuild RepoName="source-build-reference-packages" ManagedOnly="true" /> |
| 71 | + </Dependency> |
| 72 | +... |
| 73 | +``` |
| 74 | + |
| 75 | +Dependency changes may include adding `SourceBuild` to existing dependency |
| 76 | +elements, and adding a new `source-build-reference-packages` element. |
| 77 | + |
| 78 | +`SourceBuild` causes the source-build targets in the Arcade SDK to download |
| 79 | +[intermediate nupkg]s from the upstream repo's official build, rather than using |
| 80 | +prebuilt binaries to fulfill the dependencies. Note that `RepoName` is used to |
| 81 | +calculate the ID of the [intermediate nupkg]: the `Dependency` `Name` is |
| 82 | +ignored by source-build. |
| 83 | + |
| 84 | +`ManagedOnly` determines whether a RID suffix is necessary on the [intermediate |
| 85 | +nupkg] ID. For example, running source-build on `dotnet/installer` with |
| 86 | +`linux-x64` with the above example configuration will restore: |
| 87 | + |
| 88 | +* `Microsoft.SourceBuild.Intermediate.runtime.linux-x64` |
| 89 | + * `.linux-x64` because `ManagedOnly` is not `true`. |
| 90 | +* `Microsoft.SourceBuild.Intermediate.source-build-reference-packages` |
| 91 | + * Ends with the `RepoName` without a suffix because `ManagedOnly="true"`. |
| 92 | + |
| 93 | + |
| 94 | +# Trying it out locally |
| 95 | + |
| 96 | +Running source-build locally is done by passing `/p:ArcadeBuildFromSource=true` |
| 97 | +at the end of the usual arcade-based build command for the repo. For example: |
| 98 | + |
| 99 | +``` |
| 100 | +./build.sh -c Release --restore --build --pack /p:ArcadeBuildFromSource=true |
| 101 | +``` |
| 102 | + |
| 103 | +> Note: [source-build is not supported on |
| 104 | +> Windows](https://github.com/dotnet/source-build/issues/1190), only Linux and |
| 105 | +> macOS. |
| 106 | +
|
| 107 | +After running the build, source-build artifacts will be in |
| 108 | +`artifacts/source-build`, and the [intermediate nupkg] will be something like |
| 109 | +`artifacts/packages/*/Microsoft.SourceBuild.Intermediate.*.nupkg`. |
| 110 | + |
| 111 | +It isn't strictly necessary to try it out locally to proceed with CI onboarding. |
| 112 | +The source-build contributor who submits the initial configuration PR to the |
| 113 | +repo will have tested out the build locally themselves. |
| 114 | + |
| 115 | + |
| 116 | +[intermediate nupkg]: https://github.com/dotnet/source-build/blob/release/3.1/Documentation/planning/arcade-powered-source-build/intermediate-nupkg.md |
0 commit comments