开发者

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

I have 2 projects

  • A C++ library
  • A .NET app that uses the above

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 Wo开发者_如何学JAVArk.

How to automate this?


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.


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