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

[Bug]: ResolveKeySource is not a dependency of CoreCompile #10306

Open
jjonescz opened this issue Jun 28, 2024 · 4 comments
Open

[Bug]: ResolveKeySource is not a dependency of CoreCompile #10306

jjonescz opened this issue Jun 28, 2024 · 4 comments
Assignees
Labels

Comments

@jjonescz
Copy link
Member

jjonescz commented Jun 28, 2024

Issue Description

CoreCompile target calls Csc with KeyFile="$(KeyOriginatorFile)".
This KeyOriginatorFile property is set by the ResolveKeySource target.
ResolveKeySource target is not a dependency of CoreCompile (although it is a dependency of e.g., Compile and CoreBuild)
Most of the time it seems the ResolveKeySource target is actually executed before CoreCompile so everything works fine - but sometimes it doesn't: dotnet/roslyn#74156

Steps to Reproduce

  1. Clone roslyn at 31e6ba81af842e960aa04850b0e63229874d4f02
  2. Run .\Restore.cmd
  3. Open in VS IntPreview Version 17.11.0 Preview 3.0 [35026.344.main]
  4. Run Build > Build Solution - succeeds
  5. Run Build > Build Solution again - fails - see Can only build Roslyn.sln a single time before building breaks (2) roslyn#74156

Creating a minimal repro would be complicated, I don't know the exact conditions needed to get the buggy ordering of targets.

Here's the binlog (from a VS build) where I saw the issue: vs.binlog.zip

Expected Behavior

Build succeeds the second time.

Actual Behavior

CSC error CS8102: Public signing was specified and requires a public key, but no public key was specified. [D:\roslyn-D\src\VisualStudio\CSharp\Impl\Microsoft.VisualStudio.LanguageServices.CSharp.csproj]

Analysis

No response

Versions & Configurations

No response

@rainersigwald
Copy link
Member

In that binlog:

  1. CoreCompile is running because of <Target Name="_SetGeneratedOutputItems" DependsOnTargets="CoreCompile"> from microsoft.visualstudio.extensibility.jsongenerators.sdk\17.10.2079\build\Microsoft.VisualStudio.Extensibility.JsonGenerators.Sdk.props
  2. That's depended on by ExtensionJsonOutputGroup
  3. That's explicitly requested in the reference through VSSDK targets by

https://github.com/dotnet/roslyn/blob/879be6a9604d74f51916939625856e6602303256/src/VisualStudio/Setup/Roslyn.VisualStudio.Setup.csproj#L209C146-L209C170

I think two things should be done:

  1. The VSSDK should be updated so that reference is Compile instead of CoreCompile, which would trigger all of $(CompileDependsOn) in order and work.
  2. CoreCompile for VB and C# should consider adding an explicit dependency on ResolveKeySource.

The reason I'm saying "consider" for 2 is that right now CoreCompile doesn't really have any explicit dependencies and depends on the implicit $(BuildDependsOn)/$(CompileDependsOn) ordering. That can produce other problems like this (I'm a bit surprised for example that NuGet references made it into this compilation)--but adding a constraints to target order has been a surprisingly breaking operation in the past due to how people have hooked the fragile existing system.

@rainersigwald
Copy link
Member

  • The VSSDK should be updated so that reference is Compile instead of CoreCompile, which would trigger all of $(CompileDependsOn) in order and work.

I did this in an internal PR that I just completed; not sure when there'll be a new package for Roslyn to reference @jjonescz.

@jjonescz
Copy link
Member Author

jjonescz commented Jul 10, 2024

Thanks, now after updating VSSDK with the fix I see a similar issue - WPF markup is not getting compiled. Again it looks like target CoreBuild depends on PrepareResources which depends on MarkupCompilePass1 and CoreCompile is not in this dependency chain so it can run before MarkupCompilePass1 - failing to find the C# files generated from WPF XAML markup files.

Here are binlogs - first a failing one then another succeeding on rebuild for comparison: wpf-binlogs.zip

@Cosifne
Copy link
Member

Cosifne commented Jul 17, 2024

Should we create another bug? I think we have another request, asking PrepareResources should also be called before CoreCompile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants