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

Notification

Icon
Error

NCrunch environment variable not set when evaluating PackageReferences
kimbirkelund
#1 Posted : Thursday, May 9, 2019 8:22:11 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/9/2019(UTC)
Posts: 2
Location: Denmark

Was thanked: 1 time(s) in 1 post(s)
I have a setup where I have a Directory.Build.props file next to my solution file in which I include the Nerdbank.GitVersioning nuget package. This package doesn't play well with NCrunch because it generates the assembly version based on git commits, and thus generates 0.0.0- when built by NCrunch, because it isn't in a git repository.

I've tried fixing this by adding Condition=" '$(NCrunch)' != '1' " to the PackageReference element, but it doesn't work. If I use a Condition like '0' == '1' the package is correctly excluded, so it must be the case that the NCrunch environment variable isn't set at the time the condition is evaluated.

Remco
#2 Posted : Thursday, May 9, 2019 11:04:29 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 5,646

Thanks: 734 times
Was thanked: 936 time(s) in 892 post(s)
Hi, thanks for sharing this issue.

The problem here is that the PackageReferences are resolved during the package resolution step, which is performed and controlled by VS, where NCrunch has no chance to introduce alternative logic.

The package restore step creates the project.assets.json file with the physical bindings to your package. To my knowledge, it isn't possible to introduce conditional logic inside this .json file .. and if you could, VS would wipe it out anyway the next time it restores packages.

The best approach here may be to examine the package to see if it provides any opportunity for disabling its build steps under NCrunch. Does the package have a property of some kind that you could inject to override it or disable it?
kimbirkelund
#3 Posted : Friday, May 10, 2019 10:52:32 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/9/2019(UTC)
Posts: 2
Location: Denmark

Was thanked: 1 time(s) in 1 post(s)
Ok. Not much you can do then :)

However there was an environment variable I could set, so got it to work.
1 user thanked kimbirkelund for this useful post.
Remco on 5/10/2019(UTC)
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.030 seconds.