robmen;12762 wrote:Hmm, I don't see ProjectName or ProjectFileName being set outside of NCrunch. In my prototypical project, I manually
set ProjectName to MSBuildProjectName so I can use ProjectName consistently everywhere. I always thought it was interesting you called the value "ProjectName" and not "NCrunchOriginalProjectName". Maybe I missed something somewhere?
My analysis shows that both the ProjectName and ProjectFileName properties are present in any standard .NET 4.7.2 project under VS2017. I haven't tested on other platforms, but both of these properties are quite familiar to me, so probably they've been around for a while. I don't really have any firm information about their history or intended usage.
We've only recently pushed out a release of NCrunch, and we're hoping we won't need to push another for a while yet. I've prepared the following dev build containing the properties you've asked for, along with some other stuff. I'll also include the planned documentation for this below the build links:
NCrunch_Console_3.23.0.1.msiNCrunch_Console_3.23.0.1.zipNCrunch_GridNodeServer_3.23.0.1.msiNCrunch_GridNodeServer_3.23.0.1.zipNCrunch_LicenseServer_3.23.0.1.zipNCrunch_VS2008_3.23.0.1.msiNCrunch_VS2010_3.23.0.1.msiNCrunch_VS2010_3.23.0.1.zipNCrunch_VS2012_3.23.0.1.msiNCrunch_VS2012_3.23.0.1.zipNCrunch_VS2013_3.23.0.1.msiNCrunch_VS2013_3.23.0.1.zipNCrunch_VS2015_3.23.0.1.msiNCrunch_VS2015_3.23.0.1.msi.7zNCrunch_VS2015_3.23.0.1.zipNCrunch_VS2017_3.23.0.1.msiNCrunch_VS2017_3.23.0.1.msi.7zNCrunch_VS2017_3.23.0.1.zipWhen executing a build, in addition to the the $(NCrunch) environment variable, NCrunch always sets several environment variables that can be used to gain more information about the origin of the project being built. Because NCrunch's workspacing of projects effectively detaches them from their parent solution, these variables can be useful when implementing custom build processes that need to consider NCrunch's behaviour.
NCrunchOriginalSolutionPath
The $(NCrunchOriginalSolutionPath) property will always be set equal to the full path of the foreground solution open in Visual Studio. Example: C:\Projects\MySolution\MySolution.sln
NCrunchOriginalSolutionDir
The $(NCrunchOriginalSolutionDir) property will always be set equal to the directory of the foreground solution open in Visual Studio, as opposed to $(SolutionDir), which NCrunch will set to the directory of the virtual solution within the project's workspace. Example: C:\Projects\MySolution\
NCrunchOriginalSolutionName
The $(NCrunchOriginalSolutionName) property will always be set equal to the file name of the foreground solution open in Visual Studio. Example: MySolution.sln
NCrunchOriginalProjectPath
The $(NCrunchOriginalProjectPath) property will always be set equal to the full path of the project file's original location in the foreground solution. Example: C:\Projects\MySolution\MyProject\MyProject.csproj
NCrunchOriginalProjectDir
The $(NCrunchOriginalProjectDir) property will always be set equal to the directory of the project file's original location in the foreground solution, as opposed to $(ProjectDir), which NCrunch will set to the directory of the virtual project within a workspace. Example: C:\Projects\MySolution\MyProject\