Search code examples
c#asp.netvisual-studioxunit.net

How to change xUnit testing project from being non-user to user code


For some reasons, my testing project is considered non-user code according to the debug Modules. It's also optimized when it's built for Debug. As a result, the symbols are not loaded and all break points in the testing project are skipped. I have tried the solutions sHow do I remedy "The breakpoint will not currently be hit. No symbols have been loaded for this document." warning?:

  1. Set project build as for debug
  2. Manually load from the Modules
  3. Tried different options with the process to attach.
  4. Tried to change the property for the project (but VS 2022 is different from that the above link suggests)
  5. Deleted cache, clean, re-build
  6. Made sure the project is not excluded from loading symbols

Solution

  • In case this is helpful, I found that in the .csproj file there are some conditional settings that reverse the settings from the GUI. How these extra settings get there remains a puzzle, but the lesson maybe that the GUI cannot fully control the settings and the .csproj file can override it.

    <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
        <Optimize>True</Optimize>
        <DebugType>portable</DebugType>
      </PropertyGroup>
    
      <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
        <Optimize>False</Optimize>
        <DebugType>portable</DebugType>
      </PropertyGroup>