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

Encoding problem when writing file on windows.

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Andy Hush says:
      I'm having the sample problem. Version 1.4.1 of the plug-in. A question mark is ...

      I'm having the sample problem. Version 1.4.1 of the plug-in. A question mark is inserted as the first character of every AssemblyInfo.cs. msbuild fails with:

      Properties\AssemblyInfo.cs(1,1): error CS0116: A namespace cannot directly contain members such as fields or methods

      I think it's a real question mark, not a unicode indicator.

      EDIT: Looking at the code, FilePath.readToString() and write() are used. According to the documentation, readToString() uses "current system encoding". For Windows, that is code page 932, aka windows-31j. However, my AssemblyInfo.cs files are UTF-8. I believe that Visual Studio uses UTF-8 by default. So perhaps the solution is to use core Java classes that can deal with different encodings. I am not a Java programmer, so I don't know what those would be.

      Source : https://wiki.jenkins-ci.org/display/JENKINS/Change+Assembly+Version

        Attachments

          Issue Links

            Activity

            Hide
            jenkinsnewbie Abhi Nebarsu added a comment -

            I am also having the same issue. One thing I noticed is when I picked the failed build files, load the solution in Visual Studio and looked at the Encoding of Abc.cs file and AssemblyInfo.cs file, the former is having the "Unicode (UTF-8 with signature)" Encoding and the later has the "Western European (Windows)" encoding. not sure if this helps to find the root cause

            Show
            jenkinsnewbie Abhi Nebarsu added a comment - I am also having the same issue. One thing I noticed is when I picked the failed build files, load the solution in Visual Studio and looked at the Encoding of Abc.cs file and AssemblyInfo.cs file, the former is having the "Unicode (UTF-8 with signature)" Encoding and the later has the "Western European (Windows)" encoding. not sure if this helps to find the root cause
            Hide
            mate Mattias Jiderhamn added a comment -

            I'm seeing the same problem. I believe the reason is that Visual Studio not only uses UTF-8 encoding in the AssemblyInfo.cs/.vb files, but also adds a UTF-8 BOM (Byte Order Mark) at the beginning of the file. Seems that the change-assembly-version-plugin then fails to ignore the BOM and "converts" those bytes into "?" characters, which are written to the updated file.

            The workaround I found was to open the AssemblyInfo file in some text editor (TextPad in my case) and save as UTF-8 but without BOM. Then the plugin works.

            Show
            mate Mattias Jiderhamn added a comment - I'm seeing the same problem. I believe the reason is that Visual Studio not only uses UTF-8 encoding in the AssemblyInfo.cs/.vb files, but also adds a UTF-8 BOM (Byte Order Mark) at the beginning of the file. Seems that the change-assembly-version-plugin then fails to ignore the BOM and "converts" those bytes into "?" characters, which are written to the updated file. The workaround I found was to open the AssemblyInfo file in some text editor (TextPad in my case) and save as UTF-8 but without BOM. Then the plugin works.
            Hide
            leslied Desiree Leslie added a comment -

            @Mattias - I had the same problem and the work-around was just the thing. Thanks for the update.

            Show
            leslied Desiree Leslie added a comment - @Mattias - I had the same problem and the work-around was just the thing. Thanks for the update.
            Show
            tjormola tjormola added a comment - Proposed fix at https://github.com/jenkinsci/change-assembly-version-plugin/pull/10

              People

              • Assignee:
                Unassigned
                Reporter:
                leonardokobus Leonardo Kobus
              • Votes:
                1 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: