Summary
Projects using NuGet Central Package Management (CPM) via Directory.Packages.props fail to load in the Roslyn MSBuild workspace. The solution "loads" but all projects referencing CPM-managed packages report [Failure] diagnostics, resulting in zero code intelligence for affected files.
Environment
- csharp-ls: 0.22.0
- .NET SDK: 10.0.102
- OS: Fedora Linux (x86_64)
- Solution format:
.slnx
Reproduction
Given a solution using CPM with Directory.Packages.props:
<!-- Directory.Packages.props -->
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="System.Reactive.Linq" Version="6.1.0" />
</ItemGroup>
</Project>
<!-- MyProject.csproj -->
<ItemGroup>
<PackageReference Include="System.Reactive.Linq" />
</ItemGroup>
This is valid CPM configuration (dotnet build succeeds). However, csharp-ls reports:
msbuildWorkspace.Diagnostics: [Failure] Msbuild failed when processing the file
'MyProject.csproj' with message: The following PackageReference items cannot define
a value for Version: System.Reactive.Linq. Projects using Central Package Management
must define a Version value on a PackageVersion item.
And for dependent projects:
msbuildWorkspace.Diagnostics: [Failure] Msbuild failed when processing the file
'DependentProject.csproj' with message: MyProject does not provide an inclusive lower
bound for dependency System.Reactive.Linq. System.Reactive.Linq 3.0.0 was resolved instead.
Impact
All projects in the solution that reference CPM-managed packages (or depend on projects that do) fail to load. The solution appears to finish loading (Finished loading solution), but no diagnostics, symbols, or code intelligence are available for any file in the affected projects.
Steps to reproduce
- Create a .NET solution with CPM enabled (
Directory.Packages.props with ManagePackageVersionsCentrally)
- Add a
PackageVersion entry and reference it from a project without a Version attribute
- Run
csharp-ls --solution MySolution.slnx -l debug
- Open a file from the project via
textDocument/didOpen
- Observe
[Failure] diagnostics in the log and no publishDiagnostics for the file
Notes
This may be an issue in the Roslyn MSBuildWorkspace layer rather than csharp-ls itself. dotnet build uses the real MSBuild which handles CPM correctly; the Roslyn workspace loader may use a different code path.
Summary
Projects using NuGet Central Package Management (CPM) via
Directory.Packages.propsfail to load in the Roslyn MSBuild workspace. The solution "loads" but all projects referencing CPM-managed packages report[Failure]diagnostics, resulting in zero code intelligence for affected files.Environment
.slnxReproduction
Given a solution using CPM with
Directory.Packages.props:This is valid CPM configuration (
dotnet buildsucceeds). However, csharp-ls reports:And for dependent projects:
Impact
All projects in the solution that reference CPM-managed packages (or depend on projects that do) fail to load. The solution appears to finish loading (
Finished loading solution), but no diagnostics, symbols, or code intelligence are available for any file in the affected projects.Steps to reproduce
Directory.Packages.propswithManagePackageVersionsCentrally)PackageVersionentry and reference it from a project without aVersionattributecsharp-ls --solution MySolution.slnx -l debugtextDocument/didOpen[Failure]diagnostics in the log and nopublishDiagnosticsfor the fileNotes
This may be an issue in the Roslyn
MSBuildWorkspacelayer rather than csharp-ls itself.dotnet builduses the real MSBuild which handles CPM correctly; the Roslyn workspace loader may use a different code path.