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

Notification

Icon
Error

Using environment variables in additional files to include path
andcoll
#1 Posted : Thursday, September 15, 2016 9:17:36 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 9/15/2016(UTC)
Posts: 2
Location: Ireland

Hi,

Is it possible to use environment variables in the paths of files we specify in the "additional files to include" setting? When I try use them through the UI it complains that paths must be relative, and when I try add them to the .ncrunchproject file it doesn't seem to resolve them.

Relative paths are liable to break when we move things about.

Remco
#2 Posted : Thursday, September 15, 2016 9:26:13 AM(UTC)
Rank: NCrunch Developer

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

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

Thanks for posting!

There was some effort made to implement this, but it proved to be much more complicated than expected due to certain edge cases (such as absolute paths, which aren't allowed in this setting).

What do you need the environment variable for? Are you trying to work around a limitation?
andcoll
#3 Posted : Thursday, September 15, 2016 10:02:15 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 9/15/2016(UTC)
Posts: 2
Location: Ireland

Remco;9160 wrote:
Hi,

Thanks for posting!

There was some effort made to implement this, but it proved to be much more complicated than expected due to certain edge cases (such as absolute paths, which aren't allowed in this setting).

What do you need the environment variable for? Are you trying to work around a limitation?


we have files that we need to include in the root of our repository, we've got a $(SRCROOT) env variable that points to this. So instead of ..\..\..\..\..\..\includedfile.xyz we'd prefer $(SRCROOT)\includedfile.xyz.

We've had issues where we've had to change a lot of ncrunchproject files after refactoring as the relative paths are now different.

We use these same env variables in our csproj files, it would be great if we could use them for ncrunch too.
Remco
#4 Posted : Thursday, September 15, 2016 10:11:20 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
andcoll;9161 wrote:

we have files that we need to include in the root of our repository, we've got a $(SRCROOT) env variable that points to this. So instead of ..\..\..\..\..\..\includedfile.xyz we'd prefer $(SRCROOT)\includedfile.xyz.

We've had issues where we've had to change a lot of ncrunchproject files after refactoring as the relative paths are now different.

We use these same env variables in our csproj files, it would be great if we could use them for ncrunch too.


Understood. At the moment NCrunch can't handle such a scenario with this setting, but it should be possible to use MSBuild instead.

MSBuild does work with environment variables, and NCrunch uses MSBuild to establish files it needs to include. It is possible to use this as an alternative to the Additional files to include setting.

For example, including the following in your project file should work:

<ItemGroup Condition="'$(NCrunch)' == '1'">
<None Include="$(SRCROOT)\includedfile.xyz" />
<None Include="$(SRCROOT)\IncludedDir\*.*" />
</ItemGroup>

I don't believe it's possible to include an entire directory tree using a single expression in MSBuild (others may correct me if there is a way to do this), so there may be some limitations with this approach.
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.031 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download