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

Notification

Icon
Error

Passing build parameters
rhysw
#1 Posted : Friday, February 15, 2013 4:19:54 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 2/15/2013(UTC)
Posts: 2
Location: United Kingdom

I really need access to the '$(SolutionName)' parameter in my csproj file but it appears that when ncrunch builds and runs the project this parameter is not being set as expected.

Is there some change I can make to the ncrunchsolution or configuration that will either allow me to specify this value explicitly or get it from the 'original' solution?

Remco
#2 Posted : Friday, February 15, 2013 10:36:13 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
Hi, thanks for posting!

I wasn't aware that this property was in use - so I've made a note on the backlog to have support for it added in a future revision.

The best way to work around this problem will depend upon why you are making use of this build property. NCrunch specifically sets a number of environment variables inside its build process. You may be interested in used in the $(NCrunchOriginalSolutionDir) or $(SolutionDir) properties to try and infer the solution currently in use, then introduce an override in the project's own build logic to cater for the NCrunch use case. For example:

<PropertyGroup Condition="$(NCrunch) == '1' and $(NCrunchOriginalSolutionDir) == 'c:\projects\mysolution'">
<SolutionName>MySolutionName</SolutionName>
</PropertyGroup>
rhysw
#3 Posted : Monday, February 18, 2013 9:54:16 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 2/15/2013(UTC)
Posts: 2
Location: United Kingdom

Hello,

Thanks for this. Unfortunately the workaround won't work in our specific scenario because we have multiple solutions which have a reference to this (test) project. The project needs to build in a slightly different way depending on which solution is including it.

I guess I should clarify my issue. While it would certainly resolve our particular problem if the "SolutionName" variable was available, it might make a nice feature to be able to pass any build properties via the ncrunch configuration (rather than just Configuration and Platform).
i.e.
MSBuild.exe MyProj.proj /p:MyProperty=MyValue

Is there any chance of a hotfix? ATM this is preventing our purchase of 10x developer licenses (with another 10 to come later in the year)
Remco
#4 Posted : Monday, February 18, 2013 8:57:11 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
Thanks for the extra info. I have a workaround that should work for your situation using the current version of NCrunch. It's a bit creative, but I've just tried it out and it should be reliable.

The key problem is identifying inside the project file whether or not the build is running as part of a certain solution. There's no way to do this using environment variables in NCrunch, but we can infer logic based on file paths.

Normally, NCrunch doesn't copy solution (.sln) files to the workspaces of projects being built. However, you can easily tell it to do so using the 'Additional files to include' configuration option that exists at solution level. Inside each of your solutions, simply add a reference to the solution's .sln file using this configuration setting. In this way, NCrunch will copy the solution file into the workspace for each project when the project is being built, and we can then use the existence of this file to infer which solution is being used as part of the build, by introducing build logic into the project file like this:

<PropertyGroup Condition="$(NCrunch) == '1' and Exists('$(SolutionDir)\MySolution1.sln')">
<OutputPath>AlternativeDirectory</OutputPath>
</PropertyGroup>

Assuming that the 'MySolution1.sln' file is included in the 'Additional files to include' for the parent solution, it should exist at the path above whenever the project is being built as part of MySolution1. This means we can change any of the other build properties (such as the OutputPath) to implement alternative logic.

Provided MySolution2 does not include the solution file 'MySolution1.sln' in its Additional Files To Include, there's no way this can go wrong.

I hope this makes sense .. do let me know if it does the trick!


Cheers,

Remco
Remco
#5 Posted : Saturday, March 30, 2013 9:45:29 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
For anyone interested, support for $(SolutionName) has been introduced with the newly released version of NCrunch (v1.45).
JeremyR
#6 Posted : Thursday, June 20, 2013 12:26:25 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/20/2013(UTC)
Posts: 6
Location: United States of America

Remco;3903 wrote:
For anyone interested, support for $(SolutionName) has been introduced with the newly released version of NCrunch (v1.45).


I just downloaded this today, and after getting it to work well in a little prototyping project I tried applying it to our main project. I've have tracked down that $(SolutionName) is not working.

NCrunch->About lists me at version 1.45.0.12

Here is the error I'm getting when trying to sync:
"NCrunch was unable to load this project because it contains a file path that is structurally abnormal and cannot be handled. The file path specified in the project causing this error is: E:\source\Trunk\ProjectA\*Undefined*.proj.props"

Here is the offending line in my project file
<Import Project="$(SolutionDir)$(SolutionName).proj.props" />

I can replace the $(SolutionName) with the actual name and it starts working.
$(SolutionDir) appears to be working just fine.

Thanks for any help on getting this resolved quickly so I can actually use this during the 30 day trial.

Jeremy
Remco
#7 Posted : Thursday, June 20, 2013 7:42:38 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
Hi Jeremy -

I've just run some quick tests based on the scenario you've described. It looks as though $(SolutionName) is currently not being handled during project load, where NCrunch identifies the files a project requires in order to build. This will require a functional change to NCrunch to make it work.

There is a maintenance release due next month and I'll note this down to be fixed in the release. If you're concerned about having a full trial of the software and would prefer this to be on the new version, please contact me via the contact form after the maintenance release and I'll issue you with a new trial license.

Meanwhile, perhaps I can suggest a workaround to the problem? If you add the following code to the project involved, this should suppress the error:

<PropertyGroup Condition="$(SolutionName) == ''">
<SolutionName>_</SolutionName>
</PropertyGroup>

The null solution name (_) will prevent NCrunch from blowing up while trying to identify any files used by the .proj.props include file. A side-effect of this is that you'll need to include these files manually using the Additional files to include configuration setting. NCrunch will need to know about these files in order to build your project once it has been copied to an NCrunch workspace, and the null solution name will prevent it from recognising these files automatically.

Cheers,

Remco
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.056 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download