views:

116

answers:

1

I have an ASP.NET solution that builds just fine from within VS2008.

However , it fails when i do this :

MSBUILD.exe c:\path-to-sln 

It fails with a CS0006 error ("Metadata file 'dll_name' could not be found"). It also fails when I try with a .csproj of a project within the solution.

What is VS2008 doing that MSBuild is missing ? It is my understanding that VS knows about inter assembly dependencies that MSBuild cant. Is there any way I can inform MSBuild of these?

(I need MSBuild to work from the command line because I am calling it from an MSBuild-Task from within CruiseControl.Net.)

Thanks in Advance. :3)

(I have looked at http://stackoverflow.com/questions/280559/how-to-get-cmd-line-build-command-for-vs-solution , but still dont get it)

+1  A: 

you have to set the environment variables first before msbuild can work. the link you posted with the question actually has the answer (see the first answer entry).

one way you automate this is to choose which vcvars*.bat file you need, depending on which platform you wish to build an executable for. for example, if you want to build for x86, the vcvarsall.bat file says you would need bin\vcvars32.bat. you could copy this batch file, manually add your includes, lib and libpaths, and add the build step at the :end section of the batch file, like so:

...
(batch file contents go here)
:end
MSBUILD.exe c:\path-to-sln 

after that, you can just tell whatever program you are trying to build from to run the batch file you just created.

maranas
Thanks for your answer. I dont understand this part of your answer though : "manually add your includes, lib and libpaths".what else do I need apart from the contents of my sln and vcvars32.bat?
sundeep
you have to add the external includes/libraries, if any, that you added to the visual studio directories. the vcvars*.bat files don't have them; you have to manually add them into the bat file. i think in your case you don't have to add anything, because all you need is in the solution.
maranas
thank you maranas.
sundeep
I am having this same problem. Just like the author, I too need to do this from an MSBuild task from within CruiseControl.Net. Your answer seems to be correct for creating a custom .bat file, but how would I do this from within an MSBuild task in CruiseControl.Net? I thought about creating my own question, but it is exactly the same question that the author posted.
INTPnerd
i don't use CruiseControl.Net myself, but does it work when you add the custom .bat file as an executable task? http://www.igloocoder.net/ccnet/doc/CCNET/Executable%20Task.html
maranas