Sometimes SA doesn't give error return codes
nyxling
Posts: 9
I'm using SA v6.8.0.121 and have set it up to run in my TeamCity-based build server-- I've got it all working as desired, except that in some (all?) cases, when SA fails to obfuscate, it doesn't actually give an error (read: non-zero) return code, so TeamCity never knows to flag that step of the build process as having failed.
As it is right now, I need to manually check every build log's obfuscation step to see if SA output any error text, because it'll just happily have an error, and then tell TeamCity that were wasn't one.
An example of where I've seen this happen:
I've since fixed that error, but the fact that we were assuming all was well when it in fact WASN'T is a little concerning. The last thing we want is for obfuscation to fail, and we release thinking it succeeded.
As it is right now, I need to manually check every build log's obfuscation step to see if SA output any error text, because it'll just happily have an error, and then tell TeamCity that were wasn't one.
An example of where I've seen this happen:
[00:07:14]Step 5/5: Obfuscate (Command Line) (30s) [00:07:14]Starting: C:\TeamCity\buildAgent\temp\agentTmp\custom_script6461944242385122991.cmd [00:07:14]in directory: C:\TeamCity\buildAgent\work [00:07:16]SmartAssembly v6.8.0.121 [00:07:16]Copyright ¸ Red Gate Software 2005-2013 [00:07:19]Loading project C:\TeamCity\buildAgent\work\0001/../Obfuscate.saproj [00:07:19]Loading... [00:07:31]Starting... [00:07:31]Analyzing... [00:07:41]Preparing... [00:07:44]Failed [00:07:44]SmartAssembly.InformationException: SmartAssembly has encountered an invalid symbol: [00:07:44] [00:07:44][mscorlib]System.Collections.ArrayList [00:07:44] [00:07:44]The most likely cause is that SmartAssembly has used a different version of a dependency from the version used by Assembly-CSharp.dll. [00:07:44] [00:07:44]If the details below are wrong, please use the MandatoryPath attribute in the .saproj file to ensure that the correct version of the dependency is found. [00:07:44] [00:07:44]Assembly that should contain the missing symbol: C:\TeamCity\buildAgent\work\0001\0001_Data\Managed\mscorlib.dll [00:07:44] [00:07:44] [00:07:44]SmartAssembly has encountered an error while running your project. [00:07:44]Failed: SmartAssembly.InformationException: SmartAssembly has encountered an invalid symbol: [00:07:44] [00:07:44][mscorlib]System.Collections.ArrayList [00:07:44] [00:07:44]The most likely cause is that SmartAssembly has used a different version of a dependency from the version used by Assembly-CSharp.dll. [00:07:44] [00:07:44]If the details below are wrong, please use the MandatoryPath attribute in the .saproj file to ensure that the correct version of the dependency is found. [00:07:44] [00:07:44]Assembly that should contain the missing symbol: C:\TeamCity\buildAgent\work\0001_Build\0001_Data\Managed\mscorlib.dll [00:07:44]Please run SmartAssembly in User-Interface mode for more information. [00:07:45]Process exited with code 0
I've since fixed that error, but the fact that we were assuming all was well when it in fact WASN'T is a little concerning. The last thing we want is for obfuscation to fail, and we release thinking it succeeded.
Comments
Thanks for your post!
I apologize in advance if these questions are a bit stupid! However, I don't have much experience with Team City..
Can I please check:
- Is the .cmd file calling on SmartAssembly.com?
- And is that "Process exited with code 0" referring to the smartassembly.com process or to the overall Team City build?
I did a quick check and when a build fails with that invalid symbol error, it should make smartassembly.com exit with error code 1.
I wonder if there might be some TeamCity setting that could be making the step go through as successful?
(I also found one blog post that mentioned that when running msbuild from powershell, powershell will return 0 even if msbuild fails--I'm not sure if this could be related somehow - http://alsagile.com/post/27403222324/us ... ntegration)
Jessica Ramos | Product Support Engineer | Redgate Software
Have you visited our Help Center?
This is the contents of the .cmd file (it's just a .bat file)
As you can see, there are a few directory/file management lines, but basically it's just calling SmartAssembly, and to answer your questions:
1) Yes, it's calling SmartAssembly.com
2) I'm not 100% sure. I no longer have the failed build on my machine, so I can't check it's log directly, and as such, I don't know definitively whether the "Process exited with code 0" line was collapsed with the rest of the "Step5/5" stuff or not. (it auto-collapses each step's logs to make them separately viewable) HOWEVER, the overall build process was considered a success by TeamCity, and it's designed to detect errors so it can report them as a failed build. That said, if SmartAssembly had returned non-zero, it -should- have caused the entire build to fail.
I suppose there's a chance that there's a bug in TeamCity, but the fact that during configuration, I've gotten tons of errors leading to failed builds has lead me to believe that it's SmartAssembly and not TeamCity. But I'm not discounting the possibility^^
I'll have to take a look at that blog post and see if it applies to my situation, when I have time. I'll be sure to get back to you about that.
AFAIK the copy command sets the errorlevel as well. So if the SA build fails, but the file was created, it gets copied. If copying succeeded, this will return 0.
So the correction would be:
For a while there I was originally thinking that the "Process exited with code 0" actually referred to the commandline process, which would always simply returns 0 when it finished, but testing with a failed copy as the last line proved that suspicion wrong, as it would then return code 1.