为什么在发布Web App时未获取对WebJob的更改? [英] Why are changes to my WebJob not being picked up when publishing the Web App?

查看:58
本文介绍了为什么在发布Web App时未获取对WebJob的更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个已部署到Azure的ASP.NET MVC Web应用程序.VS 2013 Pro中的解决方案有3个项目:

I have an ASP.NET MVC Web App which is deployed to Azure. The solution within VS 2013 Pro has 3 projects:

  • Web App项目
  • 一个Webjob项目
  • 一个普通项目,用于存储App和Webjob都通用的代码.

通过 Add->将Webjob项目添加到主App项目中.新的Azure Webjob项目上下文菜单,它实际上在同一解决方案内添加了一个新项目,很好.

The Webjob project was added to the main App project via the Add --> New Azure Webjob Project context menu, which actually adds a new project within the same solution, which is fine.

当我最初将应用程序发布到Azure时,也已经部署了Webjob,并且一切正常.该Webjob每天按计划运行一次.

When I initially published the app to Azure, the Webjob was deployed too and all is working as expected. The Webjob runs on schedule once per day.

现在,我已经对Webjob进行了一些本地更改,并且需要发布这些更改.我遵循相同的过程来部署该应用程序( rtClick主应用程序->发布),该应用程序也应提取对Webjob的更改,但是预览"窗格未获取更改,并且所做的更改是然后没有发布到Webjob.

Now I've made some local changes to the Webjob and need those changes to be published. I follow the same process to deploy the App (rtClick main App --> Publish) which should also pick up changes to the Webjob, but the Preview pane is not picking up the changes and the changes are then subsequently not published to the Webjob.

顺便说一句,我对Common项目所做的任何更改都被成功提取,因此,进行更改和发布Webjobs看起来有些怪异.

Incidentally, any changes I make to the Common project are picked up successfully so looks like there is something weird about making changes and publishing Webjobs.

以前有人遇到过吗?

推荐答案

我已经找到了问题的原因.实际上很简单,但也很令人沮丧.

I've found the cause of the problem. It's actually very simple but also pretty frustrating.

发布Web应用程序时,可以选择在目标位置删除其他文件.我一直将此复选框保留为选中状态,因为我无缘无故不喜欢挂起的旧文件.

When publishing the web app, you have the option to Remove additional files at destination. I have always left this checked because I don't like old files hanging around for no reason.

您还可以选择从App_Data文件夹中排除文件,我也始终保持选中状态,以便根据上面的删除配置,不会删除 App_Data 中的文件.然后,我通常将NLog日志文件,ELMAH xml文件等配置为安全地放入 App_Data 中,因为其中不会删除任何内容.

You also have the option to Exclude files from the App_Data folder which I also always leave checked so that files from App_Data are not deleted based on the remove configuration above. I then usually configure things like NLog log files, ELMAH xml files etc to go into App_Data safe in the knowledge that anything in there won't be deleted.

因此,Webjobs的问题在于它们已部署到 App_Data 中.因此,如果选中了从App_Data文件夹中排除文件,那么在发布该应用程序时,它将按照所告知的内容进行操作,而忽略了 App_Data ,因此将忽略对Webjob的更改.

So the issue with Webjobs is that they're deployed into App_Data. So if the Exclude files from App_Data folder is checked then when the app is published, it's doing what it's told and ignoring App_Data and hence ignoring the changes to the Webjob.

因此,简单的解决方案是取消选中此选项,并且Webjob已成功部署.但是,现在的问题是 App_Data 中的所有其他文件(日志文件等)将被删除.

So the simple solution is to uncheck this option and the Webjob is deployed successfully. However the issue now is that all other files in App_Data will be deleted (log files etc).

因此,您可以取消选中删除文件"配置,但这可能会留下其他不需要的文件.不理想.

So you could uncheck the remove files config but that then potentially leaves other unwanted files lying around. Not ideal.

另一种选择是保留删除配置,在发布之前单击发布"对话框中的预览"按钮,然后手动取消选中您不想删除的每个文件.但是,如果您要保留的任何文件位于 App_Data 的子文件夹中,则发布过程将失败. App_Data/logs .

The other option is to leave the remove config checked, click the Preview button within the Publish dialog prior to publishing, then manually unchecking every file you don't want deleted. However the publish process fails if any of the files you want to keep are within sub-folders within App_Data e.g. App_Data/logs.

因此,另一种选择是将要保留在 App_Data 中的所有文件移到 App_Data 的根目录,然后在预览"窗口中取消选中每个文件在发布之前.一次完成并没有什么大不了的,但是在多次发布时就变得乏味.

So the other option is to move all of the files within App_Data that you want to keep into the root of App_Data, then uncheck each of them within the Preview window prior to publishing. Not a huge deal when done once but becomes tedious when publishing lots of times.

我意识到我可以将日志文件等移动到Azure存储,SQL DB等中,但是如果其他代码在 App_Data 中需要保留,该怎么办? App_Data 并非仅适用于Webjobs,但是如果您还将 App_Data 用于其他用途,则使用Webjobs会造成一些尴尬的情况.

I realise I could move log files etc to Azure storage, SQL DBs etc but what if it's the case that other files are in App_Data which need to be kept? App_Data isn't solely intended for Webjobs but using Webjobs creates a bit of an awkward situation if you also use App_Data for other things.

渴望知道我是否在这里缺少任何明显的东西吗?

Be keen to know if I'm missing anything obvious here?

这篇关于为什么在发布Web App时未获取对WebJob的更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