Jader Dias
Jader Dias

Reputation: 90465

How to reference a C++ library project from a .NET one in Visual Studio?

I have 2 projects

When I want to run the .NET app I have to build the C++ library manually and copy the binary to the .NET app output folder, so it can Work.

How to automate this?

Upvotes: 0

Views: 275

Answers (3)

Hans Passant
Hans Passant

Reputation: 941237

First make sure you've got a solution with both projects. Right-click the C++ project, Properties, Configuration Properties, General. Change the Output Directory setting to

$(SolutionDir)bin\$(ConfigurationName)

Repeat for the Release configuration (upper left combo). That ensures the C++ build is using the same folder naming strategy as the .NET build (bin\Debug and bin\Release).

Now right-click the .NET project, Project Dependencies and tick the C++ project. That ensures that the C++ project gets built first and that the build output gets copied to your .NET build folder.

Upvotes: 3

Öö Tiib
Öö Tiib

Reputation: 10979

You can make the output folder of both projects same folder. Then you do not need to copy.

Upvotes: 1

Valentin
Valentin

Reputation: 880

You can use post-build event, which can be found in Build events under project properties. You can write commands to compile your C++ prjects using MSBuild if needed and copy resulting dll to needed directory.

For example copy ..\..\include\crash_rpt\bin\dbghelp\dbghelp.dll ..\bin\debug

Upvotes: 1

Related Questions