简体   繁体   中英

msbuild behaving differently from command line vs Jenkins

I have a Jenkins job that creates and deploys a website package.

When I run the job from Jenkins it creates a package for each project and the deployment package doesn't contain the webjobs. However, the same msbuild command from command line it does create a package file bigger including the webjobs in it.

I have tried running the msbuild command line using the same user account Jenkins service and does work as well.

If I compare both msbuild output logs, I get a few differences being the main difference the command line msbuild log includes:

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.

If the zip package file doesn't include the webjobs files, when I do the deployment it doesn't update the 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.

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. You can set/override their values using the /p: switch with msbuild.

  • SkipApp_DataFolder (needs to be False )
  • WebJobsExtendWebPublish (needs to be true )
  • WebJobsConfigFile (a file needs to exist at that path)

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 .

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.

<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.

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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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