The Deska blog

OpenCode for .NET: Does It Understand NuGet and Project References?

Explore how OpenCode for .NET handles C# dependencies, NuGet packages, and project references within modern agentic workflows and developer tools.

· 12 min read

Developing software in the .NET ecosystem requires more than just a syntax parser. When utilizing OpenCode for .NET, the most critical question involves its ability to navigate the complex web of NuGet packages and cross-project references that define modern C# applications. A coding agent that only sees the current file is of limited use in a solution containing twenty projects. To be effective, the agent must understand the underlying project system, the global toolset, and how types are resolved across assemblies.

The Architecture of OpenCode in C# Contexts

OpenCode operates by indexing the codebase to provide context to the underlying large language model. Unlike simpler scripts, a sophisticated implementation for .NET must account for the csproj and sln file structures. These files are the source of truth for the compiler. If an agent fails to parse these XML structures, it cannot know that a class in the Core project is accessible to the Web API project.

Most agentic tools approach this by using a combination of static analysis and runtime metadata. Static analysis involves reading the source code directly. Runtime metadata comes from the results of a dotnet build or dotnet restore command. OpenCode attempts to bridge this gap by looking at the file tree and identifying common patterns in .NET development, such as the bin and obj folders or the packages.config and modern PackageReference nodes.

How NuGet Packages are Handled

NuGet packages are the backbone of .NET reuse. When you ask an agent to implement a feature using a library like AutoMapper or Entity Framework Core, the agent needs to know which version is installed. OpenCode typically relies on the local environment to provide this context. Because it runs locally, it has access to your global NuGet cache and the project specific assets.

There are three main ways an agent interacts with NuGet:

  • Discovery: The agent reads the project file to see which PackageReference tags exist.
  • Documentation: The agent uses its internal training data to understand how those libraries work.
  • Execution: The agent can trigger the dotnet CLI to add new packages or restore missing ones.

If you are working within a specialized environment, the agent might struggle with private NuGet feeds or authenticated Azure Artifacts. In these scenarios, the developer must ensure the local machine is already authenticated. The agent does not bypass your system security; it utilizes the credentials already present in your nuget.config file.

Cross Project References and Symbol Resolution

In a large .NET solution, a single change can ripple through multiple projects. A common challenge for AI agents is understanding that ProjectA depends on ProjectB. Without this knowledge, the agent might suggest creating a new class that already exists in a referenced library.

OpenCode handles this by scanning the directory structure for other csproj files. When you provide a prompt that requires cross-file logic, the agent seeks out the relevant files by following the reference chain. This is where the local-first nature of your tools becomes vital. By having direct access to the disk, the agent can quickly grep through the entire solution rather than relying on a limited cloud buffer.

Using OpenCode inside Deska

Deska provides a unique environment for running OpenCode alongside other tools. Within the canvas, you can open multiple panels to monitor the agent's progress. You might have an OpenCode panel running a refactoring task while a terminal panel shows the output of dotnet watch test. This local-first approach ensures that your code never leaves your machine, which is a requirement for many enterprise .NET developers.

Deska allows you to run several agents side by side. You can compare how OpenCode handles a specific C# refactoring compared to Claude Code or Codex CLI. This comparison is often revealing. One agent might be better at writing LINQ queries, while another excels at setting up Dependency Injection boilerplate.

The ask-deska feature further integrates these agents into the workspace. You can use voice or chat to tell the workspace to open all projects referenced by a specific file. This helps the agent and the developer stay in sync. If the agent is confused about a missing reference, you can use the docs/terminals to run a build and pipe the errors back into the agent thread.

Comparing OpenCode with Other Agentic Tools

The market for AI coding assistants is expanding. It is useful to see where OpenCode sits compared to other popular options for C# developers.

FeatureOpenCodeGitHub CopilotClaude Code
Project AwarenessFile based with local indexingRepository wide via cloudTerminal based with file access
NuGet SupportReads csproj filesLarge training set of packagesCan execute CLI commands
Execution EnvironmentLocal machineCloud sidecarLocal terminal
PrivacyLocal-first processingCloud processingLocal execution / Cloud API

These tools differ in approach. Copilot relies heavily on cloud-side indexing of your repository to provide suggestions. OpenCode, especially when used within a tool like Deska, focuses on the immediate context of your local file system. This often results in faster responses for local refactorings but might require more manual guidance for massive, multi-repo architectural changes.

Troubleshooting C# Reference Issues

If OpenCode is not picking up your project references, there are a few steps to take. First, ensure your obj folders are populated. The project.assets.json file generated during restore contains a wealth of information that many tools use to resolve symbols. If this file is missing, the agent is essentially flying blind regarding external dependencies.

Second, check your solution structure. If your projects are scattered across non-standard directory levels, the agent's recursive search might miss them. Keeping a clean, standard .NET directory structure helps the AI as much as it helps human developers.

Third, leverage the mobile app if you need to monitor a long-running refactoring. If you are running a large-scale migration across a .NET solution, you can pair your phone to your workstation. This allows you to check the terminal output for build errors related to missing NuGet packages while you are away from your desk.

FAQ

Does OpenCode support .NET 8 and C# 12 features?

Yes, OpenCode generally supports the latest versions of .NET. Since it uses large language models that have been trained on vast amounts of open source code, it is familiar with primary constructors, collection expressions, and other modern C# syntax. However, the accuracy depends on the specific model you choose to plug into the agent.

Can OpenCode fix NuGet restore errors automatically?

OpenCode can identify the cause of restore errors if it has access to the terminal output. It can suggest changes to your csproj file or your nuget.config. However, it cannot solve network issues or credential problems that are external to the code itself. You can use Deska to run the restore command and then share the logs with the agent.

How do I handle private assembly references in OpenCode?

For assemblies that are not in a NuGet feed but are referenced as DLL files on disk, you should ensure those files are within the directory scope that the agent is allowed to read. If the DLLs are in a global assembly cache or a folder outside the project root, the agent will see the reference in the project file but will not be able to inspect the metadata of the binary itself.

Getting Started with .NET Agents

To begin using OpenCode with your C# projects, you should first prepare your workspace. A clean build ensures all metadata is available. You can download Deska to set up a workspace where you can run these agents locally. By placing your code editor and terminal side by side on the infinite canvas, you create an environment where the agent's actions are transparent and easy to verify.

The power of .NET development lies in its strong typing and robust tooling. By integrating OpenCode into this workflow, you can automate the repetitive parts of coding while maintaining the high standards of a compiled language. Explore the docs/getting-started page to see how to configure your first C# agentic session.

💡 Ideas+🐛 BugsSuggest a feature or report a bug