Skip to content

DeterministicSourcePaths can break building if source control information not available #37379

Closed
@KevinCathcart

Description

@KevinCathcart

Version Used:
dotnet sdk 2.2.300
Steps to Reproduce:

  1. dotnet new console
  2. dotnet build /p:ContinuousIntegrationBuild=true

Actual Behavior:

C:\Program Files\dotnet\sdk\2.2.300\Roslyn\Microsoft.Managed.Core.targets(102,5): error : SourceRoot items must include at least one top-level (not nested) item when DeterministicSourcePaths is true

Expected Behavior:
Build Succeeds.

The mere fact that we we are performing a continuous integration build does not mean that source control information will be available to MSBuild. However deterministic builds are enabled by default, and turning on ContinuousIntegrationBuild, means that DeterministicSourcePaths is enabled.

That would be fine if DeterministicSourcePaths worked when no source control information was available, but it requires SourceRoot items, which are only created by a source control information provider like the Source Link packages.

This bit me when I tried to add a new Test project to a solution being built with /p:ContinuousIntegrationBuild=true. I did not bother to add a Source Link NuGet package since I was not going to package or publish the test project on the CI server, merely run it, so I don't actually need Source Link data in the pdbs.

Obviously I know the workarounds (add the Source Link package or set DeterministicSourcePaths to false in the test project).

But ideally they would not be needed. Instead ideally, either a) DeterministicSourcePaths would only be set if a source control information provider package was installed, or b) that DeterministicSourcePaths was somehow made to work even without a source provider package.

@tmat I think you are the expert on this stuff, so this is probably your issue.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions