program tip

참조 DLL 파일이 배포 프로젝트로 bin에 복사되지 않아 오류가 발생합니다.

radiobox 2020. 12. 8. 07:54
반응형

참조 DLL 파일이 배포 프로젝트로 bin에 복사되지 않아 오류가 발생합니다.


웹 응용 프로그램 프로젝트에서 참조되는 여러 외부 DLL 파일이 있습니다. 호스팅 서버에 설치하기위한 배포 프로젝트가 있습니다. .NET 3.5 및 Visual Studio 2008을 사용할 때 DLL 파일이 bin 폴더에 복사되었습니다. .NET 4 및 Visual Studio 2010으로 업그레이드했기 때문에 더 이상 발생하지 않으며 참조를 찾을 수 없기 때문에 서버 오류가 발생합니다.

CopyLocal이 true로 설정되어 있고 web.config 내에서 이것이 다른 곳에서 설정되고 있음을 암시하는 아무것도 찾을 수 없습니다.


Visual Studio 2010에는 버그가 있습니다. 기본적으로 솔루션 파일의 XML은 다음과 같습니다.

<Reference Include="DevExpress.SpellChecker.v11.1.Core,
           Version=11.1.5.0,
           Culture=neutral,
           PublicKeyToken=b88d1754d700e49a,
           processorArchitecture=MSIL">
<HintPath>..\References\DevExpress.SpellChecker.v11.1.Core.dll</HintPath>
</Reference>

MSBuild는 아래에서이를 예상하므로 DLL 파일이 배포에 포함됩니다.

<Reference Include="DevExpress.SpellChecker.v11.1.Core,
           Version=11.1.5.0,
           Culture=neutral,
           PublicKeyToken=b88d1754d700e49a,
           processorArchitecture=MSIL">
<HintPath>..\References\DevExpress.SpellChecker.v11.1.Core.dll</HintPath>
<Private>True</Private>
</Reference>

트릭은 설정하는 것입니다 Copy Local으로 False, 프로젝트를 저장 한 다음에 다시 True- 다시 저장 . 여기에는 MSBuild가 존중하는 Private 노드가 올바르게 포함됩니다.

Copy LocalVisual Studio 2010에 포함되지 않은 비공개 노드 ( ) 의 기본값 True이고 MSBuild는 누락 된 노드를 False.


동일한 문제가 발생하고 "BeforeBuild"단계를 추가하는 대신 단순히이 작업을 수행하는 테스트를 만들었습니다.

    [TestMethod]
    public void ReferenceAssemblyThatDoesNotCopyToBuildFolder()
    {
        Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler referenceThisButDoNotUseIt = null;
    }

그리고 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler ...'유형을 해결할 수 없다는 오류가 수정되었습니다.


내 배포 프로젝트에 이상한 일이 발생했습니다. 감지 된 종속성이 없다는 것을 알았을 때 기본 출력을 제거하고 다시 추가했습니다.

이제 종속성이 표시되고 설치시 bin 폴더에 배치됩니다.


나는 방금 똑같은 문제가 있었고 누군가에게 도움이 될 수 있으므로 내가 찾은 것을 공유하고 싶었습니다.

제 경우의 이유는 일부 타사 응용 프로그램을 설치하는 동안 어셈블리가 GAC에 설치 되었기 때문입니다.

DLL 파일이 GAC에있는 경우 Junto에서 언급 한대로 프로젝트 파일의 "Private"노드를 사용하여 "로컬 복사"로 표시하지 않는 한 컴파일러는 대상 폴더에 복사하지 않습니다.

문제는 해당 노드를 추가하지 않고 한 머신에서 개발하고 다른 머신에서 빌드하고 DLL 파일이 빌드 머신의 GAC에만있는 경우 비공개 노드가없는 기본 동작으로 인해 파일이 개발 머신에서는 올바르게 복사되지만 빌드 머신에서는 복사되지 않습니다.

더 큰 문제는 DLL 파일이 직접 참조되지 않지만 프로젝트가 DLL 파일을 참조하는 두 번째 프로젝트를 참조하는 경우입니다. 이 경우 DLL 파일이 참조되지 않으므로 프로젝트에서 "로컬 복사"로 표시 할 수 없습니다. 따라서 DLL 파일이 GAC에 있으면 출력 폴더에 복사되지 않습니다.

이 경우에 가능한 해결책은 다음과 같습니다.

  • GAC에서 DLL 파일 제거
  • 최종 프로젝트에서 DLL 파일에 대한 직접 참조를 추가합니다.
  • GAC의 DLL 파일과 구별되는 새 강력한 이름으로 DLL 파일에 다시 서명합니다.

나는 똑같은 문제가 발생했습니다. EnterpriseLibrary를 참조하는 Visual Studio 2008 프로젝트가 있습니다. TFS와 웹 배포 프로젝트를 사용하여 통합 빌드를 실행하면 모든 DLL 파일이 복사됩니다. Visual Studio 2010, TFS 2010 및 WDP 2010으로 업그레이드 할 때 일부 DLL 파일이 누락되었습니다. 이상하게도 이것은 일부 DLL 파일에만 발생하고 다른 파일에는 발생하지 않습니다.

예를 들어, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.dll은 두 경우 모두 복사되지만 Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll은 복사되지 않습니다.

해결 방법으로 "BeforeBuild"단계를 사용하여 파일을 복사했습니다.

이제 괜찮은 것 같습니다.


I didn't meet the same problem but similar. I had WPF main project and referenced project where the referenced did not copy. I found that in my case the main project was set for NET 4.0 Client Profile and the referenced for NET 3.5. When I set the main project to 3.5 the compiled dll of the referenced project started to copy. (I don't know why because I solved it by practice)


I too ran into a similar issue where referenced dlls were not copied into the bin in published folder. I was using a TFS checked out copy that didn't include the bin folder into the application. -> So just included the bin folder. -> Built the referenced applications -> Published the website project Now I see all the referenced dlls in bin in the published folder


I had a similar issue with VS 2012 Express. I used Tesseract libraries in my project. Everything worked well until I used this project in a solution where were more than one project. Problem was that some DLLs (liblept168.dll, libtesseract302.dll) that are normally placed in folders bin/debug/x86 or bin/debug/x64 were copied only when I rebuilt whole solution. Changing a single line and building it again caused that the DLLs were deleted and not copied back.

I solved this issue by adding a reference of the project that creates missing DLLs to the startup project.


rzen and others, thanks - your comments led to a solution for us.

We have a project that targets version 10 of the Microsoft.ReportViewer.Common.dll and Microsoft.ReportViewer.WebForms.dll assemblies (separate "libs" folder we created at the 'src' level). But when we did a build, the output included version 12, which was recently installed on the build server.

Using comments here, we ensured that 'Copy Local' was set to True and that the flag was set in the project file. However, it was still deploying version 12. So what we found that did the trick was ensuring that the 'Specific Version' property was also set on the two references. Voila, version 10 of each file is now being deployed!

There was much rejoicing.

JH


If your project does not directly load the library, it won't always be deployed, even if it is referenced explicitly! I got confused because I could see it in a local Bin directory but not when deployed. The dll in the Bin directory was an old file that wasn't removed during Clean which is why I was confused.

A full clean and rebuild and it wasn't in my local Bin folder either which showed me the problem (I only use it in web.config). I then referenced the dll file itself in the project and set it to copy to output to make sure it gets deployed.


I am not sure how it was set up in Visual Studio 2008, but I am almost positive that you might have been using the Post-Build event command line. In there you can tell to copy the DLL files you need for deployment. An example is given below:

mkdir $(SolutionDir)\Deployment
copy "$(SolutionDir)Your_Library_Name\Your_Dll_ForDeployement.dll" 
$(SolutionDir)\Deployment\

We can use the <Private>False</Private> to not to copy the referenced DLL files to the bin directory. This is useful when we are building applications in a separate TFS build server where we need to build the application and not to copy the DLL files to the bin directory.


Check the framework of the project in which the DLL file has been referenced. The framework should be .NET 4.0. Please correct it if the framework is Client Profile.

참고URL : https://stackoverflow.com/questions/2947017/reference-dll-file-not-copying-to-bin-with-deployment-project-causing-error

반응형