How to add a link to an Azure Function C # project?

With the latest Azure SDK, I got the Azure Tools for Visual Studio so that I can debug my Azure feature indoors - cool.

My azure function should use the business object dll code

From a .csx script I can make a link to a .dll with such a directive at the beginning

#r  "ServiceBusQueue.Shared.dll"

There is no "Add Link ..." link in the Azure Feature Project. I can only add the Build dependency so that the dll of the business object is created first.

But when the dll code is updated, there is no copy of the dll output to the basket of my azure function directory. Publish on the Internet in order This is necessary so that the latest business object code is used in the local debugging session.

Since the Azure project has no tab for Prebuild events, the solution I found is to write Prebuild eventin the App project of the application

.funproj file

<Target Name="BeforeBuild">
    <Message Text="Copying dlls into Azure Function ..." />
    <Exec Command="Call CopyDlls.cmd $(Configuration)" />
</Target>

Batch file:

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

Thus, the dll is copied to the bin directory of the Azure Function project.

Is there a more integrated / clean way to do this?

+4
source share
1 answer

Unfortunately, the best workaround for this is, as you found out, using the target MSBuild in the file funproj.

post-build . → → - xcopy /Y $(TargetPath) $(SolutionDir)FunctionApp1\bin.

VS . . https://github.com/Azure/Azure-Functions/issues/90.

+7

Source: https://habr.com/ru/post/1668552/


All Articles