Reputation: 4512
I have project Foo1 which is dependent on library Foo2, where Foo2 is dependent on library Foo3.
Foo1 is c# gui application, Foo2 is C++/Cli library, Foo3 is native c++ library
Dlls of Foo2/Foo3 libraries lie in separate folder Lib. I noticed, that sometimes Foo1 uses old version of Foo2.dll file. It copies dlls from Lib folder to Bin folder, where it keeps executable file, and uses their. When I make changes in Foo3 library, Foo2 project also rebuilds. Dlls were replaced in Lib folder. But they stay not updated in Bin folder, thus main application uses old dlls.
It is piece from Foo1.csproj file:
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1D3976DD-23E4-4798-80A5-AFA8D34E9342}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AuthorProtoNet</RootNamespace>
<AssemblyName>AuthorProtoNet</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<TargetFrameworkProfile />
<IsWebBootstrapper>false</IsWebBootstrapper>
<!-- Predefined intermediate and output paths, defined for all configurations-->
<IntermediateOutputPath>..\..\Temp\win-$(Platform)-$(Configuration)\$(AssemblyName)\</IntermediateOutputPath>
<OutputPath>..\..\Bin\win-$(Platform)-$(Configuration)\</OutputPath>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<Reference Include="Foo2">
<HintPath>..\..\..\Lib\win-$(Platform) $(Configuration)\Foo2.dll</HintPath>
</Reference>
Upvotes: 2
Views: 313
Reputation: 817
MSBuild (Visual Studio's default build engine) doesn't add reference to unmanaged libraries and projects (e.g. C++ libraries or projects.), hence they are not copied to project's output directory. The usual solution to copy unmanaged libraries is with a post-build event. Post-build event is the user configured DOS commands that MSBuild executes after a project is built.
You can set a project's post-build events in its post-build event editor; you will find that in a project's Properties > Build Events > Post-build event command line. Additionally, the MSBuild DOS prompt can access all build variables (e.g $(Configuration)
, $(Platform)
, etc.) So configuring the appropriate source and destination paths according to build configuration shouldn't be a problem. In your case something like the following post-build configuration (untested) should work.
<PropertyGroup>
<PostBuildEvent>xcopy \qy ..\..\..\Lib\win-$(Platform) $(Configuration)\Foo2.dll $(OutDir)</PostBuildEvent>
</PropertyGroup>
P.S. The post-build event editor will generate the preceding section for you. Not necessarily needed to create that yourself.
Upvotes: 2