Skip to content

Broken incremental build related to SourceLink and generated AssemblyInfo.cs #37027

@KirillOsenkov

Description

@KirillOsenkov

Starting with .NET 8 I'm observing broken incremental builds related to SourceLink and the generated assembly info file.

When the regular command-line build runs, EnableSourceControlManagerQueries is true, so InitializeSourceControlInformationFromSourceControlManager runs. Then the Git SHA is added to the informational version during AddSourceRevisionToInformationalVersion. Finally CoreGenerateAssemblyInfo runs, and writes the full sha such as 1.0.0+60002d5025224f2f2ffd0e1e159226e7c2ff61c3 into $(GeneratedAssemblyInfoFile).

However during design-time build, EnableSourceControlManagerQueries is false because DesignTimeBuild = true:
https://github.com/dotnet/sourcelink/blob/4ca4236c10047416251be48339d464f15a697e8b/src/SourceLink.Common/build/Microsoft.SourceLink.Common.props#L13

Then the target InitializeSourceControlInformationFromSourceControlManager doesn't run, so ultimately the generated assembly informational version is just 1.0.0.

Thus, the file Foo.AssemblyInfo.cs gets a different assembly informational attribute after regular and design-time builds, thus flip-flopping and breaking incrementality.

I don't think I've seen this before .NET 8 (maybe because SourceLink stuff wasn't on by default?).

@drewnoakes @tmat

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions