You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: ResolveKeySource is not a dependency of CoreCompile #10306
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
Clone roslyn at 31e6ba81af842e960aa04850b0e63229874d4f02
Run .\Restore.cmd
Open in VS IntPreview Version 17.11.0 Preview 3.0 [35026.344.main]
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]
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
That's depended on by ExtensionJsonOutputGroup
That's explicitly requested in the reference through VSSDK targets by
The VSSDK should be updated so that reference is Compile instead of CoreCompile, which would trigger all of $(CompileDependsOn) in order and work.
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.
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
Activity
rainersigwald commentedon Jun 28, 2024
In that binlog:
CoreCompileis running because of<Target Name="_SetGeneratedOutputItems" DependsOnTargets="CoreCompile">frommicrosoft.visualstudio.extensibility.jsongenerators.sdk\17.10.2079\build\Microsoft.VisualStudio.Extensibility.JsonGenerators.Sdk.propsExtensionJsonOutputGrouphttps://github.com/dotnet/roslyn/blob/879be6a9604d74f51916939625856e6602303256/src/VisualStudio/Setup/Roslyn.VisualStudio.Setup.csproj#L209C146-L209C170
I think two things should be done:
Compileinstead ofCoreCompile, which would trigger all of$(CompileDependsOn)in order and work.CoreCompilefor VB and C# should consider adding an explicit dependency onResolveKeySource.The reason I'm saying "consider" for 2 is that right now
CoreCompiledoesn'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 commentedon Jul 9, 2024
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 commentedon 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
CoreBuilddepends onPrepareResourceswhich depends onMarkupCompilePass1andCoreCompileis not in this dependency chain so it can run beforeMarkupCompilePass1- 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 commentedon Jul 17, 2024
Should we create another bug? I think we have another request, asking
PrepareResourcesshould also be called beforeCoreCompileRemove workaround for dotnet/msbuild#10306
Remove workaround for dotnet/msbuild#10306 (#77974)
Merge main to runtime async branch (#78114)