Deploy subfolders for Azure WebJob

南笙酒味 提交于 2019-11-30 03:29:17

问题


I'm deploying a WebJob to Azure using Visual Studio, but none of the subdirectories in the build output folder of the project are copied to Azure (as per looking in the FTP folder and by virtue of the app not executing correctly). Is there any way to get the deploy to copy all the files and folders across?

More info: the subdirectories are from a referenced project and the files do have "Copy Always" set. They do appear in the output build directory of the WebJob project

UPDATE: So it seems that at some point this was fixed and now works as expected


回答1:


Thank you for reporting this. It looks like a bug in the tooling. I filed a bug for it.




回答2:


I hacked together an automated deployment that seems to be work so far:

Add your WebJob project as a build dependency to your website project

I deploy my WebJob to a standalone Azure Website, so the website didn't reference the project directly. I don't want the build output of the WebJob project included in the bin of the website, just the proper app_data path. If you're not worried about MSBuild compatibility, you can set the build dependency using Visual Studio. Or you can edit the website project and add a reference with the other <Reference> tags:

<ProjectReference Include="..\PathToJobs\Jobs.csproj">
  <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>

On PostBuild, copy the WebJob bin output to the magic app_data folder

WebJobs are expected to be in app_data\jobs\[type]\[name], so we copy the WebJob bin to the that folder in the website project:

set webjob_dist_path=$(ProjectDir)app_data\jobs\continuous\Job
IF EXIST "%webjob_dist_path%" (
  RMDIR "%webjob_dist_path" /S /Q
)
XCOPY "$(SolutionDir)Jobs\bin\$(ConfigurationName)\*" "%webjob_dist_path" /Q /E /I /Y

Tell the website to include the WebJob magic folder when it deploys

(see: How do you include additional files using VS2010 web deployment packages?)

<PropertyGroup>
  <CopyAllFilesToSingleFolderForPackageDependsOn>
    CustomCollectFiles;
    $(CopyAllFilesToSingleFolderForPackageDependsOn);
  </CopyAllFilesToSingleFolderForPackageDependsOn>
  <CopyAllFilesToSingleFolderForMsdeployDependsOn>
    CustomCollectFiles;
    $(CopyAllFilesToSingleFolderForPackageDependsOn);
  </CopyAllFilesToSingleFolderForMsdeployDependsOn>
</PropertyGroup>
<Target Name="CustomCollectFiles">
  <ItemGroup>
    <_CustomFiles Include="app_data\jobs\**\*" />
    <FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
      <DestinationRelativePath>%(RelativeDir)%(Filename)%(Extension)</DestinationRelativePath>
    </FilesForPackagingFromProject>
  </ItemGroup>
</Target>

Deploy the website using the normal Azure Publish profiles. Done!



来源:https://stackoverflow.com/questions/26840167/deploy-subfolders-for-azure-webjob

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!