views:

1856

answers:

8

I have a solution which contains many class libraries and an ASP .NET website which references those assemblies.

When I build the solution from within the IDE, all assemblies referenced by the website end up in the bin directory. Great!

When I use MsBuild from the command line, all the referenced assemblies are not copied to the bin directory. Why?

My command line is simply:

msbuild.exe d:\myproject\mysolution.sln

Thanks,

Carl.

A: 

Which msbuild are you referencing? Is it the right one?

I generally call like this (from a batch file):

%WINDIR%\Microsoft.NET\Framework\v3.5\msbuild.exe deploy.proj /v:n

In this example, deploy.proj is just a regular msbuild file that does some other stuff before and after calling msbuild on the .sln file.

Rob
Yes, it's the right one. All the assemblies in the sln get compiled but just not copied to the bin directory as they would if I were compiling in the IDE.
Carl
A: 

I think this problem only occurs when your bin directory is not the framework's default for a solution.

I understand that msbuild uses each project set up to build it. If this is so, please go to each projects properties page and check the post build event command line arguments.

El Padrino
A: 

If I recall, MSBuild dosen't copy the referenced assemblies. I've posted a "solution" a while ago: http://www.brunofigueiredo.com/post/Issue-Tracker-part-IV-The-Build-Enviroment-using-MSBuild-(or-NAnt).aspx

Hope it helps.

Bruno Shine
the link is broken
Mr. Flibble
A: 

You could always use a copy task in MSBuild to pull your assemblies into the proper directory. I asked a question not to long ago and ended up answering it myself. It shows how you can setup your Copy task to grab output from another project and pull it into your target project:

http://stackoverflow.com/questions/266888/msbuild-copy-output-from-another-project-into-the-output-of-the-current-project

Andrew Van Slaars
A: 

I haven't been using msbuild for ASP.NET, but aspnet_compiler. Though...I don't remember why. Sorry.

%windir%\Microsoft.Net\framework\v2.0.50727\aspnet_compiler -v \%~n1  -f -p .\%1 .\Website
kenny
+1  A: 

I have found various references to this problem scattered around the Net - and I've just come across it myself. Apparently MSBuild on the command line isn't as good at tracing chains of dependencies as the IDE is.

So as I understand it, if A depends on B which depends on C, The command line may not realize that A depends on C.

The only solution I've found is to ensure that you manually set the project dependencies so that the ASP project references everything it depends on - don't expect it to be able to figure them all out on the command line. This has worked for me, although I only have 5 projects so it's not a bind to get going.

I hope this helps.

George Sealy
A: 

You could make use of the Post-Build steps in project properties to copy the output for the project to a particular location.

This copies to an Assemblies directory in the same directory as the Sln file. I have this in the post-build step of all my projects.

md "$(SolutionDir)Assemblies"
del "$(SolutionDir)Assemblies\$(TargetFileName)"
copy "$(TargetPath)" "$(SolutionDir)Assemblies" /y
benPearce