-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Workspace failed with could not load "NuGet.Frameworks" error #61454
Comments
The customer's sample code looks right, at least at first glance. I've reached out to the MSBuild team for advice here. |
Hi @jasonmalinowski , any update on this? And should I move this to the MSBuild issues? |
@WeihanLi Ah thanks for the ping -- my back and forth with that team got lost in everything else going on. Just to confirm, what version of the SDK are you using? |
@jasonmalinowski thanks for your reply, I'm using the latest .NET 7 Preview 4/5/6/7 && RC SDK |
@jasonmalinowski @rainersigwald I think I'm hitting this same issue in dotnet/api-docs-sync: dotnet/api-docs-sync#124 The code I'm fixing in that PR is for the PortToTripleSlash tool. It lets us backport documentation from dotnet-api-docs into triple slash comments in source. I was able to get it to work when executed manually, no issues detected. But when I attempt to run the unit tests, I hit a very similar error as the one reported here:
Here is what the tests do:
Ping me via Teams if you'd like to see a live repro. The tests are also able to generate a binlog, if you'd like to see it. |
The Microsoft.TestPlatform.ObjectModel used by the .NET Test SDK brings in an older version of NuGet than what is used by the .NET SDK. Roslyn misattributes this reference to the Microsoft.CodeAnalysis.Analyzer.Testing package in our version.props file. Lines 210 to 215 in 2c86eb9
For the purpose of running Unit Tests both dotnet-format and Roslyn add NuGet package references to their UnitTests and keep the NuGet version in step with the version of the .NET SDK pinned by our global.json. See more details from this issue #52954 (comment) cc: @nohwnd, @shyamnamboodiripad, @vritant24 I wonder if the SDK could just fix this up for us by adding implicit NuGet references which match the SDK version to UnitTest projects. |
I think we should get rid of dependency on Nuget.Frameworks altogether if possible. We have quite limited range of supported frameworks and changes in how nuget.frameworks interprets versions has bitten us few times in the past. |
Thank you, @JoeRobich ! Your suggestion unblocked my problem with the tests. Edit: Nevermind, it seems to be still there. |
@carlossanlop Hello, i have almost same case as you, that start failing after latest sdk update. What exactly you did to fix this issue? |
@JoeRobich not sure exactly what happened, but I had to sync my clone to the latest bits, and then do a |
@carlossanlop I should have noted that the version number in my example above is only for .NET 7 SDK Preview 5. If you have installed the newer Preview 6 SDK, then we would need to find the matching NuGet version.
Sure thing. |
@JoeRobich @carlossanlop Hey, i found workaround, that force roslyn to use sdk's dll version. There is not so good solution, but it works. In my case i got error after updating sdk to
|
None of above working for my case 😭 |
Thanks @MelnikovIG! Your suggestion was clever and a good workaround that works for now. I keep getting broken by this every now and then. It's quite obnoxious. Would love to see it fixed and prevented in the future. |
Yes, that worked! I now get the exact same behavior in both |
The 7.0.4xx SDKs ship with a newer version of NuGet.Frameworks than we are shipping. Due to a complicated set of interactions of how the various AssemblyLoadingContexts work (or don't work as expected!), this means that when our LSP server uses MSBuildWorkspace to load projects, it'll end up using the NuGet.Frameworks we use here rather than the MSBuild one, causing load issues. The underlying problem is tracked with dotnet#61454, although I still need to write up the full situation in that bug since back in June we ended up running into a similar issue and had lots of deep analysis of it. Fixing the problem requires changes in several different repositories (and all involving AssemblyLoadContexts, so the changes are very technical) so for now we'll just bump the version. Fixes dotnet/vscode-csharp#5980
The 7.0.4xx SDKs ship with a newer version of NuGet.Frameworks than we are shipping. Due to a complicated set of interactions of how the various AssemblyLoadingContexts work (or don't work as expected!), this means that when our LSP server uses MSBuildWorkspace to load projects, it'll end up using the NuGet.Frameworks we use here rather than the MSBuild one, causing load issues. The underlying problem is tracked with dotnet#61454, although I still need to write up the full situation in that bug since back in June we ended up running into a similar issue and had lots of deep analysis of it. Fixing the problem requires changes in several different repositories (and all involving AssemblyLoadContexts, so the changes are very technical) so for now we'll just bump the version. Fixes dotnet/vscode-csharp#5980
I am facing the same issue with v7.0.4 SDK, I see it was "fixed" in this PR. I tried to come over this problem by adding the following snippet to the .csproj I am trying to load (suggested workaround):
Indeed it made it possible to open the project with BTW, reverting to v7.0.3 will make both opening and compiling the project work. |
@csaba-sagi-sonarsource That fix applies to the language service executable for VS Code that we also build in this repo. Fixing it properly is still a bit more work to properly isolate all the versioning.
This likely would be something else. Now that you mention it I wonder if we have a general hole here with Razor: Razor might be detecting that we're "in" a design time build and thus it thinks we're in an IDE, and as a result might disable the generator. There's some hacks here for how Visual Studio works and it might be tripping things up. Can you file a separate bug and we'll take a look? |
I have opened this issue in the razor repository, with a bit more detail on what happens. If you need any further information on the problem, I am happy to help. |
To work around dotnet#61454 we were deploying NuGet.Frameworks versions in various places; now that we're doing MSBuildWorkspace builds in the build host that has a separate deployment folder we don't need this anymore.
To work around dotnet#61454 we were deploying NuGet.Frameworks versions in various places; now that we're doing MSBuildWorkspace builds in the build host that has a separate deployment folder we don't need this anymore.
To work around dotnet#61454 we were deploying NuGet.Frameworks versions in various places; now that we're doing MSBuildWorkspace builds in the build host that has a separate deployment folder we don't need this anymore.
To work around dotnet#61454 we were deploying NuGet.Frameworks versions in various places; now that we're doing MSBuildWorkspace builds in the build host that has a separate deployment folder we don't need this anymore.
To work around dotnet#61454 we were deploying NuGet.Frameworks versions in various places; now that we're doing MSBuildWorkspace builds in the build host that has a separate deployment folder we don't need this anymore.
To work around dotnet#61454 we were deploying NuGet.Frameworks versions in various places; now that we're doing MSBuildWorkspace builds in the build host that has a separate deployment folder we don't need this anymore.
To work around dotnet#61454 we were deploying NuGet.Frameworks versions in various places; now that we're doing MSBuildWorkspace builds in the build host that has a separate deployment folder we don't need this anymore.
So with the #70469, we now have MSBuildWorkspace running all builds in a separate process which will be isolated from your application dependencies. So dependencies on things like NuGet.Frameworks we no longer expect to be an issue. |
thanks very much @jasonmalinowski , and which version could be expected with this change? |
I would expect 4.9.0-2.final for the first preview bits. |
Previous commit adding the nuget reference didn't work. This is a workaround that works: dotnet/roslyn#61454 (comment)
Previous commit adding the nuget reference didn't work. This is a workaround that works: dotnet/roslyn#61454 (comment)
Previous commit adding the nuget reference didn't work. This is a workaround that works: dotnet/roslyn#61454 (comment)
Previous commit adding the nuget reference didn't work. This is a workaround that works: dotnet/roslyn#61454 (comment)
Previous commit adding the nuget reference didn't work. This is a workaround that works: dotnet/roslyn#61454 (comment)
Previous commit adding the nuget reference didn't work. This is a workaround that works: dotnet/roslyn#61454 (comment)
Version Used: 4.2.0
Steps to Reproduce:
There's a sample: https://github.com/WeihanLi/dotnet-exec/blob/c856424abe605ada9f4d2bedb68c3526d1241bc8/src/dotnet-exec/AdvancedCodeCompiler.cs
Expected Behavior:
Should work without error
Actual Behavior:
And I could not find the
NuGet.Frameworks
package with version6.3.0
on the NuGet website, I finally find it in the sdk folder, did I miss some config?The text was updated successfully, but these errors were encountered: