Page 1 of 1

Post-Build Comands

Posted: Mon Jan 12, 2015 11:45 am
by AccidentReport
I have a piece of code in my post-build to copy the built test files from the PC I'm on to the PC used to run the tests. This works brilliantly. My issue is that when I am building my tests I often run them to test them locally. Of course this triggers a build and then copies my tests to the other PC even though they may not now be in a state to be run.

Is there a way to do this properly so that I can execute tests locally without triggering the post-build command?

Re: Post-Build Comands

Posted: Mon Jan 12, 2015 5:37 pm
by krstcs
You could put the copy instruction in the Release build configuration instead of in Debug. Then when you want to actually copy the files, you would switch to the Release configuration.

The other thing you could do is use a build server with a continuous integration system like Jenkins. Then, you would do the work on your system, and the build server would only run new builds when you push (finished) code up to your code versioning system (CVS) like Git/TFS/SVN. If you aren't using a CVS, you should be. Even if you are the only person working on the project, it will save you a lot of work if your system crashes, or if you just mess something up.

Re: Post-Build Comands

Posted: Mon Jan 12, 2015 9:47 pm
by Ciege
If building in Visual Studio you can add code to the pre and post build events. For example, this post build event with only run commands when on the machine named DEVMACHINENAME:

Code: Select all

if NOT %ComputerName% == DEVMACHINENAME GOTO end
echo "Put commands here for dev machine only ".
:end
I'm not sure if RanorexStudio handles pre and post build events the same way.

Re: Post-Build Comands

Posted: Mon Jan 12, 2015 9:57 pm
by krstcs
It does. The build section of the project properties is pretty much the same, functionally, as VS.

I hadn't mentioned that because he seems to be building everything on the one system, so this wouldn't have the desired effect unless he moved to a dev-system/build-system setup where they were separate.

Re: Post-Build Comands

Posted: Tue Jan 13, 2015 9:43 am
by AccidentReport
krstcs wrote:You could put the copy instruction in the Release build configuration instead of in Debug. Then when you want to actually copy the files, you would switch to the Release configuration.
So if I did this I would need to change the Configuration under the build menu to Release, build it and then switch back? Would running it via F5 or the play button use the Debug or Release configuration if the configuration was set to release? I know that may seem like a stupid question but running the tests is under the debug menu! Also, we have multiple projects in the solution we work on independently so I assume I would have to ensure that we only ever build the single project wed work on and not the whole solution?
krstcs wrote:I hadn't mentioned that because he seems to be building everything on the one system, so this wouldn't have the desired effect unless he moved to a dev-system/build-system setup where they were separate.
At present there are two developers working on the tests locally and then the tests are run from another separate machine. We have started looking into using Jenkins to actually manage the build and execution of the tests but we haven't made much progress due to time restraints at present!

Re: Post-Build Comands

Posted: Tue Jan 13, 2015 3:32 pm
by krstcs
The debug menu in Ranorex (and SharpDevelop and Visual Studio) runs the configuration that is selected. It just attaches the .NET debugger to the process, which is why it's called Debug.

The debug configuration usually includes the debug symbols for easier debugging using the .NET debugger, while the Release configuration doesn't. The debug config creates a debug symbols file that the debugger reads so it can understand and use the actual symbols instead of the machine encoding. The Release configuration also usually includes some code optimizations that make the executable run faster, but which, in debug, would cause issues.

Does that help?

Re: Post-Build Comands

Posted: Tue Jan 13, 2015 4:28 pm
by AccidentReport
Yes that helps. Thanks.

I think we'll use the debug/release config as suggested for now. At least until something better gets setup!