I'm using GitVersion to automatically version my code. Specifically, I use the GitVersionTask NuGet package that installs an MSBuild task to extract the version information during every build. One of the things this task does is to "inject" a static class called GitVersionInformation. I access this in my code for things like displaying the version string in the About box and emitting version strings to the log file. In fact, the first thing my code does is write out some version strings using NLog:
Visual Studio is happy with this, and the code builds without issues - but not in NCrunch. In NCrunch, I get this:
LocalServer.cs (99, 53): 'GitVersionInformation' is inaccessible due to its protection level
LocalServer.cs (100, 53): 'GitVersionInformation' is inaccessible due to its protection level
LocalServer.cs (101, 51): 'GitVersionInformation' is inaccessible due to its protection level
LocalServer.cs (102, 52): 'GitVersionInformation' is inaccessible due to its protection level
LocalServer.cs (103, 61): 'GitVersionInformation' is inaccessible due to its protection level
LocalServer.cs (104, 57): 'GitVersionInformation' is inaccessible due to its protection level
LocalServer.cs (105, 71): 'GitVersionInformation' is inaccessible due to its protection level
Protection level? Probably not correct. It's a static internal class and Visual Studio is perfectly happy to compile that code. I guess there's some subtlety I'm not seeing about the MSBuild task. Any advice?
It's a .NET Standard 2.0 dll using the new project format (or actually, several) and none of them work in NCrunch. It's as if $(NCrunch) isn't defined in the build. If I set it unconditionally it works but that's no good.
Remco wrote:
What *did work* however was to set DisableGitVersionTask = true in custom build properties. I'm not clear on what the difference is effectively.
Sorry, I should have been more specific ... this was what I was trying to suggest doing :)
It's a bit concerning that the NCrunch environment variable isn't available in your build conditions. Something must be blocking this from your build system. Regardless, the Custom Build Properties can be used for overriding anything of this sort, and is probably a cleaner option.