वहाँ वी.एस. बताने के लिए गंतव्य फ़ोल्डर में DLLs कॉपी करने के लिए कई तरीके हैं। और वीएस को प्रतिलिपि बनाने के लिए बताएं यदि डीएल नया है
2. डीएलएल प्रोजेक्ट के संदर्भ में एक नई परियोजना जोड़ें, और आउटडोर को इच्छित फ़ोल्डर में सेट करें। यह प्रोजेक्ट कुछ भी नहीं करता है लेकिन डीएलएल की प्रतिलिपि बनाता है।
vcxproj फ़ाइल
5.Use vcxproj फ़ाइल
<ItemGroup>
<CustomBuild Include="..\..\xxx.dll">
<FileType>Document</FileType>
<Command>
call mkdir "$(OutDir)" 2>nul &
copy /Y "..\..\xxx.dll" "$(OutDir)xxx.dll"
</Command>
<Message>Copying xxx.dll to $(OutDir)\xxx.dll</Message>
<Outputs>$(OutDir)\xxx.dll</Outputs>
</CustomBuild>
</ItemGroup>
में CustomBuild एक makefile 6.Use में vcxproj फ़ाइल
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
</ClCompile>
<Link>
</Link>
<PostBuildEvent>
<Command>
echo off
mkdir "$(ProjectDir)..\..\bin\$(Configuration)\"
copy "$(OutDir)xxx.dll" "$(ProjectDir)..\..\lib\$(Configuration)\"
echo on
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
में एक PostBuildEvent एक PreBuildEvent 4.Use 3.Use
और मेकफ़ाइल में डीएल कॉपी करें। और nmake का उपयोग
7.Write एक बल्ला फ़ाइल है कि प्रति काम करने का निर्माण, और के रूप में बल्लेबाजी फ़ाइल आह्वान करने के लिए 3-6
जैसे कि अजगर के रूप में
8. स्क्रिप्ट है, जो भी से dll डाउनलोड कर सकते हैं इंटरनेट। और पीई फ़ाइल को 3-6 में डालें।
ऐसे Gradle के रूप में निर्माण 9.Other उपकरण भी मदद कर सकते हैं,
10.Make यह एक NuGet प्लगइन
11.Sometimes मैं सिर्फ एक बल्ला लिखते हैं, और मैन्युअल रूप से बल्ले पर अमल।
अपडेट 01 (स्व निकालने dll उदाहरण):
1.Add आप देशी dll कामयाब dll के संसाधन
2.Add इस init() विधि के रूप में
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace DllSelfExtract
{
public class SelfExtract
{
public static void Init()
{
String managedDllPath = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;
String nativeDllPath = managedDllPath.Replace("file:///", "").Replace("DllSelfExtract.DLL", "TestDll.dll");
if(!File.Exists(nativeDllPath))
{
Stream dllIn = Assembly.GetExecutingAssembly().GetManifestResourceStream("DllSelfExtract.TestDll.dll");
if (dllIn == null) return;
using (Stream outFile = File.Create(nativeDllPath))
{
const int sz = 4096;
byte[] buf = new byte[sz];
while (true)
{
int nRead = dllIn.Read(buf, 0, sz);
if (nRead < 1)
break;
outFile.Write(buf, 0, nRead);
}
}
}
//LoadLibrary Here
}
}
}
3 ।परियोजना है कि आपके प्रबंधित dll का उपयोग में, आह्वान init() विधि पहले
SelfExtract.Init();
अपडेट 02 (NuGet उदाहरण):
1. बनाएँ एक नया NuGet परियोजना
2.Place कामयाब/lib निर्देशिका
3.Place गैर-प्रबंधित सभी गैर-प्रबंधित * * .dl_
को .dll/निर्माण उपनिर्देशिका में साझा पुस्तकालयों और संबंधित फ़ाइलें और नाम बदलने में विधानसभाओं 10
4.Add निम्नलिखित सामग्री कुछ इस तरह के साथ/निर्माण उपनिर्देशिका में एक कस्टम .targets फ़ाइल:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<AvailableItemName Include="NativeBinary" />
</ItemGroup>
<ItemGroup>
<NativeBinary Include="$(MSBuildThisFileDirectory)*">
<TargetPath></TargetPath>
</NativeBinary>
</ItemGroup>
<PropertyGroup>
<PrepareForRunDependsOn>
$(PrepareForRunDependsOn);
CopyNativeBinaries
</PrepareForRunDependsOn>
</PropertyGroup>
<Target Name="CopyNativeBinaries" DependsOnTargets="CopyFilesToOutputDirectory">
<Copy SourceFiles="@(NativeBinary)"
DestinationFiles="@(NativeBinary->'$(OutDir)\%(TargetPath)\%(Filename).dll')"
Condition="'%(Extension)'=='.dl_'">
<Output TaskParameter="DestinationFiles" ItemName="FileWrites" />
</Copy>
<Copy SourceFiles="@(NativeBinary)"
DestinationFiles="@(NativeBinary->'$(OutDir)\%(TargetPath)\%(Filename).%(Extension)')"
Condition="'%(Extension)'!='.dl_'">
<Output TaskParameter="DestinationFiles" ItemName="FileWrites" />
</Copy>
</Target>
</Project>
5.Add Package.nuspec में
<files>
<file src="lib\" target="lib" />
<file src="tools\" target="tools" />
<file src="content\" target="content" />
<file src="build\" target="build" />
</files>
6 निर्माण फ़ोल्डर के लिए नियम बनाएं पैकेज
7. अपने अन्य सी # प्रोजेक्ट में बस इस NuGet पैकेज को जोड़ें।
शायद यह एसओ पोस्ट शीर्षक [विजुअल स्टूडियो में डीएलएल की निर्भरताओं की प्रतिलिपि बनाना] (http://stackoverflow.com/questions/1043913/copying-a-dlls- निर्भरता-in-visual-studio) मदद की जा सकती है? –
मुझे डर है कि यह मेरी जरूरत नहीं है। मैं Managed.dll और Native.dll वितरित करना चाहता हूं। जब लाइब्रेरी का कोई उपयोगकर्ता Managed.dll संदर्भित करता है तो मुझे अपनी प्रोजेक्ट के बिन फ़ोल्डर में स्थानीय रूप से कॉपी की गई Native.dll की आवश्यकता होती है। – Trifon