"Missing file" link error with TFS build

Hi,

We are trying to build automatically one VS 2005 solution containing various VC++ project (one exe and several dlls). This solution and its projects make use of custom configuration (this help us to define various preprocessor #defines used in our C++ code).
When building this solution with one configuration through via VS 2005 on a desktop computer, everything builds fine. But after creating a TFS build type and running it on the build server we see this error:

LINK(0,0): error LNK1104: cannot open file 'D:\Build\RootFolder\TFSProjectName\BuildTypeName\Binaries\PlatformName\ConfigurationName\DesignerLocale.lib' (D:\Build\RootFolder being our build directory path)

It is strange that TFS build look for lib files in the 'D:\Build\RootFolder\TFSProjectName\SolutionName\Binaries...' directory since all our projects are configured so they generate the compilation output into D:\Build\RootFolder\TFSProjectName\BuildTypeName\Sources\TFSProjectName\Bin\ConfigurationName

I guess we are missing something or does TFS build hardcode the usage of the "Binaries" output directory and overwrite solution and projects settings?

Best Regards.

[1207 byte] By [GDigrego] at [2008-2-25]
# 1
That's right - all the compiled output generated is dropped into the Binaries folder by Team Build. That explains why the build looks for the files there
Anutthara at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Build Automation...
# 2

Really? Does this means any solutions that needs to build with TFS Build will have to use the same convention and hard-code usage of the "Binaries" directory? There is now way to tell TFS Build to look for files in output directories specified in projects files?

When I look at my TFS Build machine, the compilation output goes to the directories we have specified in vcproj projects. These directories being created by TFS below the build directory path we have specified in the build type. This is OK for us.

But at link time, TFS build search in the "Binaries" directory for the lib files the current built vcproj project has dependencies on and can't find them as the Binaries directory remains always empty in our case. Is this a TFS build bug or can we solve that modifying the appropriate file(s) (vcproj files, build type xml file, etc)?

Thanks for helping us solving this issue.

GDigrego at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Build Automation...
# 3

GDigrego,

You can use AdditionalReferencePath item (inside tfsbuild.proj) to include any folder. The folder specified by the AdditionalReferencePath will be used to resolve references. For additional details, please refer the post -

http://blogs.msdn.com/manishagarwal/archive/2006/01/04/509125.aspx

Hope it helps

ManishAgarwal at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Build Automation...
# 4

I've did some investigation again and find out that TFS build seems to ignore the "Additional Library Directories" settings of our .vcproj project.

I understand that it is possible to repeat this information in the build type XML file by adding some "AdditionalReferencePath" tags but we don't like this solution since:

1- We will need to duplicate this information and this will be error prone and not that nice for project maintenance

2- Our projects have several configurations defined that use different values for the "Additional Library Directories" setting. I'm not sure the same can be achieved using "AdditionalReferencePath" tags in the build type xml so the path are different depending the configuration being built.

Also, looking at other messages in this forum (see links below), we are not the only one having issues with includes/libraries/etc file references in VC projects . It happears to me that TFS seems not ready for handling C++ projects correctly.

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=367165&SiteID=1

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=319570&SiteID=1

We are still looking for a solution for this problem :(

GDigrego at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Build Automation...
# 5

Hello,

After a long pause I'm again back fighting to solve this issue. I've tried to solve it using the "AdditionalReferencePath" tag as suggested but had no success.
Looking at the build log, I've noticed the following things that might help you in helping me:

- As a reminder, the error message I get is:

Linking...
LINK : fatal error LNK1104: cannot open file 'D:\Build\FiRE_Project\FiRE\FiRE Only\Binaries\Win32\Debug\OT602Res.lib'
Build log was saved at "file://d:\Build\FiRE_Project\FiRE\FiRE Only\Sources\FiRE\Utilities\Debug\BuildLog.htm"
Utilities - 1 error(s), 0 warning(s)

- My additional path seems to be taken into account since I can find the following text in the log

Initial Items:
AdditionalReferencePath
D:\Build\FiRE_Project\FiRE\FiRE Only\Sources\FiRE\Lib\Debug\

- MS Build is creating on the fly a temporary version of the project that fails to link. Could somebody explain me why this is happening?

Using "CreateTemporaryVCProject" task from assembly "Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
Task "CreateTemporaryVCProject"
MSBuild is creating a temporary VC project file "D:\Build\FiRE_Project\FiRE\FiRE Only\Sources\FiRE\_Workspace\..\utilities\utilities.tmp_Debug_Win32.vcproj" for the project "D:\Build\FiRE_Project\FiRE\FiRE Only\Sources\FiRE\_Workspace\..\utilities\utilities.vcproj", with project references replaced by assembly references. This step is necessary to resolve project references of this project. If you want to avoid this step in the future, please use file references instead of project references in this project.

- I've checked and the missing lib exists in fact in my additional ref path (D:\Build\FiRE_Project\FiRE\FiRE Only\Sources\FiRE\Lib\Debug\), but somehow MS BUILD resolve it to another location (using the default "Binaries" folder)

VC project reference "D:\Build\FiRE_Project\FiRE\FiRE Only\Sources\FiRE\_Workspace\..\OT602Res\OT602Res.vcproj" resolved as "D:\Build\FiRE_Project\FiRE\FiRE Only\Binaries\Win32\Debug\OT602Res.lib".

PS: I can send a copy of the full log if required

Thanks for your help,
Gaetano

GDigrego at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Build Automation...
# 6

MSBuild always creates temporary versions of VC++ projects, since *.vcproj files predate MSBuild and are not MSBuild project files. Typically this process is transparent and the temporary MSBuild project file is stored only in memory within the MSBuild process. My understanding is that when a VC++ solution includes project-to-project references, one or more of the temporary projects may need to be written to disk to resolve the references - this is what you are seeing with the CreateTemporaryVCProject task execution.

Not sure about your AdditionalReferencePath issue - will try to look into it and get back to you.

-Aaron

AaronHallberg at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Build Automation...
# 7

Hello Aaron,

Have you had a chance to look at the AdditionalReferencePath issue?

Thanks,

Gaetano.

GDigrego at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Build Automation...
# 8

Sorry, but I have not. I will take a look at this tomorrow and get back to you.

-Aaron

AaronHallberg at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Build Automation...
# 9

OK – first I’d like to go through some of the issues raised during this thread.

(1) “I guess we are missing something or does TFS build hardcode the usage of the "Binaries" output directory and overwrite solution and projects settings?”

Team Build overrides the OutDir property used by MSBuild in compiling managed code projects, and the OutputDirectory used by VCBuild in compiling VC++ projects (confusingly, this property is referred to as OutDir within Visual Studio).This is done because Team Build needs the binaries to be in a well-known location for other build steps, such as running automated tests and copying binaries to the drop location.

This should not mean, however, that you need to “…hard-code usage of the ‘Binaries’ directory” in your project settings.In general, you should be able to use paths relative to the OutDir property effectively on both development machines and the build machine.If you have specific questions regarding this issue, please let me know and I should be able to help.

(2) “When I look at my TFS Build machine, the compilation output goes to the directories we have specified in vcproj projects. These directories being created by TFS below the build directory path we have specified in the build type.”

I am pretty confused by this – are your binaries really going into the directories specified in your vcproj files?As mentioned above, Team Build overrides the output directory such that your binaries should end up in a common location.Perhaps here you are referring to the intermediate directories, rather than the output directories?

(3) “But at link time, TFS build search in the "Binaries" directory for the lib files the current built vcproj project has dependencies on and can't find them as the Binaries directory remains always empty in our case.”

Team Build uses as the output directory something like this:

<Build Directory Root>\<Team Project>\<Build Type>\Binaries\<Platform>\<Configuration>

I assume this is what you mean by the Binaries directory.Is this directory really empty in your case?This should not be the case unless (a) you are overriding the OutDir property yourself in TfsBuild.proj, or (b) your build is failing very quickly and not generating any outputs.

(4) “You can use AdditionalReferencePath item (inside tfsbuild.proj) to include any folder.”

This is not correct.AdditionalReferencePath can be used to resolve references in managed code, but not to specify additional library directories for VC++ projects.

(5) “I've did some investigation again and find out that TFS build seems to ignore the "Additional Library Directories" settings of our .vcproj project.”

Why do you think Team Build is ignoring your vcproj additional library directories?This should not be the case…

(6) OK – so how do you fix your build?

I suspect that you have a hard link to OT602Res.lib in your project settings for Utilities.vcproj.To check this, look in the Property Pages for Utilities.vcproj under Configuration Properties \ Linker \ Command Line for something like $(OutDir)OT602Res.lib.Remove this reference, and instead use a project reference (which you can add in the Property Pages under Common Properties \ References).

I hope this helps – let me know if I incorrectly diagnosed your issue, if you have other questions, etc.

-Aaron
AaronHallberg at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Build Automation...
# 10

Hello Aaron,

I'm having the same problem with my C++ projects, that is: The library projects' output does not end up in the <Build Directory Root>\<Team Project>\<Build Type>\Binaries\<Platform>\<Configuration> folder, instead it is located under the project themselves /<project>/(debug or release).

This gives me the following error:
LINK(0,0): error LNK1181: cannot open input file 'c:\build\<team project>\CI\Binaries\Mixed Platforms\Release\<project>.lib'

I have the project as a reference to the client project.

It seems as though the TFS build override doesn't work. If I check the build log, I see this line:

C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\..\..\vc\vcpackages\vcbuild.exe /override:"c:\build\<team project>\CI\BuildType\TFSBuild.vsprops" "c:\build\<team project>\CI\Sources\Modules\<project>\<project>.vcproj" "Release|Win32"

and the TFSBuild.vsprops contains:

<VisualStudioPropertySheet ProjectType="Visual C++" Version="8.00" Name="Team Build Overrides" OutputDirectory="c:\build\<team project>\CI\Binaries\Mixed Platforms\Release\">

So: Why doesn't the output end up in the binaries folder, I assume that this is the problem?

Regards
/Jakob

JakobEhn at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Build Automation...
# 11

Does anyone have an answer for this? We can't get our build process to work when we have solutions with
C++ projects, because of this issue!

Very grateful for any help on this!

Regards

/Jakob

JakobEhn at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Build Automation...
# 12

Hello Jakob. I had been puling my air out most of the day with this very issue. Many thanks to you and Aaron for continuing this thread for as long as you have. Aaron's solution regarding using project references worked for me regarding including LIB files built from other projects within the same solution. I actually had to try it twice, though.

Aaron mentions first finding the LIB files that your individual projects are referenceing which likely read $(OutDir)File.lib from the Linker Inputs section. My first attempt involved just removing the $(OutDir) portion. Then I re-read the post and saw it was saying I should completely remove the entry from the Linker Inputs area. (Rection = "You want me to do what?!" I had never really dealt with the Project References area for a C++ application before.) Much to my surprise, the linker reference worked with just the Project References entry.

Anyway, I hope the detail I provided was enough to get you moving along as I am now able to. Right after I enter this I am also entering another submission regarding problems with Custom Build Steps directly on files within a C++ project (as opposed to custom build steps & events at the project level, which seem to work file.)

Good luck

John Garland

JohnGarland at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Build Automation...
# 13

Hi John, Hi Aaron

I' m currently fighting trying to set up an automated build of a large c++ solution, > 20 vc project. We create an exe that uses various dll's, part of these dll's are using some with these dll's. We output the exe and dll in a bin directory, that's to say we change the default $(OutDir), the lib files are output in a lib directory.

I can build, link is more correct, what I call level 0 dll, that's to say the one that don't depend on another dll. Once I reach the level 1 dll, the compilation fails with this "missing file" error.

If I add the dll and lib files of level 0 in bin and lib directories as source controlled element, I can built the level 1 dll, but not the level 2 ! It is really like MSBuild can't link the newly created dll's but can link the "older" ones.

Any comment will be welcome !

Pierre

pmedart at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Build Automation...
# 14

Pierre - the silver bullet for me was the change from actually specifying LIB references in my project output to switching over to use the new Project References tool in VS2005. When using TFSBuild, TFS "hijacks" the OutDir for each project that is built. Your OutDir paths are replaced by what TFS sees fit to use, so depending on your project's build to put dependency files in the "right place" ceases to work, hence the need to switch to use the alternate Preject References area.

I don't know if you've tried making the change from entering the link references in the Project properties yet or not. If not, give i t atry and see if things work out for you.

--John

JohnGarland at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Build Automation...

Visual Studio Team System

Site Classified