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

Notification

Icon
Error

Additional NCrunch Build Properties
robmen
#1 Posted : Monday, October 15, 2018 10:40:30 PM(UTC)
Rank: Member

Groups: Registered
Joined: 5/6/2015(UTC)
Posts: 23
Location: United States of America

Thanks: 4 times
Was thanked: 1 time(s) in 1 post(s)
The "NCrunch Build Properties" page lists the "NCrunchOriginalSolutionDir" and "NCrunchOriginalProjectDir" properties. NCrunch v3.18 added "ProjectName" and "ProjectFileName" (thank you, very much). Should they be documented on that page? Are there perhaps any other properties available that aren't documented?

I ask because I'm looking for something like "NCrunchOriginalSolutionPath" and/or "NCrunchOriginalSolutionFileName" (I could create NCrunchOriginalSolutionPath using "$(NCrunchOriginalSolutionDir)$(NCrunchOriginalSolutionFileName)")?
Remco
#2 Posted : Monday, October 15, 2018 11:16:28 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi, thanks for posting.

It's possible now to see a list of all the properties NCrunch injects into your build system by setting your 'Log Verbosity' setting to 'Detailed', then examining one of your build tasks in the processing queue. Around all the other trace data, you'll find a small section that shows the property values NCrunch is overriding in the build and what their values are.

I thought about adding the ProjectName and ProjectFileName properties to the documentation, but I'm concerned that by doing so I might actually confuse people. Both of these properties are present during a normal build, and they'll be set to the name of the project being built. The change introduced to help with your build customisation involved simply overriding these back to the values that any other user would expect them to normally be, so unless someone was used to working with an older version of the product that didn't do this, they'd likely just see the result that they were expecting.

The "NCrunchOriginalSolutionDir" and "NCrunchOriginalProjectDir" properties only contain the directories of the respective foreground solution/project. I guess it wouldn't be hard to add a couple more properties here for the filenames, though we'd need a full release to introduce this. It should actually be possible to construct these values artificially using the $(SolutionName) and $(ProjectFileName) properties by just concatenating these at the end of the NCrunch values.
1 user thanked Remco for this useful post.
robmen on 10/15/2018(UTC)
robmen
#3 Posted : Monday, October 15, 2018 11:43:00 PM(UTC)
Rank: Member

Groups: Registered
Joined: 5/6/2015(UTC)
Posts: 23
Location: United States of America

Thanks: 4 times
Was thanked: 1 time(s) in 1 post(s)
Thanks for responding so quickly.

Remco;12761 wrote:

It's possible now to see a list of all the properties NCrunch injects into your build system by setting your 'Log Verbosity' setting to 'Detailed', then examining one of your build tasks in the processing queue. Around all the other trace data, you'll find a small section that shows the property values NCrunch is overriding in the build and what their values are.


I'll try digging through detailed logging again. There is a lot of (ahem) "detail" in there that it is easy to get lost. :)

Remco;12761 wrote:

I thought about adding the ProjectName and ProjectFileName properties to the documentation, but I'm concerned that by doing so I might actually confuse people. Both of these properties are present during a normal build, and they'll be set to the name of the project being built.


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?


Remco;12761 wrote:

The "NCrunchOriginalSolutionDir" and "NCrunchOriginalProjectDir" properties only contain the directories of the respective foreground solution/project. I guess it wouldn't be hard to add a couple more properties here for the filenames, though we'd need a full release to introduce this. It should actually be possible to construct these values artificially using the $(SolutionName) and $(ProjectFileName) properties by just concatenating these at the end of the NCrunch values.


The issue I'm having specifically is that $(SolutionName) is not getting defined when run by NCrunch in VS or, rather, it is getting set to "*undefined*" which is what MSBuild sets the values to when not run in VS. The problem a new custom build behavior we are trying to use needs access to the .sln file when building/debugging in VS. Since NCrunch is building/debugging outside VS, the custom build behavior breaks down and NCrunch doesn't work (obviously).

I know the details I provided are very vague. This is a new VS/MSBuild mechanism we've learned that looks like it will *greatly* simplify our development lives. Unfortunately, NCrunch breaks. If you want, I can provide the gory details but really it just comes down to needing the "SolutionPath" or "SolutionFileName" (since I can use "NCrunchOriginalSolutionDir" to create "SolutionPath").

I know its not fun to "propose timelines" but do you have any idea if/when "SolutionFileName" could be available in a full release? We'd make plans around your estimate. Thanks.
Remco
#4 Posted : Wednesday, October 17, 2018 12:10:14 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
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.msi
NCrunch_Console_3.23.0.1.zip
NCrunch_GridNodeServer_3.23.0.1.msi
NCrunch_GridNodeServer_3.23.0.1.zip
NCrunch_LicenseServer_3.23.0.1.zip
NCrunch_VS2008_3.23.0.1.msi
NCrunch_VS2010_3.23.0.1.msi
NCrunch_VS2010_3.23.0.1.zip
NCrunch_VS2012_3.23.0.1.msi
NCrunch_VS2012_3.23.0.1.zip
NCrunch_VS2013_3.23.0.1.msi
NCrunch_VS2013_3.23.0.1.zip
NCrunch_VS2015_3.23.0.1.msi
NCrunch_VS2015_3.23.0.1.msi.7z
NCrunch_VS2015_3.23.0.1.zip
NCrunch_VS2017_3.23.0.1.msi
NCrunch_VS2017_3.23.0.1.msi.7z
NCrunch_VS2017_3.23.0.1.zip

When 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\
1 user thanked Remco for this useful post.
robmen on 11/27/2018(UTC)
robmen
#5 Posted : Tuesday, November 27, 2018 9:23:23 PM(UTC)
Rank: Member

Groups: Registered
Joined: 5/6/2015(UTC)
Posts: 23
Location: United States of America

Thanks: 4 times
Was thanked: 1 time(s) in 1 post(s)
Very sorry, I forgot to follow up and let you know that these properties worked out perfectly for my scenario and made everything work. It's great.

I'll stay on this private build and look forward to when a new official release comes out with these new properties.

Thank you!
1 user thanked robmen for this useful post.
Remco on 11/27/2018(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.055 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download