0

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

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
ram4sof
  • 365
  • 1
  • 4
  • 14

2 Answers2

1

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.

Sara Liu - MSFT
  • 6,007
  • 1
  • 21
  • 27
0

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

Cindy Pau
  • 13,085
  • 1
  • 15
  • 27
  • The EXE is NOT compiled into bin folder when Function app is published. I agree the console app individually compiled into its own bin folder but that is not useful as my function app trying to executes the exe from the bin also the reference of console app are placed under bin.. over all it is not clean having exes in one pace and its dependencies in other place, hence it make more sense to keep the deployable artifacts in one folder for cleaner deployment approach – ram4sof Mar 29 '21 at 18:26