Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ResolveReferences dependency on GenerateBindingRedirects target causes intermittent publishing failures #10901

Open
tmat opened this issue Oct 28, 2024 · 0 comments
Labels
Area-NetSDK gathering-feedback The issue requires feedback in order to be planned, please comment if the feature is useful for you triaged

Comments

@tmat
Copy link
Member

tmat commented Oct 28, 2024

Problem

Roslyn build from Visual Studio intermittently fails with error:

C:\Program Files\dotnet\sdk\9.0.100-rc.2.24474.11\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(355,5): error MSB3030: Could not copy the file "D:\github\roslyn\artifacts\obj\InteractiveHost64\Debug\net472\win-x64\InteractiveHost64.exe.config" because it was not found. [D:\github\roslyn\src\Interactive\HostProcess\x64\InteractiveHost64.csproj]

This is caused by the following sequence of events:

  1. Roslyn.VisualStudio.Setup.csproj invokes build of InteractiveHost64.csproj with entry target PublishedProjectOutputGroup, which depends on target PublishItemsOutputGroup.
  2. Roslyn.VisualStudio.Setup.csproj invokes build of InteractiveHost64.csproj with entry target PublishVsixItems, which depends on target Publish and transitively also on PublishItemsOutputGroup.

PublishItemsOutputGroup depends on ResolveReferences, which depends on GenerateBindingRedirects.

GenerateBindingRedirects has condition '$(BuildingProject)' == 'true'".

BuildingProject property is set by BuildOnlySettings in various targets that need to build assets (Build, Publish, etc.). However, BuildOnlySettings is not set by PublishItemsOutputGroup as this target should only determine the items to be published but not publish them.

The invocation of PublishItemsOutputGroup in [1] skips generation of binding redirects (BuildingProject is `false') and the second invocation is skipped because the target already executed. As a result the App.config file is never written to and the build subsequently fails to copy the file.

Binlog: RoslynVSBuild.zip

Proposal

It doesn't seem like ResolveReferences should depend on the content of the generated App.config file. It should therefore not depend on GenerateBindingRedirects target:

 <!--
    ============================================================
                                        ResolveReferences
    ============================================================
    -->
  <PropertyGroup>
    <ResolveReferencesDependsOn>
      BeforeResolveReferences;
      AssignProjectConfiguration;
      ResolveProjectReferences;
      FindInvalidProjectReferences;
      ResolveNativeReferences;
      ResolveAssemblyReferences;
      GenerateBindingRedirects;  <!-- Should be removed -->
      GenerateBindingRedirectsUpdateAppConfig;
      ResolveComReferences;
      AfterResolveReferences
    </ResolveReferencesDependsOn>
  </PropertyGroup>
@tmat tmat transferred this issue from dotnet/sdk Oct 28, 2024
@maridematte maridematte added triaged gathering-feedback The issue requires feedback in order to be planned, please comment if the feature is useful for you and removed untriaged labels Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-NetSDK gathering-feedback The issue requires feedback in order to be planned, please comment if the feature is useful for you triaged
Projects
None yet
Development

No branches or pull requests

2 participants