Red Gate forums :: View topic - Sometimes SA doesn't give error return codes
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SmartAssembly 6
SmartAssembly 6 forum

Sometimes SA doesn't give error return codes

Search in SmartAssembly 6 forum
Post new topic   Reply to topic
Jump to:  
Author Message
nyxling



Joined: 31 Mar 2014
Posts: 7

PostPosted: Wed Jul 09, 2014 4:18 pm    Post subject: Sometimes SA doesn't give error return codes Reply with quote

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:
Code:
[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.
Back to top
View user's profile Send private message
jessica.ramos



Joined: 23 Apr 2012
Posts: 235

PostPosted: Thu Jul 10, 2014 10:19 pm    Post subject: Reply with quote

Hi Jed,

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/using-psake-to-run-your-teamcity-continuous-integration)
_________________
Jessica Ramos
Technical Support
Red Gate Software Ltd.
Back to top
View user's profile Send private message
nyxling



Joined: 31 Mar 2014
Posts: 7

PostPosted: Fri Jul 11, 2014 10:26 pm    Post subject: Reply with quote

Hi Jessica,

This is the contents of the .cmd file (it's just a .bat file)
Code:

IF NOT EXIST "0001_Obfuscate" ( mkdir "0001_Obfuscate" )
IF EXIST "0001_Obfuscate\Assembly-CSharp.dll" ( del "0001_Obfuscate\Assembly-CSharp.dll" )
"C:\Program Files\Red Gate\SmartAssembly 6\SmartAssembly.com" /build "%system.teamcity.build.checkoutDir%/../0001.saproj"
IF EXIST "0001_Obfuscate\Assembly-CSharp.dll" ( copy "0001_Obfuscate\Assembly-CSharp.dll" "0001_Build\0001_Data\Managed\Assembly-CSharp.dll" )


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.
Back to top
View user's profile Send private message
DanielRose



Joined: 30 Oct 2009
Posts: 16
Location: Aachen, Germany

PostPosted: Mon Jul 14, 2014 3:02 pm    Post subject: Re: Reply with quote

nyxling wrote:

Code:

IF NOT EXIST "0001_Obfuscate" ( mkdir "0001_Obfuscate" )
IF EXIST "0001_Obfuscate\Assembly-CSharp.dll" ( del "0001_Obfuscate\Assembly-CSharp.dll" )
"C:\Program Files\Red Gate\SmartAssembly 6\SmartAssembly.com" /build "%system.teamcity.build.checkoutDir%/../0001.saproj"
IF EXIST "0001_Obfuscate\Assembly-CSharp.dll" ( copy "0001_Obfuscate\Assembly-CSharp.dll" "0001_Build\0001_Data\Managed\Assembly-CSharp.dll" )



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:
Code:

"C:\Program Files\Red Gate\SmartAssembly 6\SmartAssembly.com" /build "%system.teamcity.build.checkoutDir%/../0001.saproj"
IF ERRORLEVEL 1 EXIT 1
IF EXIST "0001_Obfuscate\Assembly-CSharp.dll" ( copy "0001_Obfuscate\Assembly-CSharp.dll" "0001_Build\0001_Data\Managed\Assembly-CSharp.dll" )
Back to top
View user's profile Send private message
nyxling



Joined: 31 Mar 2014
Posts: 7

PostPosted: Mon Jul 14, 2014 3:26 pm    Post subject: Reply with quote

Hey there, I just logged in to check/post my solution, and it turns out that I had found the same thing as DanielRose.

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.
Back to top
View user's profile Send private message
nyxling



Joined: 31 Mar 2014
Posts: 7

PostPosted: Mon Jul 21, 2014 3:43 pm    Post subject: Reply with quote

It appears that the link that Jessica provided is indeed what I needed to make things work properly, so I would consider this issue closed.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group