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.
Build/Test Issues
NCrunch environment variable not set when evaluating PackageReferences
Started by kimbirkelund on 2,016 views
Remco NCrunch Developer
#13495
09 May 2019 23:04 UTC
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?
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?
Ok. Not much you can do then :)
However there was an environment variable I could set, so got it to work.
However there was an environment variable I could set, so got it to work.
Post a reply
Log in to reply.