C# 复制C++ DLL,以生成任何扩展引用的C项目的输出 我有一个C库,引用了一些C++ + CLI项目,其中包含了一些编译为DLL的C++库。 所以,在运行任何应用程序库的应用程序时,我当然需要C和CLI DLL,当然也需要所有C++的,即使它们被CLI项目引用,也不会被默认复制。
使用预生成事件手动复制它们可以正常工作 但我不仅需要为每个应用程序项目添加它们,而且还希望将我的库发布为NuGet,并且无法控制引用项目的属性C# 复制C++ DLL,以生成任何扩展引用的C项目的输出 我有一个C库,引用了一些C++ + CLI项目,其中包含了一些编译为DLL的C++库。 所以,在运行任何应用程序库的应用程序时,我当然需要C和CLI DLL,当然也需要所有C++的,即使它们被CLI项目引用,也不会被默认复制。,c#,c++,dll,c++-cli,nuget-package,C#,C++,Dll,C++ Cli,Nuget Package,使用预生成事件手动复制它们可以正常工作 但我不仅需要为每个应用程序项目添加它们,而且还希望将我的库发布为NuGet,并且无法控制引用项目的属性 有解决办法吗?特定于NuGet软件包的事件之一。我喜欢Hans Passants的评论。他的答案是减少复制的数据量,并允许无缝使用任何CPU 我的解决方案是WPF项目使用的。支持旧项目文件的项目类型,nuget不太支持这些文件作为.NET核心或.NET标准项目。但是.NET标准中没有c++cli。我们只有x64程序集,我的使用者只是内部的,所以不需要关心
有解决办法吗?特定于NuGet软件包的事件之一。我喜欢Hans Passants的评论。他的答案是减少复制的数据量,并允许无缝使用任何CPU 我的解决方案是WPF项目使用的。支持旧项目文件的项目类型,nuget不太支持这些文件作为.NET核心或.NET标准项目。但是.NET标准中没有c++cli。我们只有x64程序集,我的使用者只是内部的,所以不需要关心win32。 新的nuget语法允许对那些DLL进行大量的精细控制,但实际上我还没有完成学习曲线和nuget。 这就是我用于严格包装dll的方法。人们可以调试到我的dll中,我把调试dll、PDB放入包中,它们只在我们公司内部使用。如果用户将配置更改为debug,我会为这些程序集引用的包编写目标文件 本机dll
<?xml version="1.0"?>
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<description></description>
<id>yourId</id>
<version>$version$</version>
<authors></authors>
<!-- Only done because at the beginning I copied the native dll into the lib/net461 folder which gets automatically referenced -->
<references>
<reference file="yourCSharpProject.dll" />
<reference file="yourInteropProject.dll" /> <!-- if needed -->
</references>
</metadata>
<files>
<!-- the target file will copy my native dlls into the target file -->
<file src="target\**" target="build"/>
<!-- copy all debug and release of ... Native.dlls, pdbs, xml -->
<!-- usage hint ** preserves the folder structure, debug and release -->
<file src="bin\x64\**\YourNative.*" target="lib\native\" />
<!-- copy all debug and release of ... Interop.lls, pdbs, xml -->
<file src="bin\x64\Release\.*" target="lib\net461\" />
</files>
</package>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="CopyBinaries" BeforeTargets="BeforeBuild">
<CreateItem Include="$(MSBuildThisFileDirectory)../lib/native/$(Configuration)/*" >
<Output TaskParameter="Include" ItemName="SomeImportantName" />
</CreateItem>
<Copy SourceFiles="@(SomeImportantName)"
DestinationFolder="$(Outputpath)"
SkipUnchangedFiles="true" />
</Target>
</Project>