Microsoft.Web.WebJobs.Publish在部署包中生成重复的程序集 [英] Microsoft.Web.WebJobs.Publish producing duplicate assemblies in deploy package

查看:95
本文介绍了Microsoft.Web.WebJobs.Publish在部署包中生成重复的程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有大量的Azure WebJob,它们都部署到单个Azure App Service,以及同一个Azure App Service上的网站.每个WebJob都使用WebJobs SDK和Microsoft.Web.WebJobs.Publish nuget包(我们是1.0.13版的最新版本)来打包它们以进行部署.以下是我们在CI构建(VSTS)中用于生成部署程序包的MSBuild参数:

I have a large number of Azure WebJobs that all deploy to a single Azure App Service, along with a Website on the same Azure App Service. Each WebJob all use the WebJobs SDK and the Microsoft.Web.WebJobs.Publish nuget package (we are up-to-date with version 1.0.13) to package them up for deployment. The following are the MSBuild arguments we use in the CI build (VSTS) to produce the deploy package:

/p:DeployOnBuild=true /p:PublishProfile=Release /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation=$(Build.StagingDirectory)

这会产生一个与"Azure Web Service Deploy" VSTS任务一起正常工作的程序包(因为WebJobs可以作为WebJobs正常运行),这不是问题.

This produces a package that works fine (in that the WebJobs run correctly as WebJobs) with the "Azure Web Service Deploy" VSTS task, that isn't the problem.

问题是.zip文件包复制了所有WebJob程序集.这些重复项最终将其复制到Azure应用服务中.

The problem is that the .zip file package duplicates all the WebJob assemblies. These duplicates end up making it out to the Azure App Service.

每个WebJob软件包的.zip文件中的文件夹结构为:

The folder structure in each WebJob package's .zip file is:

- Content/[build agent full path]/
     - app_data/jobs/continuous/[web job name]/[assembly files]
     - bin/[assembly files]

这引起问题的原因有3个:

This causes a problem for 3 reasons:

  1. 我们已经开始调查与安全供应商的合作伙伴,他们将对我们的部署程序包进行静态分析.重复会导致报告问题.
  2. 由于bin/[assembly files]出现在App Service中,因此它们与网站的程序集相互混合,而该程序集也已部署到同一App Service中.
  3. 通过在这些部署程序包中转移所有这些额外的膨胀,会减慢我们的构建/发布时间.我的团队练习持续交付",并希望管道能够快速完成.
  1. We've started investigating partnering with a security vendor who will perform static analysis our our deployment packages. This duplication causes reporting issues.
  2. Because the bin/[assembly files] makes it out to the App Service, they get inter-mixed with the assemblies for the Website that is also deployed to the same App Service.
  3. Our build / release time is slowed down by transferring all this extra bloat in these deployment packages. My team practices Continuous Delivery and expects the pipeline to be fast.

那么为什么Microsoft.Web.WebJobs.Publish包除了必需的app_data/jobs/continuous/[WebJobName]/[assembly files]之外又添加到bin/[assembly files]中?更重要的是,如何防止包装过程包含bin/[assembly files]?

So why does the Microsoft.Web.WebJobs.Publish package add in the bin/[assembly files] in addition to the required app_data/jobs/continuous/[WebJobName]/[assembly files]? And more importantly, how can I prevent the packaging process from including bin/[assembly files]?

我真的很讨厌不得不增加构建步骤来将压缩后的软件包拆开并放回原处,而又不会产生多余的垃圾,或者我不得不想出一种手工制作已发布软件包的方法.您有1个工作,Microsoft.Web.WebJobs.Publish! :)

I'd really hate to have to add build steps to piece apart the zipped packages and put it back together without the extra junk, or have to figure out a way to hand-craft the publish package. You have 1 job, Microsoft.Web.WebJobs.Publish! :)

推荐答案

我对 44611520/8654143

我必须为现有目标添加一个以上的替代项以使其起作用:

I had to add more than one override for existing targets to make it work:

<Target Name="CollectFilesFromContent" />
<Target Name="CollectFilesFromReference" />
<Target Name="CollectFilesFromIntermediateAssembly" />
<Target Name="CollectFilesFrom_SourceItemsToCopyToOutputDirectory" />

如何找到它?

1)使用/verbosity:diag

2)检查日志并查找DestinationRelativePath=bin;会有相关的条目FromTarget=SomeTargetName

2) Inspect the log and look for DestinationRelativePath=bin; there will be related entry FromTarget=SomeTargetName

3)将<Target Name="SomeTargetName" />添加到.csproj

您应该以标有FromTarget=PublishWebJob的条目结尾.

You should end with entries marked with FromTarget=PublishWebJob.

我认为可以以某种方式过滤FilesForPackagingFromProject变量的内容(可能覆盖CustomCollectFiles目标并在那里修改FilesForPackagingFromProject),但我不知道msbuild不够好.

I think it is possible to filter contents of FilesForPackagingFromProject variable somehow (probably override CustomCollectFiles target and modify FilesForPackagingFromProject there) but I don't know msbuild good enough.

这篇关于Microsoft.Web.WebJobs.Publish在部署包中生成重复的程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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