You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu下使用Rider创建C#项目及System引用异常问题求助

Fixing System Reference Issues in Rider (Mono vs .NET MSBuild Conflict)

Hey there, let’s work through this problem together—it’s super common when both Mono and the .NET SDK are installed side-by-side, and Rider ends up picking the wrong MSBuild toolchain. Here’s a step-by-step breakdown to get your C# console app running smoothly:

1. Ensure Rider uses the .NET SDK's MSBuild

First, we need to confirm Rider isn’t defaulting to Mono’s MSBuild:

  • Open Rider and go to Settings/Preferences (File → Settings on Windows/Linux, Rider → Preferences on macOS)
  • Navigate to Build, Execution, Deployment → Build Tools → MSBuild
  • Look for the list of detected MSBuild instances. Select the one labeled "dotnet-msbuild" (it should point to your .NET SDK installation path, e.g., /usr/local/share/dotnet/sdk/7.0.400/MSBuild.dll or C:\Program Files\dotnet\sdk\7.0.400\MSBuild.dll)
  • Uncheck any Mono-based MSBuild entries if they’re selected, then apply the changes.

2. Clear project and Rider caches

Stale caches often cause reference resolution issues:

  • In Rider, go to File → Invalidate Caches...
  • Select the option to "Invalidate and Restart"
  • While Rider is restarting, manually delete the bin, obj, and .idea folders from your project directory (these will get recreated fresh when you reopen the project)

3. Verify your project's .csproj configuration

Double-check your project file to make sure it’s targeting a modern .NET runtime, not a Mono-specific framework:

  • Open your project’s .csproj file in Rider
  • Ensure the <TargetFramework> element specifies a .NET SDK version you have installed, like:
    <TargetFramework>net6.0</TargetFramework>
    
  • Remove any lines that force Mono usage, such as <UseMonoMSBuild>true</UseMonoMSBuild> if present.

4. Validate your .NET SDK setup outside Rider

Let’s rule out issues with your .NET installation itself:

  • Open a terminal/command prompt and run dotnet --version—this should return a valid version number (e.g., 7.0.400)
  • Navigate to your project directory and run dotnet build. If this completes successfully, the problem is definitely with Rider’s configuration (go back to step 1 to recheck MSBuild selection)
  • Ensure your system’s PATH environment variable lists the .NET SDK directory before any Mono directories. This ensures tools like dotnet take priority over Mono equivalents.

5. Reset Rider's MSBuild detection (last resort)

If none of the above works, reset Rider’s MSBuild tool detection:

  • Close Rider completely
  • Locate Rider’s configuration directory:
    • Windows: %APPDATA%\JetBrains\Rider<your-version>
    • macOS: ~/Library/Application Support/JetBrains/Rider<your-version>
    • Linux: ~/.config/JetBrains/Rider<your-version>
  • Delete the msbuild folder inside this directory
  • Reopen Rider—it will re-scan your system for MSBuild tools, and you can reselect the dotnet-msbuild instance as in step 1.

If you still run into issues after these steps, feel free to share more details about your OS, .NET/Mono versions, and any specific error messages from the build output.

内容的提问来源于stack exchange,提问作者brainbuggged

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 07:20:16