Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@dotnet-maestro
Copy link
Contributor

@dotnet-maestro dotnet-maestro bot commented Oct 29, 2025

Note

This is a codeflow update. It may contain both source code changes from the source repo as well as dependency updates. Learn more here.

This pull request brings the following source code changes

From https://github.com/dotnet/roslyn

@dotnet-maestro
Copy link
Contributor Author

Note

PRs from original repository included in this codeflow update:

💡 You may consult the FAQ for more information or tag @dotnet/product-construction for assistance.

@dotnet-maestro
Copy link
Contributor Author

Important

There are conflicts with the main branch in this PR.
Apart from conflicts in the source files, this means there are unresolved conflicts in the codeflow metadata file src/source-manifest.json.
When resolving these, please use the (incoming/ours) version from the PR branch. The correct content should be this:

{
  "barId": 288936,
  "path": "roslyn",
  "remoteUri": "https://github.com/dotnet/roslyn",
  "commitSha": "d4a697d01ea70799b5dd603ffff005dfb176253a"
}

💡 You may consult the FAQ for more information or tag @dotnet/product-construction for assistance.

@dotnet-maestro
Copy link
Contributor Author

Note

PRs from original repository included in this codeflow update:

💡 You may consult the FAQ for more information or tag @dotnet/product-construction for assistance.

@jjonescz
Copy link
Member

@tmat

  /__w/1/s/src/sdk/src/BuiltInTools/dotnet-watch/HotReload/CompilationHandler.cs(9,45): error CS0234: The type or namespace name 'Watch' does not exist in the namespace 'Microsoft.CodeAnalysis.ExternalAccess' (are you missing an assembly reference?) [/__w/1/s/src/sdk/src/BuiltInTools/dotnet-watch/dotnet-watch.csproj]
  /__w/1/s/src/sdk/src/BuiltInTools/dotnet-watch/HotReload/IncrementalMSBuildWorkspace.cs(7,45): error CS0234: The type or namespace name 'Watch' does not exist in the namespace 'Microsoft.CodeAnalysis.ExternalAccess' (are you missing an assembly reference?) [/__w/1/s/src/sdk/src/BuiltInTools/dotnet-watch/dotnet-watch.csproj]
  /__w/1/s/src/sdk/src/BuiltInTools/dotnet-watch/HotReload/CompilationHandler.cs(229,32): error CS0246: The type or namespace name 'WatchHotReloadService' could not be found (are you missing a using directive or an assembly reference?) [/__w/1/s/src/sdk/src/BuiltInTools/dotnet-watch/dotnet-watch.csproj]
  /__w/1/s/src/sdk/src/BuiltInTools/dotnet-watch/HotReload/CompilationHandler.cs(294,65): error CS0246: The type or namespace name 'WatchHotReloadService' could not be found (are you missing a using directive or an assembly reference?) [/__w/1/s/src/sdk/src/BuiltInTools/dotnet-watch/dotnet-watch.csproj]
  /__w/1/s/src/sdk/src/BuiltInTools/dotnet-watch/HotReload/CompilationHandler.cs(342,53): error CS0246: The type or namespace name 'WatchHotReloadService' could not be found (are you missing a using directive or an assembly reference?) [/__w/1/s/src/sdk/src/BuiltInTools/dotnet-watch/dotnet-watch.csproj]
  /__w/1/s/src/sdk/src/BuiltInTools/dotnet-watch/HotReload/CompilationHandler.cs(342,124): error CS0246: The type or namespace name 'WatchHotReloadService' could not be found (are you missing a using directive or an assembly reference?) [/__w/1/s/src/sdk/src/BuiltInTools/dotnet-watch/dotnet-watch.csproj]
  /__w/1/s/src/sdk/src/BuiltInTools/dotnet-watch/HotReload/CompilationHandler.cs(632,103): error CS0246: The type or namespace name 'WatchHotReloadService' could not be found (are you missing a using directive or an assembly reference?) [/__w/1/s/src/sdk/src/BuiltInTools/dotnet-watch/dotnet-watch.csproj]
  /__w/1/s/src/sdk/src/BuiltInTools/dotnet-watch/HotReload/CompilationHandler.cs(20,26): error CS0246: The type or namespace name 'WatchHotReloadService' could not be found (are you missing a using directive or an assembly reference?) [/__w/1/s/src/sdk/src/BuiltInTools/dotnet-watch/dotnet-watch.csproj]
  /__w/1/s/src/sdk/src/BuiltInTools/dotnet-watch/HotReload/CompilationHandler.cs(39,31): error CS0246: The type or namespace name 'WatchHotReloadService' could not be found (are you missing a using directive or an assembly reference?) [/__w/1/s/src/sdk/src/BuiltInTools/dotnet-watch/dotnet-watch.csproj]

