Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependencies are not copied to output path of another referencing project with msbuild and nuget #23

Closed
lauxjpn opened this issue Apr 29, 2017 · 3 comments

Comments

@lauxjpn
Copy link

lauxjpn commented Apr 29, 2017

If you build a library project in Visual Studio, include the emgucv package using nuget and compile everything, you will get the x86 and x64 sub directories inside your ouput directory as expected.

Unfortunately, if you create another project that references this library project and compile it, the x86 and x64 sub directories will not be copied to the output directory of the newly created project and thus causing it to fail when calling any library project function that uses emgucv.

To solve this problem, you have to change a single file which is distributed together with the nuget package.

The EmguCV.targets file looks like this:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup>
    <OpenCVBinX64 Include="$(MSBuildThisFileDirectory)\native\x64\*.dll" />
    <OpenCVBinX86 Include="$(MSBuildThisFileDirectory)\native\x86\*.dll" />
  </ItemGroup>
  <Target Name="AfterBuild">
    <Copy SourceFiles="@(OpenCVBinX64)" DestinationFolder="$(OutputPath)\x64" ContinueOnError="true" SkipUnchangedFiles="true" Condition="$(CopyOpenCVBins)"/>
    <Copy SourceFiles="@(OpenCVBinX86)" DestinationFolder="$(OutputPath)\x86" ContinueOnError="true" SkipUnchangedFiles="true" Condition="$(CopyOpenCVBins)"/>
  </Target>
</Project>

If you replace it with the following code, it will work in both scenarios:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup Condition="'$(CopyOpenCVBins)'"> 
    <Content Include="$(MSBuildThisFileDirectory)\native\x64\*.dll">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Link>x64\%(Filename)%(Extension)</Link>
    </Content>
    <Content Include="$(MSBuildThisFileDirectory)\native\x86\*.dll">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Link>x86\%(Filename)%(Extension)</Link>
    </Content>
  </ItemGroup>
</Project>
@tfaris
Copy link

tfaris commented May 26, 2017

I just ran into this myself today.

@emgucv Any thoughts? I can confirm that @lauxjpn's solution works for me.

@lauxjpn
Copy link
Author

lauxjpn commented Jul 13, 2017

It seems that the code was included in the newly added emgucv/platforms/nuget/Emgu.CV.targets file with commit 2f21a40 about 24 days ago.
The issue should be solved.

@lauxjpn lauxjpn closed this as completed Jul 13, 2017
@emgucv
Copy link
Owner

emgucv commented Jul 14, 2017

Offical Emgu CV v3.2 release is available from Nuget:
https://www.nuget.org/packages/Emgu.CV/

We will support Nuget packages moving forward.

Thanks for the feed back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants