简体   繁体   English

msbuild 的行为与命令行和 Jenkins 不同

[英]msbuild behaving differently from command line vs Jenkins

I have a Jenkins job that creates and deploys a website package.我有一个 Jenkins 工作来创建和部署一个网站包。

When I run the job from Jenkins it creates a package for each project and the deployment package doesn't contain the webjobs.当我从 Jenkins 运行作业时,它为每个项目创建一个包,并且部署包不包含 webjobs。 However, the same msbuild command from command line it does create a package file bigger including the webjobs in it.但是,来自命令行的相同 msbuild 命令确实创建了一个更大的包文件,其中包括 webjobs。

I have tried running the msbuild command line using the same user account Jenkins service and does work as well.我已经尝试使用相同的用户帐户 Jenkins 服务运行 msbuild 命令行并且也能正常工作。

If I compare both msbuild output logs, I get a few differences being the main difference the command line msbuild log includes:如果我比较两个 msbuild 输出日志,我会发现一些差异是命令行 msbuild 日志包括的主要区别:

Target "DiscoverWebJobs" in file "E:\Jenkins\jobs\Queue - Publish\workspace\tvdQueue\packages\Microsoft.Web.WebJobs.Publish.1.0.12\tools\webjobs.wap.targets" from project "E:\Jenkins\jobs\Queue - Publish\workspace\tvdQueue\WebAPI\WebAPI.csproj" (target "Build" depends on it):
    Task "Message"
      WebJobs: reading [E:\Jenkins\jobs\Publish job\workspace\Project\WebAPI\Properties\webjobs-list.json]
    Done executing task "Message".
    Using "ReadWebJobsConfigFile" task from assembly "E:\Jenkins\jobs\Publish job\workspace\Project\packages\Microsoft.Web.WebJobs.Publish.1.0.12\tools\Microsoft.Web.WebJobs.Publish.Tasks.dll".
    Task "ReadWebJobsConfigFile"
    Done executing task "ReadWebJobsConfigFile".
    Task "Message"
      WebJobs: WebJobs found: [../blah1.csproj;../blah2.csproj;../blah3.csproj;]
    Done executing task "Message".
    Done building target "DiscoverWebJobs" in project "WebAPI.csproj"

I tried to add the target "DiscoverWebJobs" in the Jenkins command line but it says it cannot be found... I've spent loads of time trying different options, running from different accounts, using powershell, ... but nothing and I'm sure is something silly.我试图在 Jenkins 命令行中添加目标“DiscoverWebJobs”,但它说找不到……我花了很多时间尝试不同的选项,从不同的帐户运行,使用 powershell,……但没有,我肯定是愚蠢的事情。

If the zip package file doesn't include the webjobs files, when I do the deployment it doesn't update the webjobs.如果 zip 包文件不包含 webjobs 文件,则在我进行部署时它不会更新 webjobs。 I could deploy each zip file separately but there are a few webjobs and if anyone includes a new one it would not be deployed making the continuous integration setup for this project useless.我可以单独部署每个 zip 文件,但是有一些 webjobs,如果有人包含一个新的,则不会部署它,从而使该项目的持续集成设置无用。

Examining webjobs.wap.targets and webjobs.targets from the Microsoft WebJobs Publish 1.0.12 nuget package, the following msbuild parameters affect whether the DiscoverWebJobs target runs.检查来自Microsoft WebJobs Publish 1.0.12 nuget 包的webjobs.wap.targetswebjobs.targets ,以下 msbuild 参数会影响DiscoverWebJobs目标是否运行。 You can set/override their values using the /p: switch with msbuild.您可以使用/p:开关和 msbuild 设置/覆盖它们的值。

  • SkipApp_DataFolder (needs to be False ) SkipApp_DataFolder (需要为False
  • WebJobsExtendWebPublish (needs to be true ) WebJobsExtendWebPublish (需要为true
  • WebJobsConfigFile (a file needs to exist at that path) WebJobsConfigFile (该路径需要存在一个文件)

You should not need to set/override that last one if the following file exists: E:\\Jenkins\\jobs\\Queue - Publish\\workspace\\tvdQueue\\WebAPI\\Properties\\webjobs-list.json .如果存在以下文件,则不需要设置/覆盖最后一个: E:\\Jenkins\\jobs\\Queue - Publish\\workspace\\tvdQueue\\WebAPI\\Properties\\webjobs-list.json

Finally is working!终于开始工作了! The fix for me was removing a duplicated "Microsoft.Web.WebJobs.Publish" targets import in all the csproj files in the solution.对我的修复是删除解决方案中所有 csproj 文件中重复的“Microsoft.Web.WebJobs.Publish”目标导入。

<Import Project="..\\packages\\Microsoft.Web.WebJobs.Publish.1.0.11\\tools\\webjobs.targets" Condition="Exists('..\\packages\\Microsoft.Web.WebJobs.Publish.1.0.11\\tools\\webjobs.targets')" /> <Import Project="..\\packages\\Microsoft.Web.WebJobs.Publish.1.0.11\\tools\\webjobs.targets" Condition="Exists('..\\packages\\Microsoft.Web.WebJobs.Publish.1.0.11 \\tools\\webjobs.targets')" />

<Import Project="..\packages\Microsoft.Web.WebJobs.Publish.1.0.12\tools\webjobs.targets" Condition="Exists('..\packages\Microsoft.Web.WebJobs.Publish.1.0.12\tools\webjobs.targets')" />

I had versions 1.0.11 and 1.0.12 so I removed the old one and it creates the full package including the webjobs.我有 1.0.11 和 1.0.12 版本,所以我删除了旧版本,它创建了包括 webjobs 在内的完整包。

Not sure why running msbuild from Jenkins or from command line in the same machine would have any different effect with those duplicated targets but...不知道为什么在同一台机器上从 Jenkins 或命令行运行 msbuild 会对那些重复的目标产生任何不同的影响,但是......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM