Why am I missing assemblies from the bin directory when compiling with MsBuild?

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

When I create a solution from the IDE, all the assemblies referenced by the site fall into the bin directory. Excellent!

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

My command line is simple:

msbuild.exe d:\myproject\mysolution.sln 
+4
source share
9 answers

I found various links to this problem scattered across the Web - and I just stumbled upon it. Apparently, MSBuild on the command line is not as good at tracking dependency chains as the IDE.

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

The only solution I found was to make sure that you manually install the project dependencies so that the ASP project refers to everything it depends on - don't expect it to be able to calculate them all on the command line. This worked for me, although I only have 5 projects, so this is not work-related.

Hope this helps.

+1
source

The problem I am facing is a project depending on the library project. To build, I performed the following steps:

 msbuild.exe myproject.vbproj /T:Rebuild msbuild.exe myproject.vbproj /T:Package 

This, of course, meant that I was missing a library of DLL files in the basket and, most importantly, in the package zip file. I found this to work fine:

 msbuild.exe myproject.vbproj /T:Rebuild;Package 

I have no idea why this work or why it was not in the first place. But hope this helps.

+1
source

What msbuild are you referring to? Is it correct?

I usually call this (from a batch file):

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

In this example, deploy.proj is a regular msbuild file that performs some other actions before and after invoking msbuild in the .sln file.

0
source

I think this problem only occurs when your bin directory is not the default base for the solution.

I understand that msbuild uses every project created to create it. If so, go to the project properties page and check the command line arguments of the post build event.

0
source

You can always use the copy task in MSBuild to pull assemblies into the appropriate directory. I asked a question not so long ago and myself answered. It shows how you can configure the Copy task to capture output from another project and pull it into your target project:

MSBuild copies the result from another project to the output file of the current project

0
source

I did not use msbuild for ASP.NET, but aspnet_compiler. Although ... I do not remember why. Unfortunately.

 %windir%\Microsoft.Net\framework\v2.0.50727\aspnet_compiler -v \%~n1 -f -p .\%1 .\Website 
0
source

You can use the Post-Build steps in the project properties to copy the output for the project to a specific location.

This copies to the collectors directory in the same directory as the Sln file. I have it at the stage after the assembly of all my projects.

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

Known issue f for MSBuild 3.5 and msbuild 4.5. I am using Msbuild 4, found in

  c:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe <yourSolutionFile>.sln 

The problem seems to be resolved.

0
source

If I remember, MSBuild does not copy reference assemblies. Some time ago I posted a β€œsolution”: http://www.brunofigueiredo.com/post/Issue-Tracker-part-IV-The-Build-Enviroment-using-MSBuild-(or-NAnt).aspx

Hope this helps.

-3
source