![](/img/trans.png)
[英]How to move third party dlls from bin folder to another folder in ASP.NET Web Forms project?
[英]asp.net deploy 3rd party dlls to bin folder
我創建了一個ASP.NET Webforms(4.6)網站,其中包含一些第三方組件。 為了使其正常工作,我創建了一個SharedResources文件夾,其中包含所需的DLL。 我添加了一個參考,發布時這些DLL被復制到BIN中-GREAT。 但是還有一些其他無法引用的DLL,因為它們不是有效的程序集或COM組件。
如何添加到文件夾(SharedResources \\ 3rdParty)中的dll,以便在單擊“發布”時將所有這些dll轉儲到網站的bin文件夾中。
(為避免這種情況)我已將DLL構建操作設置為“內容-始終復制”,這在〜\\ SharedResources \\ 3rdParty \\中為我提供了一個DLL文件夾,然后應用程序抱怨缺少dll,因此我將其復制到了bin中手動-不可能正確!
謝謝
右鍵單擊您的項目,然后轉到屬性,然后在“構建事件”選項卡中將其粘貼到構建前事件命令行中:復制$(ProjectDir)SharedResources \\ 3rdParty * .dll $(ProjectDir)$(OutDir)
當您發布網站時,這將不起作用。 您將必須在項目文件或單獨的目標文件中創建自己的目標,並按如下所示進行調用-
添加以下內容-
<ItemGroup>
<ThirdPartyDllDependencies Include="$(SolutionDir)..\..\Lib\ThirdPartyDll\*.dll" SkipUnchangedFiles="true" />
</ItemGroup>
<Target Name="PublishThirdPartyDllDependencies">
<Copy SourceFiles="@(ThirdPartyDllDependencies)" DestinationFolder="$(OutDir)\" />
<Copy SourceFiles="@(ThirdPartyDllDependencies)" DestinationFolder="$(WebProjectOutputDir)\bin\" />
</Target>
<!-- This target is responsible for adding the ThirdPartyDll and dependencies to the bin directory while Publishing the website. -->
<Target Name="CustomCollectFiles">
<ItemGroup>
<_CustomFiles Include="$(SolutionDir)..\..\Lib\ThirdPartyDll\ThirdPartyDll11\64Bit\*.dll" />
<FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
<DestinationRelativePath>$(WebProjectOutputDir)\bin\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
<DestinationRelativePath>$(OutDir)\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
<PropertyGroup>
<CopyAllFilesToSingleFolderForPackageDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
</PropertyGroup>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.