Skip to content

Opencode with csharp-ls locks source gen ddl files after some time #312

@HalvorNygaard

Description

@HalvorNygaard

When OpenCode is using the language server, after some time it permanently locks the dll of a source generation project, this leads to no other commands like 'dotnet build' or 'dotnet test' works on that solution until the LSP is shutdown / restarted. I have clue if the fix for this is here in this project, on OpenCodes end, or the Roslyn Analyzer itself.

These three logs what appears in my terminal whenever i try try to run a project in the same solution. The first one appears multiple times.

Microsoft.Common.CurrentVersion.targets(4903,5): Warning MSB3026 : Could not copy "obj\Debug\netstandard2.0\PlaceHolderFileName.SourceGen.dll" to "bin\Debug\netstandard2.0\PlaceHolderFileName.SourceGen.dll". Beginning retry 10 in 1000ms. The process cannot access the file 'C:\PlaceHolderPath\src\PlaceHolderFileName.SourceGen\bin\Debug\netstandard2.0\PlaceHolderFileName.SourceGen.dll' because it is being used by another process. The file is locked by: "CSharpLanguageServer (141940)"

Microsoft.Common.CurrentVersion.targets(4903,5): Error MSB3027 : Could not copy "obj\Debug\netstandard2.0\PlaceHolderFileName.SourceGen.dll" to "bin\Debug\netstandard2.0\PlaceHolderFileName.SourceGen.dll". Exceeded retry count of 10. Failed. The file is locked by: "CSharpLanguageServer (141940)"

Microsoft.Common.CurrentVersion.targets(4903,5): Error MSB3021 : Unable to copy file "obj\Debug\netstandard2.0\PlaceHolderFileName.SourceGen.dll" to "bin\Debug\netstandard2.0\PlaceHolderFileName.SourceGen.dll". The process cannot access the file 'C:\PlaceHolderPath\src\PlaceHolderFileName.SourceGen\bin\Debug\netstandard2.0\PlaceHolderFileName.SourceGen.dll' because it is being used by another process.

Here is the spot in OpenCode where the lsp init code it: https://github.com/anomalyco/opencode/blob/4e41ca74b9c0418bf3d03b9d5c308f52782b0787/packages/opencode/src/lsp/server.ts#L733

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions