Skip to content

Commit e29b13d

Browse files
committed
Update new-repo.md with current onboarding guidance
1 parent fa1a35b commit e29b13d

File tree

4 files changed

+60
-120
lines changed

4 files changed

+60
-120
lines changed

CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Users referenced in this file will automatically be requested as reviewers for PRs that modify the given paths.
22
# See https://help.github.com/articles/about-code-owners/
33

4-
* @MichaelSimons @mthalman
4+
* @dotnet/source-build

Documentation/sourcebuild-in-repos/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ with and participate in source-build.
99
* [Updating dependencies](update-dependencies.md)
1010
* [Considerations when adding features](adding-features.md)
1111
* [General notes on the source-build build](build-info.md)
12-
* [Adding new repositories](new-repo.md)
12+
* [Onboarding repositories to source build](new-repo.md)

Documentation/sourcebuild-in-repos/build-info.md

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,26 @@ produces multiple versions and these can be hard-coded or use a
3636
`$(<PackageName>ReferenceVersion)` property or similar if you don't need
3737
source-build to change them.
3838

39-
## Platform-specific packages
40-
41-
Packages that require components or packages only available on some other
42-
operating system than the building OS cannot be built in source-build. These
43-
should use `<ExcludeFromSourceBuild>true</ExcludeFromSourceBuild>` or other
44-
options to be excluded from the source-build. For instance, if a project
45-
depends on a package that can only be built on Windows, it will need to be
46-
disabled or worked around in source-build. As an example, [Roslyn
47-
removes](https://github.com/dotnet/roslyn/blob/b999a65c8b0feeccb2b58da3d7a6e80e5f08feab/src/Workspaces/Core/Portable/Storage/PersistentStorageExtensions.cs#L23)
48-
a small performance improvement when building for source-build because it
49-
requires a component that isn't available.
39+
## Platform-specific components
40+
41+
It is not always necessary or correct to include all repo components in source build.
42+
**Important philosophy: The Microsoft build and source build should be as close to the same as possible.**
43+
Components should be excluded based on platform requirements rather than source-build specific reasons.
44+
To exclude components, use the [VMR Controls](https://github.com/dotnet/dotnet/blob/main/docs/VMR-Controls.md) properties.
45+
46+
Common patterns include:
47+
48+
```xml
49+
<!-- Exclude Windows-only components on non-Windows platforms -->
50+
<ItemGroup Condition="'$(TargetOS)' == 'windows'">
51+
<ProjectReference Include="WindowsSpecific.csproj" />
52+
</ItemGroup>
53+
54+
<!-- Exclude components from source-only builds when truly necessary -->
55+
<ItemGroup Condition="'$(DotNetBuildSourceOnly)' != 'true'">
56+
<ProjectReference Include="MicrosoftProprietary.csproj" />
57+
</ItemGroup>
58+
```
59+
60+
**Avoid using `DotNetBuildSourceOnly` conditions unless absolutely necessary.**
61+
**Prefer platform-based conditions** (like `TargetOS`) **to maintain alignment between Microsoft and source builds.**
Lines changed: 35 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,34 @@
1-
# Adding a new repository to source build
1+
# Onboarding a repository to source build
22

3-
This document describes the overall process of onboarding new repos onto source
4-
build.
5-
6-
1. [Source Build Configuration](#source-build-configuration)
7-
1. [Setup CI](#setup-ci)
8-
1. [Source build repos and the VMR](#source-build-repos-and-the-vmr)
9-
1. [Validate](#validate)
3+
This document describes the overall process of onboarding repos onto source build.
104

115
## Source Build Configuration
126

137
### Trying it out locally
148

15-
If a repo passes build options through to the common arcade build script, a
16-
source build can be triggered via the following command.
9+
If a repo passes build options through to the common arcade build script, a source build can be triggered via the following command.
1710

1811
```bash
1912
./build.sh -sb
2013
```
2114

22-
> Note: [source build is not supported on
23-
Windows](https://github.com/dotnet/source-build/issues/1190), only Linux and
24-
macOS.
25-
26-
### Excluding components
15+
> Note: [source build is only supported on linux](https://github.com/dotnet/source-build/?tab=readme-ov-file#support).
2716
28-
It is not always necessary or correct to include all repo components in source
29-
build. Components should be excluded if they are not required for the platform
30-
being source-built. Including them expands the source build graph and may not
31-
be possible because of licensing. Examples include tests, Windows components
32-
(remember source build currently only supports Linux and macOS), etc. To exlcude
33-
these components use the `DotNetBuildSourceOnly` msbuild property to
34-
conditionally exclude.
17+
### Excluding platform-specific components
3518

36-
```code
37-
Condition="'$(DotNetBuildSourceOnly)' != 'true'"
38-
```
39-
40-
See the [Unified Build Controls](https://github.com/dotnet/dotnet/blob/main/docs/VMR-Controls.md)
41-
for more options on how to exclude components from source build.
19+
See the [platform-specific components guidelines](./build-info.md#platform-specific-components) for guidance on excluding components based on platform requirements rather than source-build specific reasons.
4220

4321
## Setup CI
4422

45-
Source build should run in PR validation builds, to prevent regressions.
23+
**Repository-level source build CI legs are optional.**
24+
Consider adding them only if your repository has many source-build specific conditions or complex source-build scenarios.
25+
If you have a lot of source-build specific conditions, this is when you should consider adding repo-level CI legs.
4626

47-
Source build CI can be activated with a single flag in the ordinary Arcade SDK
48-
jobs template for easy consumption. If a repo can't simply use the Arcade SDK
49-
jobs template, more granular templates are also available.
27+
Source build CI can be activated with a single flag in the ordinary Arcade SDK jobs template for easy consumption.
28+
If a repo can't simply use the Arcade SDK jobs template, more granular templates are also available.
5029

51-
See <https://github.com/dotnet/arcade/tree/main/eng/common/templates> for the
52-
current template source code. The inline comments in the `parameters:` section
53-
in those files are the most up to date docs, maintained with higher priority
54-
than this general onboarding doc.
30+
See <https://github.com/dotnet/arcade/tree/main/eng/common/templates> for the current template source code.
31+
The inline comments in the `parameters:` section in those files are the most up to date docs, maintained with higher priority than this general onboarding doc.
5532

5633
### `eng/common/templates/jobs/jobs.yml` opt-in switch
5734

@@ -60,46 +37,27 @@ The simplest way to onboard. This approach applies if the repo already uses the
6037

6138
To opt in:
6239

63-
1. Set `enableSourceBuild: true`
64-
65-
Set `enableSourceBuild: true` in the template parameters.
66-
67-
This should look something like [this sourcelink
68-
implementation:](https://github.com/dotnet/sourcelink/blob/dfe619dc722be42d475595c755c958afe6177554/azure-pipelines.yml#L40)
69-
70-
```yaml
71-
stages:
72-
- stage: build
73-
displayName: Build
74-
jobs:
75-
- template: /eng/common/templates/jobs/jobs.yml
76-
parameters:
77-
enablePublishUsingPipelines: true
78-
enablePublishBuildArtifacts: true
79-
enablePublishBuildAssets: true
80-
enableSourceBuild: true
81-
artifacts:
82-
publish:
83-
artifacts: true
84-
manifests: true
85-
```
86-
87-
1. Specify platforms (if repo is not managed-only)
88-
89-
A repo is managed-only if `eng/SourceBuild.props` contains
90-
`<SourceBuildManagedOnly>true</SourceBuildManagedOnly>`. If this is true,
91-
this step is not necessary. Otherwise, specify `sourceBuildParameters` in
92-
the `jobs.yml` template's parameters like this:
93-
94-
```yaml
95-
sourceBuildParameters:
96-
platforms:
97-
- name: 'CentosStream8_Portable'
98-
container: 'mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream8'
99-
- name: 'CentosStream8'
100-
nonPortable: true
101-
container: 'mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream8'
102-
```
40+
Set `enableSourceBuild: true` in the template parameters.
41+
42+
This should look something like [this sourcelink
43+
implementation:](https://github.com/dotnet/sourcelink/blob/dfe619dc722be42d475595c755c958afe6177554/azure-pipelines.yml#L40)
44+
45+
```yaml
46+
stages:
47+
- stage: build
48+
displayName: Build
49+
jobs:
50+
- template: /eng/common/templates/jobs/jobs.yml
51+
parameters:
52+
enablePublishUsingPipelines: true
53+
enablePublishBuildArtifacts: true
54+
enablePublishBuildAssets: true
55+
enableSourceBuild: true
56+
artifacts:
57+
publish:
58+
artifacts: true
59+
manifests: true
60+
```
10361
10462
#### End result
10563
@@ -153,34 +111,4 @@ this just happens to fit in nicely.
153111

154112
## Source build repos and the VMR
155113

156-
Another effect of adding a new source build repository is that its sources will
157-
be synchronized into the [Virtual Monolithic Repository of
158-
.NET](https://github.com/dotnet/dotnet). The VMR is then where the official
159-
source build happens from.
160-
161-
In order for the sources of the new repo to by synchronized into the VMR, the
162-
repo needs to be registered in the [`source-mappings.json`
163-
file](https://github.com/dotnet/dotnet/blob/main/src/source-mappings.json) which
164-
tells the tooling where from and which sources should be synchronized. Please
165-
open a PR in [`dotnet/dotnet`](https://github.com/dotnet/dotnet) and add
166-
your repository into `src/source-mappings.json`.
167-
168-
### Cloaking (filtering) the repository sources
169-
170-
When creating the `source-mappings.json` record for the new repo, there is a
171-
possibility of filtering which sources get synchronized into the VMR. The VMR
172-
should only really contain plain text-based files as it is consumed by 3rd party
173-
.NET distro builders who do not accept any non-text sources (e.g. binaries).
174-
When registering the repository into the VMR, it is a good time to consider
175-
which files are required for it to build and only synchronize those. Commonly,
176-
repositories contain binaries that are required for testing or similar purposes.
177-
Files like these should not be synchronized into the VMR. Another common
178-
scenario is that the repo has multiple products/ship vehicles and only a subset
179-
is needed for the source-built .NET scenario.
180-
181-
## Validate
182-
183-
Once the code flows to the VMR, the PR validation legs will ensure that no
184-
[prebuilts](https://github.com/dotnet/source-build/blob/main/Documentation/eliminating-pre-builts.md#what-is-a-prebuilt)
185-
were added to the system and everything is functioning correctly.
186-
If you need help on addressing any prebuilds, reach out to @source-build.
114+
In order to fully onboard a repo into source build, the repo must be included within the VMR. The [Repository Onboarding Guide](https://github.com/dotnet/dotnet/blob/main/docs/Repository-Onboarding.md) contains the comprehensive VMR onboarding guidance which includes among several other topics, resolving source build prebuilts.

0 commit comments

Comments
 (0)