views:

1163

answers:

10

I have a project that builds fine If I build it manually but it fails with CC.NET.

The error that shows up on CC.NET is basically related to an import that's failing because file was not found; one of the projects (C++ dll) tries to import a dll built by another project. Dll should be in the right place since there's a dependency between the projects - indeeed when I build manually everything works fine (Note that when I say manually I am getting everything fresh from source code repository then invoking a Rebuild from VS2005 to simulate CC.NET automation).

looks like dependencies are ignored when the build is automated through CC.NET.

I am building in Release MinDependency mode.

Any help would be highly appreciated!

+1  A: 

Try building it from the command line and see what happens.

FlySwat
I didn't try this - any guess about possible explanation? I am going nuts
JohnIdol
I tried this - it fails with devenv - visual studio is using msbuild but I ignore the exact set of command line parmaeters
JohnIdol
A: 

I wonder if CC.Net is building with different environment variables, such that the necessary library directories aren't properly added to the path.

Is there any specific error message in the CC.Net build log as to why that particular DLL import failed? Could not find file? Permissions? Look in the detailed CC.Net build log for the failure and see where it differs from a normal command-line build.

HanClinto
yep - error is 'file not found'
JohnIdol
How do I check the cmd line for a solution build? I can see only cmd lines for single projects in the output when I build manually - same thing in the buildLog when CC.NET
JohnIdol
+1  A: 

My guess would be that the user that the service is configured has different permissions and/or environment variables as you do when actually running it. If you are on the same physical box and it compiles fine with visual studio and you are also using visual studio in CruiseControl (not MSBuild) then it is almost assuredly the user. If however you are using MSBuild in CruiseControl there is a huge set of diffrence when MSBuild (2.0) compiles a C++ sln and when Visual Studio compiles it. If you must use MSBuild on C++ solutions try v3.5 it has much more support for C++ solutions.

Alex
this is a good suggestion - but I am using the same user the service is registered to, thus environment variables are the same
JohnIdol
BTW - I am using Visual Studio to build, both manually and through cc.net
JohnIdol
DId you search the machine to see if possibly the dll is being built but being output to somewhere other than where you expect? If it is you could change the output in the soloution properities.
Alex
it's being built in the right place (output directory) when building manually - it's just that building with devenv the build order (dependencies) semms to be ignored it fails
JohnIdol
John Build Order and Dependencies are two differnt things. Build Order will be ignored from the command line. You actually need to set the dependencies. Although in 2008 they seem to be more tied. You actually need to set each projects dependencies in order to ensure this works.
Alex
I know build order and dependencies are the same thing - in fact the only way you have to affect the build order is setting dependencies project by project. I probably expressed what I meant in a convoluted way.
JohnIdol
+1  A: 

After a long investigation - my understanding on this at current stage is that the problem is related to the fact that I am using devenv to build through CruiseControl.NET but when I build manually VisualStudio is using msbuild.

Basically this causes dependencies to be ignored (because of some msbuild command arg that I am not reproducing using devenv).

I think the fact that dependencies are set between C++ projects is relevant too to some extent, since I've been able in other occasions to build properly with CC.NET setting dependencies between .NET projects and C++ projects.

In order to figure out exactly what is generating this different behavior I'd have to follow this lead.

I'd like to hear other people's opinions on this.

JohnIdol
+2  A: 

Can you change CC to use msbuild instead of devenv? That seems like the optimal solution to me, as it means the build is the same in both situations.

Herms
this would be ideal solution in this case - I'd certainly do that If I didn't get it building already with a shameless hack (and I prefer to use devenv 'cause I am using it for everything else - a shitload of projects)
JohnIdol
A: 

I've run into instances where my solution builds if I open it in the IDE and compile, but fails if I run from a command line (either msbuild or devenv.) In each case, the problem was due to a bad reference - likely from paths not matching between your local box and the build server. You see it compile in the IDE correctly because VisualStudio, when opening a solution, will attempt to auto-resolve broken paths. When it does this, it won't tell you about it and usually won't change your solution and project files (which is what you'd hope for.)

Try opening your solution file and/or project files in a text editor and make sure all relative paths are valid.

Pedro
A: 

As Alex said, I think that your problem is that the CC.NET service runs as a local user account. Unfortunatly some of the C++ environment variables are per user and will not be carried over to the default build environment. In my case it was the lib and include files defined in Tools -> Options -> Projects and Solutions -> VC++ Directories. This same issue evidently causes other issues and is called out in this article as a yellow block.

My solution was to create a new user (BuildUser) on the build machine specifically for building. The key was to then log in as BuildUser and set up the environment. Finally, I changed the CC.NET service to login as BuildUser and restarted it.

A: 

(reposting as my initial post seems to have failed)

VC2003 seems to have an inconsistency between dependencies and input libraries.

An example:

  • ProjectA --> A.lib
  • ProjectB --> B.exe
    • In Properties-->Linker-->Additional Input Libraries, A.lib is specified.
    • In Project Dependencies, ProjectA is unchecked (why it is not automatic is still a mystery to me)

When cleaning ProjectB, A.lib is not deleted, nor is it rebuilt when ProjectB is compiled. So the build appears to succeed in your local machine.

CC.NET starts from scratch, and the build fails as A.lib is not found in the first place.

Fox
A: 

JohnIdol:

Were you able to resolve this issue? I am having a similar issue, I can build with no errors when building within the VS dev env IDE. But when I run the batch file for carrying on the same with the same set of environment variables using Visual Studio 2008 command line it fails to locate the libraries. These libraries are provided on the Tools-->Options-->Projects and Solutions-->VC++ Directories setting. I am using vc9.0 on XP. Following are the commands that I am using embedded in a bat file:

call "C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\vsvars32.bat"

devenv.com "C:\blah\blah...\blah.sln" /useenv /build "Debug" /out "C:\blah\blah...\qmt\qmt_debug\qmt_qmt_debug_debug_2009_11_11_12_32_53.txt"

When I manually set all the libraries using set and run this then again I am able to build it. However I am wondering why it is not setting the library paths using the Visual Studio environment?

Any help would be greatly appreciated.

Thanks in advance!

knight
A: 

Damn it folks, disregard my question, my bat file was in error and using /useenv switch which was causing it to use the local LIB, INCLUDE and PATH environment variables instead of VC++ specified aforementioned variables.

Thanks!

knight