Click here to Skip to main content
16,017,351 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hi friends,

I have a VC++ solution (created through Visual Studio 2010). In this code base, I have 10 projects and after building the solution I get 10 dlls as the final output.

Also in this code base, I have a folder called 3rdparty where I have some third party dlls. Now my requirement is that I want to export all of those dlls along with 10 dlls that this solution produces.

Problem:
I cannot export 3rdparty dlls from any of the 10 projects. So what I did, I created a separate vcxproj (the eleventh one) named ThirdPartExporter.vcxproj where I did not put any code but just used its Post Build Events settings to copy all the 3rdparty dlls in the final output folder. Now, the problem is that building solution never build this project even with Rebuild option. So I have to explicitly rebuild ThirdPartExporter.vcxproj to copy 3rdparty dlls in the output folder. So I cannot export 3rdparty dlls with Post Build Events settings as I have to rebuild ThirdPartExporter.vcxproj explicitly every time.

What I want:
I want to create a separate vcxproj which does not has any code. But while rebuilding the solution it copy (export) all the dlls from 3rdparty folder to the final output folder.

Can anybody help me in this regard?

Thanks in Advance,
Aseem Sharma
Posted

You might look into the Post Build events...you can copy all the DLLs and other files you want using this.

I don't think you really mean "exporting", simply copying to a common location.
 
Share this answer
 
For projects that have no build events you cannot create a PostBuild event. Go to the project folder of the DLL only project and right click on each file to be exported, and select Properties -> Custom Build Tool -> General. Set the entries as follows:
Command Line:	copy "%(FullPath)" "<your destination path>"
Description:	<the text you want to display>
Outputs:	"<same as destination path>"

// for example

Command Line:	copy "%(FullPath)" "C:\Program Files\mylib\Library1.dll"
Description:	Copying Library1
Outputs:	"C:\Program Files\mylib\library1.dll"

Use the VS macros in the properties editor to select paths, filenames and extensions wherever possible.
 
Share this answer
 
v2
Comments
krmed 17-Jul-12 14:48pm    
Actually, I was talking about a Post Build event in one of the ten projects that he does build. After the last one's done, just use the Post Build to copy everything that's needed to wherever desired.
Richard MacCutchan 23-Jul-12 8:45am    
That is what my answer already says.
Richard MacCutchan 23-Jul-12 9:10am    
What do you mean by easier? I have projects that use the above model and they work fine. Nothing needs to be changed even if I rename the project, move it to a different directory or even a different machine, since it makes use of the macros defined by Visual Studio.
Richard MacCutchan 23-Jul-12 10:38am    
As I said "what do you mean by easier?"; it's all relative. In your case batch files is a better option, in my case it's not.
If you need a separate project file to contain your post build event why not just create a tiny dummy project - Hello World or whatever so that the build takes place. Then the post build event will be called.
 
Share this answer
 
Comments
armagedescu 23-Jul-12 4:12am    
There is no build, then there is no sense to add post build. And even less sense to add fake build.
If there is needed just command execution, then there is no problem just to add command (cmd or bat) files to be built. After that you only have to change property to custom built tool and set the command to the cmd path itself $(FullPath). Then OS will simply run them.
Hi Friends,

I have resolved this issue. I got below hint from the link http://weblogs.asp.net/leftslipper/archive/2010/05/27/creating-visual-studio-projects-that-only-contain-static-files.aspx. This link is about how to resolve the problem in a c# project .cxproj. I applied same solution to a vcxproj.

The first step in editing the csproj file is to remove the reference to the Microsoft.CSharp.targets file because the project doesn’t contain any C# code:

<import project="$(MSBuildToolsPath)\Microsoft.CSharp.targets">
The second step is to define the new Build, Clean, and Rebuild targets to delete and then copy the content files:

XML
<target name="Build">
       <copy>
           SourceFiles="@(Content)"
           DestinationFiles="@(Content->'$(OutputPath)%(RelativeDir)%(Filename)%(Extension)')" />
   </copy></target>
   <target name="Clean">
       <exec command="rd /s /q $(OutputPath)" condition="Exists($(OutputPath))" />
   </target>
   <target name="Rebuild" dependsontargets="Clean;Build">
   </target>


Thanks you all for the effort you spent for me.

Best Regards
Aseem Sharma
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900