Why do Teamcity binaries from SLN builds differ from MSbuild/etc?

I am finding the size of the binaries differ when I build from Teamcity / SLN option vs manually in VS2008 or using msbuild on the commandline. Why would that be?

13 comments
Comment actions Permalink

Hello,

There are many things that could affect the built artifact size (e.g. files timestamps, OS patches). Event more, any new build from VS/MSBuild will likely have another sizes of binaries.

Do you see drasic changes between files? If so, you need to investigate conditions in your build script to ensure you run same set of commands under TC.

0
Comment actions Permalink

>There are many things that could affect the built artifact size (e.g. files timestamps, OS patches).

I have investigated this quite extensively. That is all kept constant.

>Event more, any new build from VS/MSBuild will likely have another sizes of binaries.

I'm not sure what you mean by that?

>Do you see drasic changes between files? If so, you need to investigate conditions in your build script to ensure you run same set of commands under TC.

One thing that is certain is that I cannot set the FileAlignment; my question on that is not answered;

http://devnet.jetbrains.net/thread/433306?tstart=0

How to use  "Build Parameters" instead of "/property:" for MSBuild commandline param?

However, I'm concerned there are perhaps other differences. We are getting like LE 50KB of size difference.

I thought perhaps you would have done QA on a TC "VS2008 SLN" build and compared its binaries to a manually built build with MSBuild.

Have you done that and seen or not seen differences?

0
Comment actions Permalink

Please try to run same build with rebuild options locally to make sure you receive same binaries.

0
Comment actions Permalink

>Please try to run same build with rebuild options locally to make sure you receive same binaries.
I'm sorry I'm not sure what you mean? If you mean have I checked with and without fileAlignment setting with msbuild manually, now that I have all my fixes so that the projects should take care of their alignments on their own, the sizes do not differ.


My whole question is why when I run MsBuild in the CLI manually (with fileAlignment) and check vs the teamcity/SLN/Vs2008 binaries they do not match. That is my question.
They are significantly bigger, like 17kB on our largest/output exe.
Looking in hex, there are a number of regions where it appears that Teamcity adds extra date handling to the exe; see the screenshot.



Attachment(s):
120117.PM-4532.TeamcitySlnVs2008.LargerWithGregorianDate.jpg
0
Comment actions Permalink

Does it work if you add /property:FileAlignment=XXX as a custom parameter to MSBuild?
If yes, than you may convert the commandline argument into build system property.

Do you have the same option in Visual Studio? Please try making the change there, but note project configuration.

BTW. Could you please check build configuration you use in VS and in TeamCity. By default MSBuild uses configuration called "Debug"

0
Comment actions Permalink

hi Eugene,
>Does it work if you add /property:FileAlignment=XXX as a custom parameter to MSBuild?
You mean on the CLI? That is what I'm doing, eg
msbuild ..\..\mysolutionitem.sln /target:Clean;Build /p:Configuration=Release /p:Platform="Any CPU" /p:Filealignment=512

>If yes, than you may convert the commandline argument into build system property.
Again, if I understand you right, that means because the above worked, it should work as a TC system property. I see no evidence it worked.

>Do you have the same option in Visual Studio? Please try making the change there, but note project configuration.
All that has been gone through very extensively. I have worked with Microsoft and determined exactly how it should/not work. I am doing it correctly there. The big MS takeaway is that Msbuild builds may differ from VS GUI builds.

You are using Msbuild, though, per the wrapper command I see, right, not devenv? So in  your case neither the GUI nor the devenv are strictly applicable and I should just compare msbuild command, above, to your output.

That is what does not match.
I wish this could be a phone call I am typing-tired!

0
Comment actions Permalink

I still would like help on this please .

:)
0
Comment actions Permalink

Hello,

Please sorry for delay in reply.
We use MSBuild.exe to run .sln builds in TeamCity.
If you like to use Visual Studio for it (i.e. devenv.exe), please vote for the issue:
http://youtrack.jetbrains.net/issue/TW-5385

Please add debug output to some project to ensure you specified the right property. Recently we changed our minds about msbuild/visual studio solution runner warnings for usage of /p or /property arguments

/p:Aaa=BBB is equivalent to add a property system.Aaa with value BBB into the build configuration "properties and environment variables" section.
To diagnose msbuild issues, consider to add "/v:diag" commandline argument to make msbuild dump more information about the build.

0
Comment actions Permalink

Finally! I'm so relieved, it did take. Thank you.

In the box for Command line parameters, I entered:   /Property:FileAlignment=filealignment v:diag
Then the output tab for Build Parameters shows:

User Defined Parameters

Name Value passed to build
system.filealignment 512
system.verbosity diagnostic
0
Comment actions Permalink

Hmm, oops I marked answered but actually the answer I clicked helps me workaround but doesn't answer the question.

I need to to another task but will think about if I need more.

Ideally I would like to know why they don't match; maybe now that I add this info I will be ok.

0
Comment actions Permalink

Hello,

I checked that it is possible to specify FileAlignment from outside of the build.
By default, MSBuild treats all environment variables as properties. So if you have filealignment environment variable defined on the machine it may affect the build.

Please check in project files you specify file alignment explicitly, there should be something link:
<PropertyGroup>
<FileAlignment>512</FileAlignment>
</PropertyGroup>

Note, that the value could be redefined with coditional expressions below.

I checked that MSBuild /p:FileAlignment=512 parameter overrides setting in project.
Setting in project overrides environent variable value.

Hope this shed light to the issue. Most likely, you suffer from environment/software/defaults settings issues.
To make sure, please consider running msbuild from commandline the same used account under the same agent.

You may also note that file size could depend configuration you build and on resources you include assemblies.
For more details please refer to Microsoft documentation on MSBuild and Deven.exe.

0
Comment actions Permalink

hi Eugene!

>I checked that MSBuild /p:FileAlignment=512 parameter overrides setting in project.

On my TC v7 I could set it to 512 but 4096 would not take. However, I do have in my csproj files set to 512. So does that explain why I wouldn't be able to change it?

0
Comment actions Permalink

There were no changed between 6.5 and 7.0 regarding parameters passing to MSBuild.
The value of the property may be changed in the build script. Please check what value was sent to build and what parameter value do you see in csc.exe calls.
It may be required to specify Rebuild target to enforce MSBuild to rebuild all assemblies.
Do you use some custom scriptions inside *proj files? If so, please make sure those scrits does not chnage the value of the property.

0

Please sign in to leave a comment.