include c/c++ unmanaged code dll, consumed using dllimport, in azure functions publish process

隐身守侯 提交于 2020-01-01 07:23:13

问题


How does one include in a c/c++ unmanaged code dll, consumed using v2 .net core compatible DllImportAttribute statements, in azure functions publish process?

I've confirmed it works in cloud deployment by manually copying, via azure storage explorer, to functions app storage account | file shares | | site/wwwroot/bin folder.

Issue is now I haven't been able to find way to have it included in vs17 | | Publish process.

Tried placing dll in \bin\$(Configuration)\netcoreapp2.1\bin folder before executing vs17 | | Publish but doesn't result in it being picked up.


回答1:


In VS, right click on your Function project and Edit <FunctionProjectName>.csproj. Add items below to copy dlls we need when publishing or debugging locally.

  <!-- For publish -->
  <ItemGroup> 
    <None Include=" relative or absolute path to your dll, which is not in your project">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
  </ItemGroup>

  <!-- If you have put dlls under your project root -->
  <ItemGroup>
    <None Update="YourDllName.dll">
        <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
  </ItemGroup>

  <!-- For local debug -->
  <Target Name="CopyToBin" BeforeTargets="Build">
    <Copy SourceFiles="relative or absolute path to your dll" DestinationFolder="$(OutputPath)\bin" />
  </Target>


来源:https://stackoverflow.com/questions/53643543/include-c-c-unmanaged-code-dll-consumed-using-dllimport-in-azure-functions-p

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!