Skip to content

Investigate ExcludeFromSourceBuild not working in dotnet/runtime #1825

Closed

Description

@dagood

#1820 tried to exclude R2RDump from source-build, but it still got restored and its dependencies were still prebuilts.

I suspect that the new static restore might not be evaluating the projects the same way as they used to, preventing the ExcludeFromSourceBuild property from working. I haven't looked very far into it, but I wonder if maybe the problem is that it isn't checking DotNetBuildFromSource in the environment and we need to pass it in as a command, since RestoreTaskEx is called something like this (newlines for clarity):

"/src/.dotnet/dotnet"
"/src/.dotnet/sdk/5.0.100-preview.8.20417.9/NuGet.Build.Tasks.Console.dll"
"CleanupAssetsForUnsupportedProjects=True;
  NoCache=True;
  Recursive=True"
"/src/.dotnet/sdk/5.0.100-preview.8.20417.9/MSBuild.dll"
"/src/artifacts/src/runtime.bf456654f9a4f9a86c15d9d50095ff29cde5f0a4/Build.proj"
"ContinuousIntegrationBuild=true;
  Configuration=Release;
  RepoRoot=/src/artifacts/src/runtime.bf456654f9a4f9a86c15d9d50095ff29cde5f0a4/;
  Rebuild=false;
  Test=false;
  Pack=false;
  IntegrationTest=false;
  PerformanceTest=false;
  RuntimeConfiguration=Release;
  Subset=clr.tools+clr.runtime+clr.corelib+clr.nativecorelib+clr.packages;
  TargetArchitecture=x64;
  CMakeArgs=;
  MicrosoftNetFrameworkReferenceAssembliesVersion=1.0.0;
  PackagesDir=/src/packages/restored/;
  PackageRid=centos.7-x64;
  NoPgoOptimize=true;
  KeepNativeSymbols=true;
  RuntimeOS=centos.7;
  DotNetPackageVersionPropsPath=/src/artifacts/obj/x64/Release/PackageVersions.props;
  DotNetRestoreSourcePropsPath=/src/artifacts/obj/x64/Release/RestoreSources.props;
  VersionsPropsPath=/src/artifacts/src/runtime.bf456654f9a4f9a86c15d9d50095ff29cde5f0a4/eng/Versions.props;
  DisableWarnForInvalidRestoreProjects=true;
  __BuildPhase=SolutionRestore;
  _NETCORE_ENGINEERING_TELEMETRY=Restore;
  MSBuildRestoreSessionId=4d351d66-a832-485b-8465-698ff0f49b17;
  RestoreUseStaticGraphEvaluation=true;
  ExcludeRestorePackageImports=true"

It should have access the the env vars, though, so that might be a red herring.

It might just be that RestoreTaskEx uses a completely new execution flow and doesn't care when Arcade tries to blank out the usual restore Targets.

Perhaps a way around this is to add to CollectPackageReferences and remove out all package refs? (I believe RestoreTaskEx will specifically evaluate this target because it's where a lot of custom refs happen.)

The current surefire workaround is to stop using ExcludeFromSourceBuild for now and instead make more heavy-handed and perhaps unmergeable patches.

Related-seeming issues:

Activity

  1. added
    area-patch-removal
    area-infra
    on Oct 21, 2020
  2. dagood commented on Dec 23, 2020

    @dagood
    MemberAuthor

    I spotted in a dotnet/runtime PR that it appears to actually be possible to generate static restore binlogs! We can probably use that to nail down the root cause here. dotnet/runtime#46270

    +    <GenerateRestoreUseStaticGraphEvaluationBinlog>true</GenerateRestoreUseStaticGraphEvaluationBinlog>
  3. ViktorHofer commented on Apr 14, 2025

    @ViktorHofer
    Member

    This is by design. We use static graph restore which doesn't support this Arcade exclusion infra. Instead, we don't traverse a project in the graph if it shouldn't be referenced. We do this by apply conditions on the P2Ps / ProjectToBuild items in runtime. This can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-infraarea-patch-removal

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions