Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Unable to make NCrunch build anything with optimized code and without debugging symbols
Magnus Lidbom
#1 Posted : Tuesday, August 4, 2020 6:37:39 PM(UTC)
Rank: Member

Groups: Registered
Joined: 8/30/2012(UTC)
Posts: 19

Thanks: 3 times
Was thanked: 4 time(s) in 4 post(s)
I have tried everything I can think of and have been banging my head against the wall for hours with this problem now.
I'm to the point of having this csproj file and still NCrunch builds it with full debug info and optimizations disabled:

.csproj
Code:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <IsPackable>false</IsPackable>

    <Optimize>true</Optimize>
    <DebugType>none</DebugType>
    <DebugSymbols>false</DebugSymbols>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <Optimize>true</Optimize>
    <DebugType>none</DebugType>
    <DebugSymbols>false</DebugSymbols>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
    <DebugType>none</DebugType>
    <DebugSymbols>false</DebugSymbols>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="nunit" Version="3.12.0" />
    <PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
  </ItemGroup>

</Project>



Of course I have disabled "Instrument Output Assembly"

When I browse to the "workspace used for selected test" there is a pdb there staring me in the face. And when I open the dll in dotPeek this stares me in the face:

Code:

[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]


Please help. I really need this to work since I'm currently doing low level optimizations.
Remco
#2 Posted : Tuesday, August 4, 2020 11:50:05 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,140

Thanks: 795 times
Was thanked: 1050 time(s) in 1000 post(s)
Hi, thanks for posting.

When building the project, NCrunch always sets Optimize=false and DebugType=full (or DebugType=portable) to force the build system to compile the assembly in debug mode. This is done because many of the downstream features (i.e. code coverage, instrumentation, etc) rely on having debug information in order to work. It was introduced because we had many first time users experiencing problems with getting the product to work on incorrectly configured projects.

It's possible to override this behaviour using the 'Custom Build Properties' setting. Set Optimize=true and DebugType=portable in this setting and you'll get the result you're after, though you'll need to put things back again later if you want your NCrunch code coverage to work.
1 user thanked Remco for this useful post.
Magnus Lidbom on 8/5/2020(UTC)
Magnus Lidbom
#3 Posted : Wednesday, August 5, 2020 7:45:18 AM(UTC)
Rank: Member

Groups: Registered
Joined: 8/30/2012(UTC)
Posts: 19

Thanks: 3 times
Was thanked: 4 time(s) in 4 post(s)
Thank you!

That works like a charm :)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.036 seconds.