【发布时间】:2017-06-18 13:30:25
【问题描述】:
借助最新的 Azure SDK,我得到了 Visual Studio 的 Azure Function tools 这样我就可以在本地调试我的 Azure Function - 很酷。
我的天蓝色函数需要使用业务对象dll的代码
从 .csx 脚本中,我可以在开始时使用这样的指令引用 .dll
#r "ServiceBusQueue.Shared.dll"
Azure 函数项目中没有“添加引用...”。 我只能添加一个 Build 依赖,以便首先构建业务对象 dll。
但是当更新 dll 代码时,没有将 dll 输出复制到我的 azure 函数目录的 bin 中。 在网络上发布是可以的 为了在本地调试会话中使用最新的业务对象代码,这是必需的。
因为 Azure 函数项目中没有 Prebuild 事件选项卡,
我找到的解决方案是在 Function App 项目中写一个Prebuild event
.funproj 文件
<Target Name="BeforeBuild">
<Message Text="Copying dlls into Azure Function ..." />
<Exec Command="Call CopyDlls.cmd $(Configuration)" />
</Target>
批处理文件:
rem %1 is the configuration, debug or release
echo %1
mkdir .\ServiceBusQueueTriggerCSharp\bin
copy ..\ServiceBusQueue.Shared\bin\%1\*.* .\ServiceBusQueueTriggerCSharp\bin
rem DOS subtlety : test than return code is equal or greater than 1
rem : make the compilation to fail
if errorlevel 1 exit /b 1
这样 dll 就会被复制到 Azure Function 项目的 bin 目录中。
有没有更集成/更清洁的方法来做这样的事情?
【问题讨论】:
标签: c# azure msbuild csproj azure-functions