Some build targets run when ExcludeFromSourceBuild is set
- 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
Assessment
This issue has not been assessed yet.