Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#373399 - 22/07/2021 18:20 C# compilation question - Formatted strings compiling differently?
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31597
Loc: Seattle, WA
I'm rubbing the EmpegBBS genie lamp here, I'm hoping someone might know this one...

I'm in the process of converting our company's Build/CI/CD system from Team City to Azure DevOps Pipelines. One of my tasks is to move our product's main compilation step (which is done with MSBuild version 15.0 aka VS2017) to run on a different set of build agent machines, triggered by a different set of processes.

I'm checking to be sure that the resulting compiled executables are more-or-less the same on the new system as they were on the old system. I know that it's normal for some things to be different, I'm not expecting them to be binary-identical. However, I'm seeing a significant difference which looks like a compiler-settings kind of thing, and I'm wondering if anyone recognizes this particular difference. What am I getting wrong in the compiler settings? I'm worried that this is some kind of canary in the coal mine which indicates I've missed something important in my configuration settings.

I've done a "dump" of a particular DLL in our artifact set using the ILDASM tool, and I see this interesting difference in the "User Strings" section. The Azure DevOps Pipeline build is "baking in" some of the format-strings, whereas the Team City build leaves them separated. An example screen shot from Beyond Compare is attached below, to make my question clear.

Does anyone know what compiler optimization setting controls this thing shown in the screen shot? For example, a command line parameter to MSBuild or something.

Thanks!







Attachments
Dump Diff.png (261 downloads)

_________________________
Tony Fabris

Top
#373400 - 22/07/2021 19:03 Re: C# compilation question - Formatted strings compiling differently? [Re: tfabris]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31597
Loc: Seattle, WA
Clarifying a few things which I know will come up:

- Both outputs are from a Release configuration, therefore the default compiler optimizations should be "on" for both builds.

- Both outputs are from the same set of source code and project files.

- The version of MSBuild might be slightly different between the two, but they should both be basically MSBuild version 15.

- I tried adding the /deterministic parameter to the command line of MSBuild and it failed, saying that it didn't recognize that parameter.

- I tried adding <Deterministic>true</Deterministic> to the CSPROJ file of one of the modules as described here, and the files still differed in the same way. I'm thinking the flag was simply ignored in the project file.

- Actually I notice that when MSBuild calls out to the Roslyn compiler (csc.exe), it adds "/deterministic+" to every one of them already anyway. Here's an example output (some filenames blurred on purpose):
Code:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Roslyn\csc.exe
/noconfig /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /define:TRACE /highentropyva+
/reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\mscorlib.dll"
/reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Core.dll"
/reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.dll"
/debug:pdbonly /filealign:512 /optimize+
/out:obj\Release\***************.dll
/ruleset:d:\_work\1\s\Development\***********.ruleset
/subsystemversion:6.00 /target:library /warnaserror+ /utf8output /deterministic+
**********.cs **********.cs **********.cs **********.cs **********.cs (etc)


Though I don't know what the "plus sign" means after the parameter. There are a few parameters with the plus sign after them. Any idea what those mean?
_________________________
Tony Fabris

Top
#373401 - 23/07/2021 00:04 Re: C# compilation question - Formatted strings compiling differently? [Re: tfabris]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31597
Loc: Seattle, WA
Aha, that's interesting... Looks like the Team City build logs do not show the "/deterministic+" flag on them, and the Azure Pipeline builds do. That's the only difference between the two sets of log outputs. That might be the whole thing. Now I have to figure out where that's controlled, deep in our configuration files somewhere.

Update: Actually, some of the modules have it and some of them don't. The one I was examining didn't have it originally, and when I added the <Deterministic>true</Deterministic>, the parameter showed up and was used in the CSC command line. Yet the files still had the same differences. So back to square one.

_________________________
Tony Fabris

Top
#373407 - 24/07/2021 17:02 Re: C# compilation question - Formatted strings compiling differently? [Re: tfabris]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31597
Loc: Seattle, WA
Got it.

The solution turned out to be slight differences in compiler optimizations between minor dot-versions of Visual Studio. When I upgraded the VS version on one of the old system's Team City build agents, and ran a build there, its differences from the Azure Pipeline build became very minor.
_________________________
Tony Fabris

Top