Quantcast
Channel: Active questions tagged nuget-package - Stack Overflow
Viewing all articles
Browse latest Browse all 3067

How do you package native dependencies in a nuget package for AnyCpu for SDK-Style project users?

$
0
0

I'm currently working on an application using .Net Framework 4.5 using the new SDK-style Project Format. I want to create a nuget package for a third party dependency that consists of an AnyCpu Assembly and native dependencies with differing names for x86 and x64. I want just all native dependencies copied in the case of an AnyCpu-Build and only the respective libraries when compiling my program with x86/x64.

I tried creating a nuget with the following structure:

- lib
   - net452
       - Dependency.AnyCpu.Assembly.dll
- runtime
   - win7
       - native
           - Dependency.Native.x86.dll
           - Dependency.Native.x64.dll
   - win7-x86
       - native
           - Dependency.Native.x86.dll
   - win7-x64
       - native
           - Dependency.Native.x64.dll

Which works for the x86 and x64 case, but fails to copy anything in the AnyCpu case. Without the win7 folder there is no difference.

A .props-file with the following content:

<?xml version="1.0" encoding="utf-8" ?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup Condition="'$(Platform)' == 'AnyCPU'">
    <Content Include="$(MSBuildThisFileDirectory)..\..\runtimes\win7-x86\native\*">
      <Link>%(Filename)%(Extension)</Link>
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Visible>False</Visible>
    </Content>
    <Content Include="$(MSBuildThisFileDirectory)..\..\runtimes\win7-x64\native\*">
      <Link>%(Filename)%(Extension)</Link>
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Visible>False</Visible>
    </Content>
  </ItemGroup>
</Project>

copies all native dependencies no matter which architecture I set.


Viewing all articles
Browse latest Browse all 3067

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>