Can't reference a C# project from a C++ project

In a previous question I thought this was a sub-project problem but its much simpler than that.

Basically if you reference a C# project from a C++ one, when the sln2005 build runner comes to build the C++ project it can't find the C# project and so the build fails.

Here is the vcproj file for the C++ project:

    <References>
        <AssemblyReference
            RelativePath="System.dll"
            AssemblyName="System, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
        />
        <AssemblyReference
            RelativePath="System.Data.dll"
            AssemblyName="System.Data, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86"
        />
        <AssemblyReference
            RelativePath="System.XML.dll"
            AssemblyName="System.Xml, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
        />
        <ProjectReference
            ReferencedProjectIdentifier="{01945453-41AF-4DB1-A10A-118AF8AF78BF}"
            RelativePathToProject=".\Relational\Relational.csproj"
        />
    </References>

The RelativePathToProject is relative to the solution not to the vcproj so whilst it can be built in VS from the solution, when attempting the same thing using the build runner the reference can't be resolved.

Has anybody got any ideas as to how to solve this? If I can't fix it I'm going to have to give up on the whole TeamCity project. Help!!

Many thanks,

Daniel Graham

5 comments
Comment actions Permalink

Can you build your solution using msbuild from console? If not, could you please try changing the value
of RelativePathToProject to be relative to .vcproj file folder.

Thanks!

0
Comment actions Permalink

No - I get the same error.

The MSBuild command line we used is:
MSBuild Foundation.sln /t:Build /property:Configuration=Release;Platform="Any CPU"

It runs to the same point and falls over with the same error.

If I then open the solution in Visual Studio from the directory downloaded by TeamCity, set to "Release" and "Any CPU" - the solution builds perfectly. Running the MSBuild command line above again after this, unsurprisingly, works.

From the logs, MSBuild and Visual Studio both use cl.exe to compile the C++, where the sln2005 build runner uses vc.exe - not that this makes any difference.

Using MSBuild, I have tried the following RelativePathProjects in the vcproj file:
            RelativePathToProject=".\Relational\Relational.csproj"
            RelativePathToProject=".\..\Relational\Relational.csproj"
            RelativePathToProject=".\..\..\Relational\Relational.csproj"
but this has made no difference.

I manually checked the ReferencedProjectIdentifier against the one stored in the Relational.csproj and they are the same.

Thanks for your help so far - much appreciated.

0
Comment actions Permalink

Some additional information.

This is the beginning of a working build from the log file:

Copying 'c:\TeamCity\buildAgent\work\70320e3b892ce449\Foundation\Relational\bin\Release\IKVM.OpenJDK.ClassLibrary.dll' to target directory...
Copying 'c:\TeamCity\buildAgent\work\70320e3b892ce449\Foundation\Relational\bin\Release\IKVM.Runtime.JNI.dll' to target directory...
Copying 'c:\TeamCity\buildAgent\work\70320e3b892ce449\Foundation\Relational\bin\Release\IKVM.Runtime.dll' to target directory...
Copying 'c:\TeamCity\buildAgent\work\70320e3b892ce449\Foundation\Relational\bin\Release\jt400_5_3.dll' to target directory...
Copying 'c:\TeamCity\buildAgent\work\70320e3b892ce449\Foundation\Relational\bin\Release\jt400_6_2.dll' to target directory...
Copying 'c:\TeamCity\buildAgent\work\70320e3b892ce449\Foundation\Relational\bin\Release\db2jcc4.dll' to target directory...
Copying 'c:\TeamCity\buildAgent\work\70320e3b892ce449\Foundation\Relational\bin\Release\Support.dll' to target directory...
Copying 'c:\TeamCity\buildAgent\work\70320e3b892ce449\Foundation\Relational\bin\Release\Support.pdb' to target directory...
Copying 'c:\TeamCity\buildAgent\work\70320e3b892ce449\Foundation\Relational\bin\Release\ojdbc6.dll' to target directory...
Copying 'c:\TeamCity\buildAgent\work\70320e3b892ce449\Foundation\Relational\obj\Release\Relational.dll' to target directory...
Copying 'c:\TeamCity\buildAgent\work\70320e3b892ce449\Foundation\Relational\obj\Release\Relational.pdb' to target directory...
Creating temporary file "c:\TeamCity\buildAgent\work\70320e3b892ce449\Foundation\track unicode db agnostic\xtab2\Release\RSP00001418722484.rsp" with contents
[
/O2 /GL /I "C:\TeamCity\buildAgent\work\70320e3b892ce449\Foundation\\track unicode db agnostic\utils" /I "C:\TeamCity\buildAgent\work\70320e3b892ce449\Foundation\\track unicode db agnostic\math" /I "C:\TeamCity\buildAgent\work\70320e3b892ce449\Foundation\\track unicode db agnostic\calc_parser" /D "WIN32" /D "NDEBUG" /D "UK_CO_DWL__LIBS__XTAB__BUILDING" /D "PIC" /D "_CRT_SECURE_NO_WARNINGS" /D "_WINDLL" /D "_UNICODE" /D "UNICODE" /FD /EHsc /MD /Fo"Release\\" /Fd"Release\vc80.pdb" /W3 /c /Zi /TP /wd4251 /wd4996 /wd4793 /wd4835

This is the beginning of the breaking build from the log file:

Creating temporary file "c:\TeamCity\buildAgent\work\70320e3b892ce449\Foundation\track unicode db agnostic\xtab2\Release\RSP00000114083300.rsp" with contents
[
/O2 /GL /I "C:\TeamCity\buildAgent\work\70320e3b892ce449\Foundation\\track unicode db agnostic\utils" /I "C:\TeamCity\buildAgent\work\70320e3b892ce449\Foundation\\track unicode db agnostic\math" /I "C:\TeamCity\buildAgent\work\70320e3b892ce449\Foundation\\track unicode db agnostic\calc_parser" /D "WIN32" /D "NDEBUG" /D "UK_CO_DWL__LIBS__XTAB__BUILDING" /D "PIC" /D "_CRT_SECURE_NO_WARNINGS" /D "_WINDLL" /D "_UNICODE" /D "UNICODE" /FD /EHsc /MD /Fo"Release\\" /Fd"Release\vc80.pdb" /W3 /c /Zi /TP /wd4251 /wd4996 /wd4793 /wd4835

So the only thing different here, is the copying of the assemblies from the Relational directory.

Here is the next step from the log for the working build:

Creating command line "cl.exe @"c:\TeamCity\buildAgent\work\70320e3b892ce449\Foundation\track unicode db agnostic\xtab2\Release\RSP00001418722484.rsp" /nologo /errorReport:prompt"
Creating temporary file "c:\TeamCity\buildAgent\work\70320e3b892ce449\Foundation\track unicode db agnostic\xtab2\Release\RSP00001518722484.rsp" with contents
[
/O2 /GL /I "C:\TeamCity\buildAgent\work\70320e3b892ce449\Foundation\\track unicode db agnostic\utils" /I "C:\TeamCity\buildAgent\work\70320e3b892ce449\Foundation\\track unicode db agnostic\math" /I "C:\TeamCity\buildAgent\work\70320e3b892ce449\Foundation\\track unicode db agnostic\calc_parser" /D "WIN32" /D "NDEBUG" /D "UK_CO_DWL__LIBS__XTAB__BUILDING" /D "PIC" /D "_CRT_SECURE_NO_WARNINGS" /D "_WINDLL" /D "_UNICODE" /D "UNICODE" /FD /EHa /MD /Fo"Release\\" /Fd"Release\vc80.pdb" /W3 /c /Zi /clr /TP /wd4251 /wd4996 /wd4793 /wd4835 /FU "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll" /FU "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll" /FU "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.XML.dll" /FU "c:\TeamCity\buildAgent\work\70320e3b892ce449\Foundation\Relational\obj\Release\Relational.dll"

And here is the same step for the breaking build:

Creating command line "cl.exe @"c:\TeamCity\buildAgent\work\70320e3b892ce449\Foundation\track unicode db agnostic\xtab2\Release\RSP00000114083300.rsp" /nologo /errorReport:queue"
Creating temporary file "c:\TeamCity\buildAgent\work\70320e3b892ce449\Foundation\track unicode db agnostic\xtab2\Release\RSP00000214083300.rsp" with contents
[
/O2 /GL /I "C:\TeamCity\buildAgent\work\70320e3b892ce449\Foundation\\track unicode db agnostic\utils" /I "C:\TeamCity\buildAgent\work\70320e3b892ce449\Foundation\\track unicode db agnostic\math" /I "C:\TeamCity\buildAgent\work\70320e3b892ce449\Foundation\\track unicode db agnostic\calc_parser" /D "WIN32" /D "NDEBUG" /D "UK_CO_DWL__LIBS__XTAB__BUILDING" /D "PIC" /D "_CRT_SECURE_NO_WARNINGS" /D "_WINDLL" /D "_UNICODE" /D "UNICODE" /FD /EHa /MD /Fo"Release\\" /Fd"Release\vc80.pdb" /W3 /c /Zi /clr /TP /wd4251 /wd4996 /wd4793 /wd4835 /FU "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll" /FU "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll" /FU "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.XML.dll"

As can be seen the Relational.dll is missing from the end of that and so it all falls over.

Hope this helps.

0
Comment actions Permalink

Thanks for your pointer about MSBuild.exe that helped quite a bit pointing me in the right direction.

You'll forgive me for feeling a bit smug about this - but this was quite tricked, involved a lot of trial and error and web searching.

Basically MSBuild.exe is unable to handle this situation in any convenient fashion because it does not follow an identical building process to a build to the VS IDE. In particular it has real trouble compiling C++ projects that have references to C# projects. See here for more information: http://social.msdn.microsoft.com/Forums/en-US/msbuild/thread/f8f087fe-f820-490f-8872-5c8c5127ac46/#page:2 - (the first page starts with a slightly different problem which will be of interest to some as well I'm sure) - no doubt there are other differences between the builders too.

Brainstorming with a colleague we realised that you can use devnenv.exe itself as a build runner.
eg: devenv.exe foundation.sln /build "Release|Any CPU"

That worked! OMG! But ... without providing a log and it's asynchronous. All of which is a bit rubbish.

However - if you use devenv.com in place of devenv.exe (thankyou to this blog here ( http://weblogs.asp.net/soever/archive/2006/05/18/447014.aspx ) for that) - you get the log output to the console as well and thus it is also synchronous, perfect for TeamCity.

Problem solved!

0
Comment actions Permalink

Great!
I found out that we have an issue to support devenv.exe or .com as a build runner.
Could you please watch/vote for it at
http://www.jetbrains.net/tracker/issue/TW-5385
Thanks!

0

Please sign in to leave a comment.