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

后端 未结 9 1329
日久生厌
日久生厌 2021-01-13 10:43

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 a

相关标签:
9条回答
  • 2021-01-13 11:05

    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.

    0 讨论(0)
  • 2021-01-13 11:09

    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.

    0 讨论(0)
  • 2021-01-13 11:09

    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.

    0 讨论(0)
  • 2021-01-13 11:14

    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
    
    0 讨论(0)
  • 2021-01-13 11:17

    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:

    MSBuild copy output from another project into the output of the current project

    0 讨论(0)
  • 2021-01-13 11:18

    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
    
    0 讨论(0)
提交回复
热议问题