대상 폴더에 DLL을 복사 VS 말할 수있는 몇 가지 방법이 있습니다. dll이 더 새로운 경우 복사하도록 VS에게 알려주십시오.
2. dll 프로젝트를 참조하는 새 프로젝트를 추가하고 OutDir을 원하는 폴더로 설정하십시오. 이 프로젝트는 dll을 복사 만합니다. vcxproj 파일 메이크 6.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>
에서
5.Use CustomBuild에서 PreBuildEvent 4.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 3.Use
makefile에 dll을 복사합니다. 및
7.Write 복사 작업을 박쥐 파일을 구축하고,에서와 박쥐 파일을 호출하는 nmake를 사용하여 3-6
도에서 DLL을 다운로드 할 수 있습니다 파이썬 등
8.Use 스크립트, 인터넷. 그리고 3-6에서와 같이 py 파일을 호출하십시오.
은 Gradle을 같은 도구도 도움이 될 수 있습니다 구축 9.Other
10.Make 그것을 NuGet 플러그인
11.Sometimes 난 그냥 방망이를 쓰고, 수동으로 방망이를 실행합니다.
업데이트 01 (자체 추출 DLL 예) : 관리 DLL의 자원
2.Add이 초기화() 메소드로
1.Add하면 네이티브 DLL
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 .
1.Create 새로운 NuGet 프로젝트
2.Place가 관리 : 관리되는 DLL을 사용하는 프로젝트에서 먼저 초기화() 메소드
SelfExtract.Init();
업데이트 02 (NuGet 예)를 호출/lib 디렉토리의 어셈블리
3. 관리되지 않는 공유 라이브러리 및 관련 파일을/build 하위 디렉토리에 배치하고 관리되지 않는 모든 * .dll의 이름을 * .dl_
로 변경합니다 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이
<files>
<file src="lib\" target="lib" />
<file src="tools\" target="tools" />
<file src="content\" target="content" />
<file src="build\" target="build" />
</files>
6 Package.nuspec에서 빌드 폴더에 대한 규칙을 구축 패키지를 빌드하십시오.
7. 다른 C# 프로젝트에서이 NuGet 패키지를 추가하십시오.
아마도 [제목] [Visual Studio에서 DLL의 종속성 복사] (http://stackoverflow.com/questions/1043913/copying-a-dlls-dependencies-in-visual-studio)가 도움이 될 수 있습니까? –
나는 이것이 내가 필요한 것이 아닌가 걱정된다. Managed.dll 및 Native.dll을 배포하려고합니다. 라이브러리 사용자가 Managed.dll을 참조하면 프로젝트의 bin 폴더에 로컬로 복사 된 Native.dll이 필요합니다. – Trifon