.NET Framework Bookmark and Share   
 index > MSBuild > How to make MSBuild create all the binaries in the first compilation?
 

How to make MSBuild create all the binaries in the first compilation?

Hi,

I'm using the MSBuild.exe to build a solution (I'm using the following switches: /nologo /property:configuration=Debug <the_path_to_the_sln_file>).

For some reason, the first time I execute it, not all the DLLs are being copied into the solution's target directory "bin\Debug", although they are being created by the build (I checked the target directories of the projects correspondingto these missing DLLs, and saw that the DLLs are created there).

Only the second time I execute the MSBuild all the DLLs reachs the solution's target directory.

Can someone please explain this behavious, and suggest any way to fix this problem, or work around it, without the need to execute theMSBuild twice, which is a very time-consuming operation.

Regards
Trinominal

Hi, Trinominal

Based on your description, I think you add the *.dll as your referenceratherthana project.
For the reason about you have to use Msbuild twice, I think the reason is that When you firstly build your project, the assembly you referenced has not generated, so your project building failed, but the assembly has generated. So after the second build, your project would build successfully.

To resolve this, You should add project to your reference rather than the *.dll. This will add dependency to your project which makethe assembly build before your project build.
Hope this could help you.
If I misunderstood you, feel free to let me know.

Thanks

Chao

Chao Kuo

Hi, Trinominal

Based on your description, I think you add the *.dll as your referenceratherthana project.
For the reason about you have to use Msbuild twice, I think the reason is that When you firstly build your project, the assembly you referenced has not generated, so your project building failed, but the assembly has generated. So after the second build, your project would build successfully.

To resolve this, You should add project to your reference rather than the *.dll. This will add dependency to your project which makethe assembly build before your project build.
Hope this could help you.
If I misunderstood you, feel free to let me know.

Thanks

Chao

Chao Kuo
Hi, Trinominal

Does your problem resolved, please let me know if my suggestion help!
Thanks
Chao
Chao Kuo
Hi Chao Kuo,

Thanks for you answer, and sorry for the late reply.

First, it is quite problematic for me to set a project reference from the startup project to the relevant projects as you suggested, for all kind of reasons.

Among the DLLs which doesn't appears in the executable directoryafter the first build, I found two types of problems:

1. The startup project (lets call it project A), which is the project which its "bin\Debug" is the executable directory of the solution, references project B, and project B references project C. The DLL of project C doesn't appear in the executable directory.
I found only one case where this pattern happened. In all the rest of the cases whereproject A referenced project B, and B referenced project D, the DLL of project D would appear in the executable directory. I couldn't distinguis yet why this specifiec case with project C didn't work as the rest of the cases of that pattern I mentioned.

2. There is no reference dependency between the startup projectA to a project X (not direct and not indirect), and the project X reaches the executable directory (ONLY IN THE SECOND BUILD) by xcopy commands during the post build event.
Regarding this patternt of the problem:
2-A)Doesn't the post build event of the startup project should be executed only after all the DLLs have been created?
2-B) Anyhow, is there any way to just run the post build events of a certain solution, without build, so that I won't have to build the second time?

I'll be happy if someone have the solution to the two patterns of the problems I specified above.

Regards
Trinominal

You can use google to search for other answers

Custom Search

More Threads

• Is there a way to use wild cards within an "Exec command..."?
• Register multiple tasks
• How to achieve different project settings for debug and release configurations
• ResolveAssemblyReference task
• running unit tests in build scripts
• ClickOnce Install Fails on one machine okay on all others
• catching a target failure
• Getting started, what to do with existing proj files?
• how to determine compilation success or failure of msbuild
• How to define a password field for the input parameter