@dotnet-maestro
Copy link
Contributor Author

@dotnet-maestro
Copy link
Contributor Author

dotnet-maestro bot commented Nov 2, 2025

@jjonescz
Copy link
Member

jjonescz commented Nov 3, 2025

Talked to @tmat offline; needs sdk changes from 10.0.2xx to flow into sdk main first (dotnet/sdk#51207)
In the meantime, roslyn main should flow to 10.0.2xx of vmr anyway (although that seems to be waiting on #3162)

@dotnet-maestro
Copy link
Contributor Author

dotnet-maestro bot commented Nov 4, 2025

@jjonescz
Copy link
Member

jjonescz commented Nov 4, 2025

needs sdk changes from 10.0.2xx to flow into sdk main first

I assume also dotnet/sdk#51540 is needed since the original was quite old

@ViktorHofer
Copy link
Member

@jjonescz VMR now has latest SDK. Can you please take a look at the failures? Thanks

@jjonescz
Copy link
Member

The error is

src/sdk/src/BuiltInTools/Watch/Microsoft.DotNet.HotReload.Watch.csproj(0,0): error NU1102: (NETCORE_ENGINEERING_TELEMETRY=Restore) Unable to find package Microsoft.CodeAnalysis.Contracts with version (>= 5.3.0-ci)

Where in the binlog I additionally see:

- Versions from source-built-roslyn were not considered

And

Package source mapping matches found for package ID 'Microsoft.CodeAnalysis.Contracts' are: 'source-built-source-build-reference-packages,dotnet6,dotnet6-transport,dotnet7,dotnet7-transport,dotnet8,dotnet8-transport,dotnet8-workloads,dotnet9,dotnet9-transport,dotnet10,dotnet10-transport,dotnet11,dotnet11-transport,dotnet-public,dotnet-eng,dotnet-tools,dotnet-tools-transport,dotnet-libraries,dotnet-libraries-transport,vs-impl,richnav,test-tools'.

I would expect the Contracts package to come from source-built-roslyn, i.e., source build seems badly configured, but I don't know where exactly is this configured, any ideas?

@jjonescz
Copy link
Member

FWIW, the 10.0.2xx branch can be used for comparison (the roslyn code there is the same) - there are no failures, see #3936.

Also cc @tmat. Have you made any changes related to this package which are missing here?

@ViktorHofer
Copy link
Member

A Version.Details.xml entry is missing in sdk (and a corresponding Version.Details.props property).

@jjonescz
Copy link
Member

Hm, that doesn't seem to be present in the 10.0.2xx branch either (so why that one doesn't fail?), but I guess I can try adding it here, thanks.

@ViktorHofer
Copy link
Member

Ah nevermind, I see that those packages all share one version: https://github.com/dotnet/sdk/blob/eb80929b472550eee0e593017adff6773cff9859/Directory.Packages.props#L26

@ViktorHofer
Copy link
Member

ViktorHofer commented Dec 18, 2025

The package doesn't get produced in roslyn:

2025-12-18T08:36:20.4159151Z   New artifact(s) after building roslyn:
2025-12-18T08:36:20.4160404Z     -> Microsoft.CodeAnalysis/5.3.0-ci
2025-12-18T08:36:20.4161016Z     -> Microsoft.CodeAnalysis.Analyzers/5.3.0-ci
2025-12-18T08:36:20.4161381Z     -> Microsoft.CodeAnalysis.AnalyzerUtilities/5.3.0-ci
2025-12-18T08:36:20.4161721Z     -> Microsoft.CodeAnalysis.BuildClient/5.3.0-ci
2025-12-18T08:36:20.4165180Z     -> Microsoft.CodeAnalysis.Common/5.3.0-ci
2025-12-18T08:36:20.4166451Z     -> Microsoft.CodeAnalysis.CSharp/5.3.0-ci
2025-12-18T08:36:20.4166898Z     -> Microsoft.CodeAnalysis.CSharp.CodeStyle/5.3.0-ci
2025-12-18T08:36:20.4167254Z     -> Microsoft.CodeAnalysis.CSharp.Features/5.3.0-ci
2025-12-18T08:36:20.4167649Z     -> Microsoft.CodeAnalysis.CSharp.Scripting/5.3.0-ci
2025-12-18T08:36:20.4167999Z     -> Microsoft.CodeAnalysis.CSharp.Workspaces/5.3.0-ci
2025-12-18T08:36:20.4168382Z     -> Microsoft.CodeAnalysis.Extensions/5.3.0-ci
2025-12-18T08:36:20.4168857Z     -> Microsoft.CodeAnalysis.ExternalAccess.AspNetCore/5.3.0-ci
2025-12-18T08:36:20.4169672Z     -> Microsoft.CodeAnalysis.ExternalAccess.HotReload/5.3.0-ci
2025-12-18T08:36:20.4170198Z     -> Microsoft.CodeAnalysis.ExternalAccess.OmniSharp/5.3.0-ci
2025-12-18T08:36:20.4172635Z     -> Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CSharp/5.3.0-ci
2025-12-18T08:36:20.4173097Z     -> Microsoft.CodeAnalysis.ExternalAccess.RazorCompiler/5.3.0-ci
2025-12-18T08:36:20.4173470Z     -> Microsoft.CodeAnalysis.Features/5.3.0-ci
2025-12-18T08:36:20.4173817Z     -> Microsoft.CodeAnalysis.Scripting.Common/5.3.0-ci
2025-12-18T08:36:20.4174257Z     -> Microsoft.CodeAnalysis.VisualBasic/5.3.0-ci
2025-12-18T08:36:20.4174917Z     -> Microsoft.CodeAnalysis.VisualBasic.CodeStyle/5.3.0-ci
2025-12-18T08:36:20.4180791Z     -> Microsoft.CodeAnalysis.VisualBasic.Features/5.3.0-ci
2025-12-18T08:36:20.4181585Z     -> Microsoft.CodeAnalysis.VisualBasic.Workspaces/5.3.0-ci
2025-12-18T08:36:20.4181916Z     -> Microsoft.CodeAnalysis.Workspaces.Common/5.3.0-ci
2025-12-18T08:36:20.4182256Z     -> Microsoft.CodeAnalysis.Workspaces.MSBuild/5.3.0-ci
2025-12-18T08:36:20.4182830Z     -> Microsoft.Net.Compilers.Toolset/5.3.0-ci
2025-12-18T08:36:20.4183186Z     -> Roslyn.Diagnostics.Analyzers/5.3.0-ci
2025-12-18T08:36:20.6936568Z   DirSize After Building roslyn

@ViktorHofer
Copy link
Member

<ExcludeFromSourceOnlyBuild>true</ExcludeFromSourceOnlyBuild>

@ViktorHofer
Copy link
Member

I don't know why this works in 2xx. Would need to dig deeper.

@jjonescz
Copy link
Member

As far as I can see, the project src/sdk/src/BuiltInTools/Watch/Microsoft.DotNet.HotReload.Watch.csproj doesn't actually use the Contracts package, and it isn't restored for it in the 10.0.2xx branch. So the real bug might be that it's getting restored here for some reason.

@jjonescz jjonescz mentioned this pull request Dec 18, 2025
@ViktorHofer
Copy link
Member

ViktorHofer commented Dec 18, 2025

It is a declared as dependency though in main in those two source projects: https://github.com/search?q=repo%3Adotnet%2Fsdk%20Microsoft.CodeAnalysis.Contracts&type=code

@jjonescz
Copy link
Member

Those projects don't seem to be built in source-build, so it shouldn't matter.

@ViktorHofer
Copy link
Member

ViktorHofer commented Dec 18, 2025

Yeah, right. OK I'm very confused now. I have absolutely no idea where that dependency is coming from then.

C:\git\dotnet>dotnet nuget why src\sdk\src\BuiltInTools\Watch\Microsoft.DotNet.HotReload.Watch.csproj Microsoft.CodeAnalysis.Contracts
Project 'Microsoft.DotNet.HotReload.Watch' does not have a dependency on 'Microsoft.CodeAnalysis.Contracts'.

@ViktorHofer
Copy link
Member

I remembered something that we set in other repos: https://github.com/dotnet/msbuild/blob/92212c00730dfb52f81c7f1e0a8a8d172fe9bb80/eng/Build.props#L3-L6

This could be it. Don't ask me why it shows up now.

@ViktorHofer
Copy link
Member

OK lol that's not it either. The binlog shows that Restore is using normal, non static-graph restore.

@ViktorHofer
Copy link
Member

ViktorHofer commented Dec 18, 2025

@dotnet/nuget-team we are stuck here. The error in the source-build job shows that NuGet tries to download Microsoft.CodeAnalysis.Contracts but we don't see where that dependency is coming from. The three projects that are mentioned (dotnet-format.csproj, dotnet-watch.csproj, ...) don't have a dependency on that package. dotnet nuget why also doesn't show any hits. There's a binlog that shows more details but also that one doesn't list that dependency anywhere.

Any idea how to further diagnose this? Last resort would be building locally and debugging NuGet.

@jjonescz
Copy link
Member

jjonescz commented Dec 18, 2025

I manually flew latest roslyn main in #3944 (as this PR is pretty outdated) and I don't seem to be getting the restore problem there (I'm getting other failures, so will need to resolve them first to be sure, but they seem to be build failures, so I assume restore succeeded) (Actually this leg is succeeding completely, it's a different leg that is failing.)

@ViktorHofer
Copy link
Member

ViktorHofer commented Dec 18, 2025

I verified that the PSB archive that gets used in this source-build job doesn't have any nuget dependencies that depend on Microsoft.CodeAnalysis.Contracts. Here's the log (vibe coded with Copilot - analyzing the nuget packages):
psb-packages.txt

But I noticed that the package itself is inside PSB even though the package is marked as exclude from source-build in at least main and 2xx. Nevermind, it's coming from SBRP (text-only package).

@dotnet-policy-service dotnet-policy-service bot requested a review from a team December 18, 2025 19:21
@zivkan
Copy link
Member

zivkan commented Dec 18, 2025

My guess is that there's a transitive package which has a dependency on Microsoft.CodeAnalysers.Contracts, but that package is eclipsed when every unique package name has its version selected. See the second example here, the one where there are two different versions of Package D: https://learn.microsoft.com/en-us/nuget/concepts/dependency-resolution#cousin-dependencies

NuGet downloads both versions of Package D, so that the next time it needs to resolve the full graph, it doesn't need to make HTTP requests to determine its dependencies.

I think in the case of "direct dependency" NuGet avoids downloadaing the package, but this is getting into the nitty gritty details of restore that I personally have never needed to investigate, so I'm not 100% sure: https://learn.microsoft.com/en-us/nuget/concepts/dependency-resolution#direct-dependency-wins

dotnet nuget why does not show packages "culled" from the graph (packages not in the final selection because the parent package was changed to a different version that does not have the same dependencies).

Unfortunately it's not easy to confirm. If you want to, just thinking on the spot, my guess would be to use the NUGET_PACKAGES environment variable to restore packages to a currently empty directory. Then use grep to scan all *.nuspec files for Microsoft.CodeAnalysis.Contracts, to see if any of the packages do indeed have it as a dependency.

@mmitche
Copy link
Member

mmitche commented Dec 18, 2025

This looks to be a point-in-time issue. CSharp.Features has a dependency on an older version of FileBasedPrograms. This has a package dependency on CodeAnalysis.Contracts. This version gets lifted to 5.3.0-ci, causing the restore error because SB doesn't build it. It's important to note that even if the restore had succeeded, it would have hit a prebuilt failure later on.

@mmitche
Copy link
Member

mmitche commented Dec 18, 2025

I'm closing this PR and re-triggering. We need to pull in newer commits that break the cyclic dep.

@mmitche mmitche closed this Dec 18, 2025
@dotnet-maestro dotnet-maestro bot deleted the darc-main-79f77f9f-a4ab-413d-9aeb-6b42485f21ea branch December 18, 2025 19:52
@ViktorHofer
Copy link
Member

@zivkan thanks for chiming in here. We found the issue and it was a cyclic dependency kinda of. But interestingly, NuGet also crashed here. Might be something to guard against:

System.Collections.Generic.KeyNotFoundException: The given key 'Microsoft.CodeAnalysis.Contracts' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at NuGet.Commands.LockFileBuilder.GetLibraryDependenciesForCentralTransitiveDependencies(RestoreTargetGraph targetGraph, TargetFrameworkInformation targetFrameworkInformation)+MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at NuGet.Commands.LockFileBuilder.AddCentralTransitiveDependencyGroupsForPackageReference(PackageSpec project, LockFile lockFile, IEnumerable`1 targetGraphs)
   at NuGet.Commands.LockFileBuilder.CreateLockFile(LockFile previousLockFile, PackageSpec project, IEnumerable`1 targetGraphs, IReadOnlyList`1 localRepositories, RemoteWalkContext context, LockFileBuilderCache lockFileBuilderCache)
   at NuGet.Commands.RestoreCommand.BuildAssetsFile(LockFile existingLockFile, PackageSpec project, IEnumerable`1 graphs, IReadOnlyList`1 localRepositories, RemoteWalkContext contextForProject)
   at NuGet.Commands.RestoreCommand.ExecuteAsync(CancellationToken token)
   at NuGet.Commands.RestoreRunner.ExecuteAsync(RestoreSummaryRequest summaryRequest, CancellationToken token)
   at NuGet.Commands.RestoreRunner.ExecuteAndCommitAsync(RestoreSummaryRequest summaryRequest, IRestoreProgressReporter progressReporter, CancellationToken token)
   at NuGet.Commands.RestoreRunner.CompleteTaskAsync(List`1 restoreTasks)
   at NuGet.Commands.RestoreRunner.RunAsync(IEnumerable`1 restoreRequests, RestoreArgs restoreArgs, CancellationToken token)
   at NuGet.Commands.RestoreRunner.RunAsync(RestoreArgs restoreContext, CancellationToken token)
   at NuGet.Build.Tasks.BuildTasksUtility.RestoreAsync(DependencyGraphSpec dependencyGraphSpec, Boolean interactive, Boolean recursive, Boolean noCache, Boolean ignoreFailedSources, Boolean disableParallel, Boolean force, Boolean forceEvaluate, Boolean hideWarningsAndErrors, Boolean restorePC, Boolean cleanupAssetsForUnsupportedProjects, ILogger log, CancellationToken cancellationToken)
   at NuGet.Build.Tasks.RestoreTask.ExecuteAsync(ILogger log)

@zivkan
Copy link
Member

zivkan commented Dec 18, 2025

I'm not a restore algorithm expert, so I sent a link to your comment to them. I don't understand the scenario well enough to create a repro, but does this sound like it's related?

If not, and you're able to create a repro for easy local debugging, please create an issue over at NuGet/Home.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants