Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-40706

MSBuild Plug-In Injects Bad Characters into Project Files in Jenkins 2.38

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Not A Defect
    • Component/s: msbuild-plugin
    • Labels:
      None
    • Environment:
      Windows Server 2012 R2 with Microsoft Build Tools 2015 and Jenkins 2.38
    • Similar Issues:

      Description

      We are in the process of attempting to migrate from CruiseControl.NET to Jenkins, and as part of this effort we wrote a new MSBuild based build (project file is attached). Despite the build working fine from the Windows command line outside of Jenkins, when an attempt is made to use the MSBuild plug-in – the following error appears in the build console output:

      {{13:01:48 Path To MSBuild.exe: msbuild.exe
      13:01:50 Executing the command cmd.exe /C " msbuild.exe /v:detailed .\Autobuild\fusion_auto_build.msbuild " && exit %%ERRORLEVEL%% from D:\Fusion workspaces\Fusion test build 4
      13:01:50 [Fusion test build 4] $ cmd.exe /C " msbuild.exe /v:detailed .\Autobuild\fusion_auto_build.msbuild " && exit %%ERRORLEVEL%%
      13:01:50 Microsoft (R) Build Engine version 4.6.1085.0
      13:01:50 [Microsoft .NET Framework, version 4.0.30319.42000]
      13:01:50 Copyright (C) Microsoft Corporation. All rights reserved.
      13:01:50
      13:01:50 Build started 12/28/2016 6:01:50 PM.
      13:01:50 Project "D:\Fusion workspaces\Fusion test build 4\Autobuild\fusion_auto_build.msbuild" on node 1 (default targets).
      13:01:50 Building with tools version "4.0".
      13:01:50 D:\Fusion workspaces\Fusion test build 4\Autobuild\fusion_auto_build.msbuild(140,11): error MSB4025: The project file could not be loaded. ' ', hexadecimal value 0x1A, is an invalid character. Line 140, position 11.
      13:01:50 Done Building Project "D:\Fusion workspaces\Fusion test build 4\Autobuild\fusion_auto_build.msbuild" (default targets) – FAILED.
      13:01:50
      13:01:50 Build FAILED.
      13:01:50
      13:01:50 "D:\Fusion workspaces\Fusion test build 4\Autobuild\fusion_auto_build.msbuild" (default target) (1) ->
      13:01:50 D:\Fusion workspaces\Fusion test build 4\Autobuild\fusion_auto_build.msbuild(140,11): error MSB4025: The project file could not be loaded. ' ', hexadecimal value 0x1A, is an invalid character. Line 140, position 11.
      }}
      The issue is that line 140, position 11 is EOF character in our MSBuild project file, so we suspect that the MSBuild plug-in with Jenkins is injecting an unprintable, non-ASCII character to MSBuild which is the problem.

      Once again, please note that if we issue the msbuild.exe command outside of Jenkins, this project file works fine.

        Attachments

          Activity

          Hide
          marshall777 Lionel Cabasson added a comment -

          Hello,

          The plugin does not alter the msbuild file, it simply runs msbuild.exe.
          It may come from the way your project retrieve the msbuild file (through source control for example).
          I would do the following tests :

          • Try to run the msbuild command line manually giving it the msbuild file located in the workspace folder (D:\Fusion workspaces\Fusion test build 4\Autobuild\fusion_auto_build.msbuild if I read the log well).
          • Run it from the machine running Jenkins and another computer.
          • Compare the hashes of the msbuild file located in the workspace and the one you ran successfully
          Show
          marshall777 Lionel Cabasson added a comment - Hello, The plugin does not alter the msbuild file, it simply runs msbuild.exe. It may come from the way your project retrieve the msbuild file (through source control for example). I would do the following tests : Try to run the msbuild command line manually giving it the msbuild file located in the workspace folder (D:\Fusion workspaces\Fusion test build 4\Autobuild\fusion_auto_build.msbuild if I read the log well). Run it from the machine running Jenkins and another computer. Compare the hashes of the msbuild file located in the workspace and the one you ran successfully
          Hide
          noahkaufman Noah Kaufman added a comment -

          Thank you for responding to this Jira ticket.

          Respectfully, we did try to run the build manually from the command from the location where the MSBuild project file is located, and it works fine. We have also tried running the build on separate machines, and this MSBuild project file has worked fine.

          We also did try comparing the file hashes and saw no difference; the values were the same. The only difference we can see is when the Jenkins uses the MSBuild plug-in to invoke MSBuild – so something is different between running msbuild.exe under the Jenkins plug-in versus the command line.

          Show
          noahkaufman Noah Kaufman added a comment - Thank you for responding to this Jira ticket. Respectfully, we did try to run the build manually from the command from the location where the MSBuild project file is located, and it works fine. We have also tried running the build on separate machines, and this MSBuild project file has worked fine. We also did try comparing the file hashes and saw no difference; the values were the same. The only difference we can see is when the Jenkins uses the MSBuild plug-in to invoke MSBuild – so something is different between running msbuild.exe under the Jenkins plug-in versus the command line.
          Hide
          noahkaufman Noah Kaufman added a comment -

          Since this is a new build being developed, the msbuild file is not kept in source control; instead it is being developed in a separate directory on the build server and is copied into the workspace once all the source files are populated as part of a Jenkins pipeline.

          Show
          noahkaufman Noah Kaufman added a comment - Since this is a new build being developed, the msbuild file is not kept in source control; instead it is being developed in a separate directory on the build server and is copied into the workspace once all the source files are populated as part of a Jenkins pipeline.
          Hide
          noahkaufman Noah Kaufman added a comment -

          You were right; there was a subtle bug in the copy process under Jenkins. The copy process was attempting to copy the MSBuild project as an ASCII file which inserted an EOF character that MSBuild could not handle. Once we changed the copy process to handle the MSBuild project file as a BINARY file, all worked as designed.

          This ticket can be closed. Thank you for your help and assistance.

          Show
          noahkaufman Noah Kaufman added a comment - You were right; there was a subtle bug in the copy process under Jenkins. The copy process was attempting to copy the MSBuild project as an ASCII file which inserted an EOF character that MSBuild could not handle. Once we changed the copy process to handle the MSBuild project file as a BINARY file, all worked as designed. This ticket can be closed. Thank you for your help and assistance.
          Hide
          marshall777 Lionel Cabasson added a comment -

          Glad you found the solution.
          Thanks for sharing it.

          Show
          marshall777 Lionel Cabasson added a comment - Glad you found the solution. Thanks for sharing it.

            People

            Assignee:
            marshall777 Lionel Cabasson
            Reporter:
            noahkaufman Noah Kaufman
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: