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

Notification

Icon
Error

Custom configuration with preprocessor directives fails to build
cadbooster
#1 Posted : Tuesday, September 16, 2025 2:15:08 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 10/20/2021(UTC)
Posts: 6
Location: Netherlands

We have a solution with three configurations: Debug, Release, NoLicense. NoLicense is a release build with all licensing code removed using preprocessor directives.

This License class is completely disabled:



NCrunch works fine when the project is in Debug or Release, but fails to build in NoLicense. The project builds fine in Visual Studio. Any idea on how to fix this or where to look?

Remco
#3 Posted : Wednesday, September 17, 2025 12:18:06 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,380

Thanks: 997 times
Was thanked: 1343 time(s) in 1246 post(s)
Hi, thanks for posting.

When you switch between build configurations, how are you handling this in NCrunch? Do you use the 'Use Build Configuration' setting? Note that NCrunch doesn't track the selected build configuration in the IDE - it will always use the project's default configuration.
cadbooster
#4 Posted : Wednesday, September 17, 2025 8:14:49 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 10/20/2021(UTC)
Posts: 6
Location: Netherlands

Hi Remco,

In the NCrunch Configuation, "Use build configuration" is set to empty. In the project file, we start with Debug. I believe the first one is the default?

<Configurations>Debug;Release;NoLicense</Configurations>

NCrunch gives these errors when we switch Visual Studio to the NoLicense configuration.
Remco
#5 Posted : Wednesday, September 17, 2025 11:59:02 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,380

Thanks: 997 times
Was thanked: 1343 time(s) in 1246 post(s)
The actual default depends on how the project is designed. I suspect you're encountering a variation of this problem, though I find the symptoms a bit strange and it makes me wonder if perhaps you have other build logic or package references dependent on the configuration.

Try setting NCrunch's 'Use Build Configuration' to 'NoLicense' to see if this makes any difference for you.
cadbooster
#6 Posted : Thursday, September 18, 2025 10:12:36 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 10/20/2021(UTC)
Posts: 6
Location: Netherlands

Good guess. We do indeed have a configuration-dependent package:



Setting 'Use build configuration' to NoLicense helped it get further into the build. I then had to add NCrunch conditionals to some post-build tasks and then it compiled!

Does that mean that NCrunch tries to build the Debug config, but Visual Studio only activates the NoLicense code?
Remco
#7 Posted : Friday, September 19, 2025 12:35:34 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,380

Thanks: 997 times
Was thanked: 1343 time(s) in 1246 post(s)
cadbooster;18331 wrote:

Does that mean that NCrunch tries to build the Debug config, but Visual Studio only activates the NoLicense code?


Sort of. In this case it's most probably an inconsistency between the dependency data from Visual Studio (project.assets.json) and the build configuration.

I expect VS would likely set up its dependency data according to the selected build configuration in the IDE. NCrunch relies on this data to be fed downstream because it can't safely generate it itself. When you have dependencies from one build configuration being fed into a build system running on a different build configuration, weird stuff can happen.

Try to keep your NCrunch build configuration identical to the one selected in VS. If you continue to have problems, I recommend adjusting your logic so that your dependencies are the same between configurations but your code is different (i.e. use compiler conditionals instead of build conditions).
cadbooster
#8 Posted : Friday, September 19, 2025 7:57:35 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 10/20/2021(UTC)
Posts: 6
Location: Netherlands

Got it. I'll keep the build conditions for now because I need to keep the license package out of the build at any cost. But now I know how to get the NoLicense configuration to build, so I can check that manually from time to time.

Thanks for all the help :)
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.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download