vsts-assemblyinfo-task icon indicating copy to clipboard operation
vsts-assemblyinfo-task copied to clipboard

How to fix iso-8859-2 Encoding warning?

Open SymbioticKilla opened this issue 1 year ago • 3 comments

##[warning]Detected file encoding (iso-8859-2) is different to the one specified (utf-8). Hi,

my .csproj file ist utf-8 and task is also with utf-8 encoding: image image

Everything works fine incl. copyright symbol ©.

I just want to remove warning message.

Thanks!

SymbioticKilla avatar Jun 13 '23 12:06 SymbioticKilla

Ran into same issue recently. Is there any plan to fix this? Thanks

petersladek avatar Sep 04 '24 10:09 petersladek

I had the same issue, but was able to fix it for myself adding BOM to my CSPROJ files. So all I did was opening my CSPROJ files and then save them using the encoding UTF-8 with BOM (in VS Code). This makes sure the task correctly detects the file as UTF-8.

bothzoli avatar Sep 05 '24 01:09 bothzoli

By the way it also seems to be an easy fix to add a "supress file encoding warnings" flag, and change the following part:

https://github.com/BMuuN/vsts-assemblyinfo-task/blob/6369290d2ca61302bbadbfbd60241419e01f8910/src/netframework/index.ts#L229-L240

as such:

 function setFileEncoding(file: string, model: models.NetFramework) { 
     const encoding = getFileEncoding(file); 
     logger.debug(`Detected file encoding: ${encoding}`); 
  
     model.detectedFileEncoding = model.fileEncoding; 
  
     if (model.fileEncoding === 'auto') { 
         model.detectedFileEncoding = encoding; 
     } else if (model.fileEncoding !== encoding && !model.supressFileEncodingWarnings) { // <-- CHANGE HERE
         logger.warning(`Detected file encoding (${encoding}) is different to the one specified (${model.fileEncoding}).`); 
     } 
 } 

I'm happy to make a PR for this if required, however I think adding the BOM to the files should be sufficient. However, it'd probably be best to add that to the documentation (maybe here?), which I'm also happy to do.

bothzoli avatar Sep 05 '24 02:09 bothzoli