Skip to content

Support OfficialBuildId for SB #48327

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

Merged
merged 22 commits into from
Apr 18, 2025
Merged

Conversation

mthalman
Copy link
Member

@mthalman mthalman commented Apr 9, 2025

Fixes dotnet/source-build#4912

This enables SB support for the OfficialBuildId property. This gets enabled by setting the EnableDevBuildAsDefaultForSourceOnly property. When that is enabled, SB will use the OfficialBuildId rather than the build numbers from the git-info files. This also allows for dev builds to be supported.

For dev builds, it was necessary to change the pre-release label defined by Arcade to use a different value. This is due to the semantic versioning rules that select the highest version as the last label value in alphabetical sorting. This is problematic when we have pre-release labels like "preview" which end up being selected as the latest version over a version that has the label of "dev" since "preview" comes after "dev" alphabetically. This means that preview packages will be resolved instead of the live dev package when resolving package dependencies. For that reason, a prefix value of "test" was chosen which comes alphabetically after all the other pre-release labels that are used.

The majority of these changes are related to the issue of testing. For the SB tests and scenario tests, we need to be able to resolve the package version of the OfficialBuildId that was provided. But some of those packages aren't produced by source build. For example, some of the self-contained publishing tests rely on packages for the portable linux-<arch> RID which is not produced by source build. For that reason, we require the packages that are produced by other unified build legs. So to test the SB output with OfficialBuildId support, we actually need to integrate a SB leg into the UB pipeline. A separate validation leg is then added that depends on the artifacts from the SB leg as well as other UB legs that provide the necessary packages required by the tests.

Another factor is building the scenario tests. This required modification because it was dependent on building the entire VMR. So that's been decoupled here for SB to allow building and running the scenario tests in a separate job without rebuilding the rest of the VMR.

Also related to the scenario tests is the need to remove the Versions.Details dependency on System.CommandLine. This was necessary because leaving it in would require SB to attempt to use the "live" version of that package which wouldn't exist in this context since it's been decoupled from the rest of the VMR.

@Copilot Copilot AI review requested due to automatic review settings April 9, 2025 22:50
@mthalman mthalman requested review from a team as code owners April 9, 2025 22:50
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Infrastructure untriaged Request triage from a team member labels Apr 9, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 5 out of 15 changed files in this pull request and generated no comments.

Files not reviewed (10)
  • src/Layout/Directory.Build.props: Language not supported
  • src/Layout/redist/targets/RestoreLayout.targets: Language not supported
  • src/SourceBuild/content/repo-projects/Directory.Build.props: Language not supported
  • src/SourceBuild/content/repo-projects/Directory.Build.targets: Language not supported
  • src/SourceBuild/content/repo-projects/scenario-tests.proj: Language not supported
  • src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.Tests/Microsoft.DotNet.SourceBuild.Tests.csproj: Language not supported
  • src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.Tests/assets/default.NuGet.Config: Language not supported
  • src/SourceBuild/content/test/tests.proj: Language not supported
  • src/SourceBuild/patches/arcade/0001-Use-test-prefix-on-unofficial-build-prerelease-label.patch: Language not supported
  • src/SourceBuild/patches/scenario-tests/0001-Remove-System.CommandLine-as-dependency.patch: Language not supported
Comments suppressed due to low confidence (3)

src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.Tests/DotNetHelper.cs:52

  • Verify that the updated ternary logic correctly differentiates between custom package path modes. In particular, ensure that when CustomPackagesPathIsInclusive is true, the 'default' configuration is intended.
string nugetConfigPrefix = useCustomPackages && !Config.CustomPackagesPathIsInclusive ? "custom" : "default";

eng/pipelines/templates/jobs/vmr-build.yml:168

  • Ensure that the conditional aggregation for 'dependsOn' correctly builds the dependency list in all scenarios; verify that an empty condition does not add spurious list items.
dependsOn:
    - ${{ if ne(parameters.reuseBuildArtifactsFrom, '') }}:
      - ${{ parameters.reuseBuildArtifactsFrom }}
    - ${{ if ne(parameters.dependsOn, '') }}:
      - ${{ parameters.dependsOn }}

eng/pipelines/templates/jobs/vmr-build.yml:565

  • Removing the trimming of buildArgs may lead to extra spaces affecting command-line parsing; confirm that buildArgs formatting remains valid after this change.
buildArgs=$(echo $buildArgs | xargs) # Remove extra spaces

@ViktorHofer
Copy link
Member

Love it. This is a great step towards unified versioning and build for source-build. The PR description is well written. I still have follow-up questions, though.

Another factor is building the scenario tests. This required modification because it was dependent on building the entire VMR. So that's been decoupled here for SB to allow building and running the scenario tests in a separate job without rebuilding the rest of the VMR.

That's definitely the right direction. We started decoupling scenario-tests from the VMR build when we moved it out of the Build target and into the Test target. I see this as the next logical step to truly build it independently. On that thought, can you remind me what the constraints for source-build are in terms of pre-builts for scenario-tests execution? Is the test execution constraint by internet access and must have no pre-builts? Does this change with this work?

EnableDevBuildAsDefaultForSourceOnly

I'm suprised to see this new switch. Is your intention to make this the default at a later point, past P4? If so, what will be the UX for source-build partners?

Copy link
Member

@ViktorHofer ViktorHofer Apr 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this file change

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with 269eba9

Comment on lines 107 to 108
<!-- TODO: Remove this import and the EnableDevBuildAsDefaultForSourceOnly when dev builds are the default for source only.
https://github.com/dotnet/source-build/issues/4922 -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the comment refers to an Import but below is a property group. The same is true for the change in L176

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with 2e4029b

@@ -198,7 +198,7 @@

<ItemGroup>
<_BuildSources Include="$(PrebuiltNuGetSourceName);$(PreviouslySourceBuiltNuGetSourceName);$(ReferencePackagesNuGetSourceName)"
Condition="'$(DotNetBuildSourceOnly)' == 'true'"/>
Condition="'$(DotNetBuildSourceOnly)' == 'true' and '$(DotNetSourceOnlyTestOnly)' != 'true'"/>
Copy link
Member

@ViktorHofer ViktorHofer Apr 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this benefit from a boolean indirection property that determines whether prebuilt feeds should be added? i.e.

<IncludePrebuiltFeeds Condition="'$(DotNetSourceOnlyTestOnly)' == 'true'">false</IncludePrebuiltFeeds>
<IncludePrebuiltFeeds Condition="'$(IncludePrebuiltFeeds)' == '' and '$(DotNetBuildSourceOnly)' == 'true'">true</IncludePrebuiltFeeds>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with 2eb97de

@@ -9,21 +9,19 @@

<!-- Don't use the updated NuGet.config file that includes the live package feeds when testing source-only as in that configuration
the Microsoft built packages should be used. -->
<TestArgs Condition="'$(DotNetBuildSourceOnly)' == 'true'">$(TestArgs) /p:TestRestoreConfigFile=$(OriginalNuGetConfigFile)</TestArgs>
<TestArgs Condition="'$(DotNetBuildSourceOnly)' == 'true' and '$(DotNetSourceOnlyTestOnly)' != 'true'">$(TestArgs) /p:TestRestoreConfigFile=$(OriginalNuGetConfigFile)</TestArgs>
<UseBootstrapArcade>true</UseBootstrapArcade>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's weird to have this un-conditionally set to true but then later for non-source-only builds, reference the arcade repo. Maybe add a condition?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with 483c975

@@ -8,5 +8,6 @@
<add key="darc-pub-dotnet-runtime-d398172" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-d3981726/nuget/v3/index.json" />
<add key="dotnet10" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet10/nuget/v3/index.json" />
<add key="dotnet10-transport" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet10-transport/nuget/v3/index.json" />
<add key="custom-packages" value="CUSTOM_PACKAGE_FEED" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you consider using the RestoreAdditionalProjectSources msbuild property to dynamically add additional nuget feeds? That would avoid rewriting this file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great suggestion. Fixed with 5a86952

<VersionSuffix Condition="'$(DotNetFinalVersionKind)' == 'release'"/>
- <VersionSuffix Condition="'$(DotNetFinalVersionKind)' == 'prerelease' and '$(SemanticVersioningV1)' != 'true'">$(_PreReleaseLabel).final</VersionSuffix>
- <VersionSuffix Condition="'$(DotNetFinalVersionKind)' == 'prerelease' and '$(SemanticVersioningV1)' == 'true'">$(_PreReleaseLabel)-final</VersionSuffix>
+ <VersionSuffix Condition="'$(DotNetFinalVersionKind)' == 'prerelease' and '$(SemanticVersioningV1)' != 'true'">$(_PreReleaseLabel)$(_SemVerLabelSeparator)final</VersionSuffix>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was the idea?

Suggested change
+ <VersionSuffix Condition="'$(DotNetFinalVersionKind)' == 'prerelease' and '$(SemanticVersioningV1)' != 'true'">$(_PreReleaseLabel)$(_SemVerLabelSeparator)final</VersionSuffix>
+ <VersionSuffix Condition="'$(DotNetFinalVersionKind)' == 'prerelease'">$(_PreReleaseLabel)$(_SemVerLabelSeparator)final</VersionSuffix>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with 392a5e6

@@ -21,6 +21,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="$(TasksDir)Microsoft.DotNet.UnifiedBuild.Tasks\Microsoft.DotNet.UnifiedBuild.Tasks.csproj" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the entire PR, this is the only change that I don't understand and which looks wrong to me. Why would we need to build a tasks assembly here in tests.proj?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mthalman can this be moved to test/Microsoft.DotNet.SourceBuild.Tests/Microsoft.DotNet.SourceBuild.Tests.csproj? We have the same ProjectReference in https://github.com/dotnet/sdk/blob/main/src/SourceBuild/content/test/Microsoft.DotNet.Tests/Microsoft.DotNet.Tests.csproj

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reference isn't necessary anymore. Removed with e87b02f

