dotnet / dotnet/arcade

Some build targets run when ExcludeFromSourceBuild is set

Open
#7,795 8 comments 0 reactions 0 assignees View on GitHub
help wanted
Dominant language
C#
Stars
729
Forks
397
Avg merge
3d 15m
Merged PRs (30d)
149

Description

- [ ] This issue is blocking
- [ ] This issue is causing unreasonable pain

In some cases, when a project is marked with `ExcludeFromSourceBuild=true`, the build is still running some targets that may lead to unexpected consequences. This was discovered by RedHat when building using a new RID.

Even though a project was marked with `ExcludeFromSourceBuild`, it was still calling the `ProcessFrameworkReferences` target which ended up calling the `ResolveAppHosts` which failed on the new RID. But, the assumption is that if the project was marked `ExcludeFromSourceBuild`, it should not be doing anything with this project.

I reproed this issue locally by building arcade with source-build `./build.sh /p:ArcadeBuildFromSource=true` and looking at the binlog at `./artifacts/source-build/self/src/artifacts/sourcebuild.binlog`. There are 3 projects to consider in the output:
- Microsoft.DotNet.Arcade.Sdk.csproj - Has `ExcludeFromSourcebuild` set to false & builds normally.
- Microsoft.DotNet.Build.Tasks.Feed.csproj - Has `ExcludeFromSourceBuild` set to true and doesn't execute any targets.
- Microsoft.DotNet.GitSync.CommitManager.csproj - Has `ExcludeFromSourcebuild` set to true and executes some targets.

The difference between the 2nd and 3rd projects is that Microsoft.DotNet.Build.Tasks.Feed.csproj specifies multiple TargetFrameworks while Microsoft.DotNet.GitSync.CommitManager.csproj specifies a single TargetFramework. Because of this difference, the last project includes `Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.BeforeCommon.targets` instead of `Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.BeforeCommonCrossTargeting.targets`. That in turn imports `Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.RuntimeIdentifierInference.targets` which seems to include the targets that are being run.

As a workaround, I added the following targets to https://github.com/dotnet/arcade/blob/main/src/Microsoft.DotNet.Arcade.Sdk/tools/Empty.targets which eliminated calling the targets:
``
``
``
``
``

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.