[英]Visual Studio copies .dll's to Bin folder on Publish
我有以下問題。
我創建了一個Azure function並希望運行存儲在{ProjectFile}/AlCompiler
文件夾中的編譯器。
該文件夾包含.dll和alc.exe文件。 exe 文件需要這些.dll才能運行,否則會產生錯誤。
我嘗試將AlCompiler文件夾的文件發布到wwwroot目錄,在 .csproj 項目文件中添加以下內容:
<ItemGroup>
<Content Include="AlCompiler/**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
我也試過這個標記:
<ItemGroup>
<ContentWithTargetPath Include="AlCompiler/**">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<TargetPath>AlCompiler\%(Filename)%(Extension)</TargetPath>
</ContentWithTargetPath>
</ItemGroup>
並嘗試使用<Link>
屬性:
<ItemGroup>
<Content Include="AlCompiler/**">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<Link>AlCompiler\%(Filename)%(Extension)</Link>
</Content>
</ItemGroup>
所有這些都會導致 AlCompiler 目錄的文件在發布時被拆分:
我沒有找到任何方法將它們保存在一個地方。
因此,由於缺少.dll,我無法運行 alc.exe 文件。
我會很高興你在這方面的幫助!
您應該在.csproj
中使用以下代碼。
<ItemGroup>
<ResolvedFileToPublish Include="your_folder/yourfile">
<RelativePath>your_folder/yourfile</RelativePath>
</ResolvedFileToPublish>
<ResolvedFileToPublish Include="azure-functions-host/appsettings.prod.json">
<RelativePath>azure-functions-host/appsettings.prod.json</RelativePath>
</ResolvedFileToPublish>
<ResolvedFileToPublish Include="azure-functions-host/appsettings.dev.json">
<RelativePath>azure-functions-host/appsettings.dev.json</RelativePath>
</ResolvedFileToPublish>
</ItemGroup>
有關更多詳細信息,您可以在下面的帖子中查看我的答案。
我遇到了解決方案,反之亦然。
而不是試圖添加。 dll到編譯器文件夾(存儲.exe的位置),我添加。 exe到 bin 文件夾(存儲.dll 的位置)。
不知道這是否是最好的解決方案,但它有效:
<ItemGroup>
<ContentWithTargetPath Include="AlCompiler/**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<TargetPath>bin\AlCompiler\%(RecursiveDir)%(Filename)%(Extension)</TargetPath>
</ContentWithTargetPath>
</ItemGroup>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.