@@ -62,6 +62,9 @@
<RuntimeHostConfigurationOption Include="$(MSBuildProjectName).CustomPackagesPath">
<Value>$(SourceBuildTestsCustomSourceBuiltPackagesPath)</Value>
</RuntimeHostConfigurationOption>
<RuntimeHostConfigurationOption Include="$(MSBuildProjectName).CustomPackagesPathIsInclusive">
<Value>$(SourceBuildTestsCustomSourceBuiltPackagesPathIsInclusive)</Value>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a comment describing this property? I assume it means that the packages path contains everything needed for this test library?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This property has been removed as part of 5a86952

@mthalman
Copy link
Member Author

On that thought, can you remind me what the constraints for source-build are in terms of pre-builts for scenario-tests execution? Is the test execution constraint by internet access and must have no pre-builts? Does this change with this work?

There are no requirements that tests build without prebuilts. Internet access is allowed for running tests. The changes in this PR don't impact this.

EnableDevBuildAsDefaultForSourceOnly

I'm suprised to see this new switch. Is your intention to make this the default at a later point, past P4? If so, what will be the UX for source-build partners?

Yes, I should have explained that better. I also had a hard time naming it because it's not just specific to dev builds. It applies to official builds too when OfficialBuildId is set. It basically means that we use dev builds or OfficialBuildId instead of git-info. This is a temporary property until we have a fully combined pipeline that includes Microsoft and SB legs. So this property is only set in the new SB leg added to the UB pipeline. This allows the existing SB pipeline to work unchanged. The UX for SB partners at this point is unchanged. I'm open to changing the default behavior here if that's what we want to do (cc @MichaelSimons). We're just in a state of transition right now while we have separate pipelines.

@ViktorHofer
Copy link
Member

The UX for SB partners at this point is unchanged. I'm open to changing the default behavior here if that's what we want to do (cc @MichaelSimons). We're just in a state of transition right now while we have separate pipelines.

I like the intermediate step as it makes the PR smaller and scoped. My main question here was whether the transition will happen in time for P4 or P5.

@@ -995,3 +995,77 @@ stages:
- Windows_x64
- Windows_x86
- Windows_arm64

# Source Build Leg
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there value in embedding the SB leg and SB validation leg in new jobs template? The benefit is to ensure they both get done and help in ensuring parameter consistency between the two - e.g. containers, naming, etc. This would make it easier to add new SB legs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with b8206dd

@MichaelSimons
Copy link
Member

I like the intermediate step as it makes the PR smaller and scoped. My main question here was whether the transition will happen in time for P4 or P5.

I too like the thought of working incrementally. The original idea was to complete the necessary changes and validate SB was capable of the new OfficialBuildId mechanism in P3. This was held up by requiring some of the workflow changes. In P4 the goal is to move all legs while still supporting the ability to rollback to the gitinfo files if MSFT ends up not shipping P4 from the new UB infra. Moving all legs in P4 isn't strictly required but would be ideal IMO.

Copy link
Member

@ViktorHofer ViktorHofer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build parts LGTM. I didn't review the YML

- AzureLinux_x64_Cross_x64
- Browser_Shortstack_wasm
- Windows_x64
- ${{ format('{0}_SourceBuild_Online_MsftSdk_x64', parameters.buildNamePrefix) }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the x64 references in the validation parameter be updated to use ${{ parameters.targetArchitecture }}? This one particular reference jumps out as the preceding job's name is built with the targetArchitecture. I am alright with fixing this when other legs are onboarded so that they can be validated.

Copy link
Member

@mmitche mmitche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from removing the semantic versioning patch which has already been discussed, I have only one minor comment. It's not immediately clear to me what DotNetSourceOnlyTestOnly means. Does it mean only testing during a source-only build, with no build? Or with a build?

@mthalman
Copy link
Member Author

It's not immediately clear to me what DotNetSourceOnlyTestOnly means. Does it mean only testing during a source-only build, with no build? Or with a build?

That gets set to true when running the source build validation job, which is a separate job that depends on outputs from the SB job and several UB jobs in order to run all of the tests. TestOnly means it's only going to be running tests. SourceOnly means that it's in source-build mode which enables certain test functionality.

@ViktorHofer
Copy link
Member

ViktorHofer commented Apr 17, 2025

You probably mentioned that in today's sync but will this change cause dev builds to fail? What about ci builds which also appear before previewX builds according to semver rules?

Asking as I currently depend on working dev builds for my outer/inner build work. Not blocking as my work can wait.

@mthalman
Copy link
Member Author

You probably mentioned that in today's sync but will this change cause dev builds to fail? What about ci builds which also appear before previewX builds according to semver rules?

Asking as I currently depend on working dev builds for my outer/inner build work. Not blocking as my work can wait.

Dev builds will work by default. Dev build mode will only be enabled in source build if you also set EnableDevBuildAsDefaultForSourceOnly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Infrastructure untriaged Request triage from a team member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Verify that source-build works with OfficialBuildId being set by the AzDO pipeline
5 participants