ram4sof
ram4sof

Reputation: 465

Publish project references of azure function within bin folder

I have a azure function application that references another console project(MyConsoleApp) as "project Reference" when i publish the Azure function application, The console project is compiled and placed out side of the bin folder. How to make MyConsoleApp.exe file is copied to bin folder while publishing the Azure Function application?

Here is the VS project structure

enter image description here

Publish Output:

enter image description here

Upvotes: 0

Views: 1491

Answers (2)

Sara Liu - MSFT
Sara Liu - MSFT

Reputation: 6218

You can extend it through MSBuild. Add this into your <azure function>.csproj file:

<ItemGroup>
    <FunctionsPublishAssemblies Include="$(TargetDir)MyConsoleApp.exe"></FunctionsPublishAssemblies>
</ItemGroup>

After that, click Publish button and you will find the MyConsoleApp.exe is under publish\bin folder during publish process.

enter image description here

Update

Add these under <azure function>.csproj file:

<ItemGroup>
    <FunctionsPublishAssemblies Include="$(TargetDir)MyConsoleApp.exe"> 
    </FunctionsPublishAssemblies>
</ItemGroup>
<Target Name="DeleteFile" AfterTargets="_AspNetCoreProjectSystemPostPublish">
        <Delete Files="$(PublishDir)MyConsoleApp.exe"></Delete>
</Target>

Then, re-publish your project.

Upvotes: 1

suziki
suziki

Reputation: 14080

Your idea is meaningless, this is by design. And, one thing that needs to be pointed out is that your exe has been compiled into the bin folder, and the bin folder you mentioned is the bin folder of the function app. You can manually put all the relevant files into bin and call them in the code, but IMHO this doesn't make much sense.

Please check your function app:

enter image description here

Upvotes: 0

Related Questions