-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
APICompat fails when Roslyn's dependencies move past our own. #32691
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
@dotnet/area-infrastructure-libraries a new issue has been filed in the ApiCompat area, please triage |
Move (only) the `Windows Full Release (no bootstrap)` leg to the `windows.vs2022preview.amd64.open` pool, which has Visual Studio 17.6 on it already. This will unblock #8674 by avoiding dotnet/sdk#32691; the `MSBuild.exe.config` binding redirects in the 17.6 VS will keep the current versions working for the moment.
This is now again causing dependency flow uptake issues in msbuild: dotnet/msbuild#9642. That PR updates to a newer roslyn which now references SCI and SRM 8.0.0. |
Looking at my local SDK folder, I don't see a deps file next to the APICompat task. Should it be included?
|
Normal applications built on top of Roslyn do not experience this type of problem. They reference |
It is built like that - the problem is that it allows for an externally provided copy of Microsoft.CodeAnalysis. This was done so that we wouldn't ship duplicate copies of CodeAnalysis in the SDK. |
Why doesn't the installer just do a hard link here? Building dependencies this way is just asking for problems like this. |
Trying to load SCI/8.0.0.0 from the roslyn directory via a custom assembly resolver doesn't work, presumably because MSBuild already loaded SCI/7.0.0.0 as part of the task interface and msbuild's binding redirects prohibit unifying to the 8.0.0.0 version. I believe that this is a desktop msbuild only issue and only happens when binding redirects aren't in-sync with the Roslyn compiler used. Repro: pkgvalerrdep.zip -> I'm not an expert in this area but this sounds to me that we would need a separate AppDomain (.NETFramework) and AssemblyLoadContext (.NETCoreApp) and dynamically instantiate all the CodeAnalysis types that we need. |
Or ... develop APICompat the way it's intended to be developed and teach the installer to hard link. I feel like we're in a hole here and think the solution is to dig deeper. |
Sure. I was looking for a short term fix for 8.0.200. |
Here's a workaround: use the VS Roslyn bits instead of the ones from the Microsoft.NET.Compiler.Toolset package. diff --git a/Directory.Build.targets b/Directory.Build.targets
index b57a232300..c0dab293b6 100644
--- a/Directory.Build.targets
+++ b/Directory.Build.targets
@@ -37,4 +37,10 @@
<RemoveDir Directories="$(_PackageFolderInGlobalPackages)"
Condition="Exists('$(_PackageFolderInGlobalPackages)')" />
</Target>
+
+ <Target Name="WorkAroundRoslynMove" AfterTargets="CollectApiCompatInputs">
+ <PropertyGroup>
+ <RoslynAssembliesPath>$(RoslynTargetsPath)</RoslynAssembliesPath>
+ </PropertyGroup>
+ </Target>
</Project> |
Sounds like an OK workaround. We could condition that target on when running on Desktop and when on an older MSBuildVersion than x. What's the earliest MSBuildVersion that updated the binding redirect for SCI to 8.0.0.0? |
Yes.
Sort of! What's happening is that |
17.9.0 should do the trick for released versions, I'd have to look up the four-part version to get more specific. |
…msbuild < 17.9.0 Contributes (works around) #32691 When using a desktop msbuild / VS < 17.9.0 and using an out-of-band Roslyn >= 4.9.0, APICompat fails to load dependencies like SCI and epically fails. This adds a workaround to not use the out-of-band Roslyn for APICompat.
…msbuild < 17.9.0 Contributes (works around) #32691 When using a desktop msbuild / VS < 17.9.0 and using an out-of-band Roslyn >= 4.9.0, APICompat fails to load dependencies like SCI and epically fails. This adds a workaround to not use the out-of-band Roslyn for APICompat.
@ericstj I wonder if we should keep close this now given that we don't support the compilers toolset package anymore without an opt-in switch in APICompat. |
First found here: dotnet/msbuild#8674 (comment)
Describe the bug
API Compat shares some dependencies with Roslyn. Those that are in the framework should get unified on our behalf. Those that are carried with the task will not. The task tries to unify them (it has a deps file) but this won't work if Roslyn uses versions higher than the task. We might consider loading the versions from Roslyn instead of those in the SDK.
To Reproduce
Using 7.0 GA sdk, try to have the task use latest compiler (for example with the compilers nuget package). Apparently this can happen with some combination of SDK / VS version.
Exceptions (if any)
Further technical details
dotnet --info
The text was updated successfully, but these errors were encountered: