none
MSBuild copy task in Azure Functions with Visual Studio 2017 RRS feed

  • Question

  • I am unable to find the specific event on which i should target the copy task in VS2017. I want to copy all Azure functions binary files after building the code in Debug mode.

    I am using following code snippet for copy task in functionApp.csproj file

    <ItemGroup>  
            <MyAzureFunction Include="$(SolutionDir)Platform\FrontendService\Platform.Service.FunctionApp\$(OutputPath)**\*.*" />  
        </ItemGroup>
      
        <Target Name="CopyFiles" AfterTargets="_GenerateFunctionsPostBuild" KeepDuplicateOutputs="false">
          <Message Text="Copying files" /> 
            <Copy SourceFiles="@(MyAzureFunction)" DestinationFiles="$(SolutionDir)Drop\Platform.Service.FunctionApp\%(RecursiveDir)%(Filename)%(Extension)" ContinueOnError="true" />  
        </Target>


    • Edited by Aniket Gaikwad Monday, April 9, 2018 6:09 AM Title modification
    Monday, April 9, 2018 4:36 AM

All replies

  • Hi Aniket Gaikwad,

    Welcome to MSDN forum.

    Do you mean you want to execute this copy task when you in the Debug mode?

    If yes, to accomplish this, you could use the MSBuild Conditions on this task:

      <Target Name="CopyFiles" AfterTargets="_GenerateFunctionsPostBuild" KeepDuplicateOutputs="false" Condition=" '$(Configuration)' == 'Debug' ">
        <Message Text="Copying files" />
        <Copy SourceFiles="@(MyAzureFunction)" DestinationFiles="$(SolutionDir)Drop\Platform.Service.FunctionApp\%(RecursiveDir)%(Filename)%(Extension)" ContinueOnError="true" />
      </Target>

    If I am not understand you correct, please let me know what is your problem with some more details info.

    Hope this helps.


    MSDN Community Support Please remember to click Mark as Answer. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Monday, April 9, 2018 11:13 AM
  • Still not getting issues with. above condition. I want to copy all Output Directory content to some other directory from where i can package it efficiently as soon as MSBuild completes build the azure functions. 

    the above condition works when i rebuild it. but it doesnt work when i do clean and build.


    Tuesday, April 10, 2018 1:56 PM
  • hi Aniket Gaikwad, How about this issue now? I found you edit above reply with a comment "fix", have you resolved it? If yes, you can write your solution here, this can be beneficial to other community members reading this thread. 

    If not, do you mean that target not work when you clean the project, then build it? Have you check if the copy resources is exists after you clean the project?


    MSDN Community Support Please remember to click &quot;Mark as Answer&quot; the responses that resolved your issue, and to click &quot;Unmark as Answer&quot; if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, April 11, 2018 10:20 AM
  • Hi Leo Liu,

    sorry for late reply,

    Yes I am saying that target not work when I clean the project, then build it. When I clean the build then all items from build directory get wiped out and target could not files to copy from source to destination.

    I have a scenario where I need to copy the project build to a specific directory from where other DevOps team can pick them deploy to Azure.

    Wednesday, April 25, 2018 8:32 AM