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

Notification

Icon
Error

Problem building a project with custom BeforeBuild target
hmemcpy
#1 Posted : Sunday, February 5, 2012 1:57:07 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 2/5/2012(UTC)
Posts: 4
Location: Czech Republic

Thanks: 1 times
Was thanked: 2 time(s) in 2 post(s)
Hi there!

I am using a trick I learned from @jfroma's blog, for automatically downloading missing nuget packages, so that I could keep the binaries out of the source control. This requires adding a custom BeforeBuild action in the csproj file:

Code:
<Target Name="BeforeBuild">
  <Exec Condition="Exists('$(ProjectDir)packages.config')"
          Command="&quot;$(SolutionDir)Tools\nuget.exe&quot; install &quot;$(ProjectDir)packages.config&quot; -o &quot;$(SolutionDir)Packages&quot;" />
</Target>


Unfortunately, it seems that NCrunch tries to execute this action even when I set in the configuration that Before/After build events for this projects should be disabled.
Since NCrunch copies the project to another location, the paths are no longer correct, and I get the following error:

Quote:
(89): The command ""C:\Users\<my username>\AppData\Local\NCrunch\7872\280\tools\nuget.exe" install "C:\Users\<my username>\AppData\Local\NCrunch\7872\280\<my project>\packages.config" -o "C:\Users\<my username>\AppData\Local\NCrunch\7872\280\Packages"" exited with code 3.


I must temporary comment out the BeforeBuild target in my csproj file to make this work.

Please help :)

Thanks!
hmemcpy
#2 Posted : Sunday, February 5, 2012 2:16:26 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 2/5/2012(UTC)
Posts: 4
Location: Czech Republic

Thanks: 1 times
Was thanked: 2 time(s) in 2 post(s)
Hmm, just as a quick FYI, apparently this feature is now built into Nuget, and it's possible to achieve without doing this! Here are the details: http://blog.davidebbo.co...p-nuget-to-restore.html

Still, it'd be nice if NCrunch could really ignore custom beforebuild/afterbuild targets.

Thanks,
Igal.
Remco
#3 Posted : Sunday, February 5, 2012 9:21:35 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 941 times
Was thanked: 1265 time(s) in 1177 post(s)
Hi Igal,

Thanks for posting! The pre/post build event suppression at the moment only applies to the pre/post build event properties. To suppress the beforebuild/afterbuild targets, you simply need to apply an MSBuild condition to them, as such:

<Target Name="BeforeBuild" Condition="$(NCrunch) != '1'">
<Exec Condition="Exists('$(ProjectDir)packages.config')"
Command="&quot;$(SolutionDir)Tools\nuget.exe&quot; install &quot;$(ProjectDir)packages.config&quot; -o &quot;$(SolutionDir)Packages&quot;" />
</Target>
1 user thanked Remco for this useful post.
hmemcpy on 2/6/2012(UTC)
hmemcpy
#4 Posted : Monday, February 6, 2012 4:18:48 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 2/5/2012(UTC)
Posts: 4
Location: Czech Republic

Thanks: 1 times
Was thanked: 2 time(s) in 2 post(s)
Oh sweet! I already switched to the more "standard" way of doing this (package restore), but good to know!

Thanks for the sweet product!
1 user thanked hmemcpy for this useful post.
Remco on 2/6/2012(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.653 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download