Friday, March 22, 2013

How To: Keep Test Items Deployment Structure

when using deployment items in tests we sometimes need to keep the stucture of test items as it appers in our local machine. by default the all the deployment items are copied to the same folder regardless the source location structure.

we can set the target destination by editing the "TestSettings" XML
all we need to do is update the DeploymentItem with outputDirectory attribute
 
here is an example for a folder:
<DeploymentItem filename="CoreSettings\" outputDirectory="CoreSettings\">

a small word of caution updating the XML will not show in the desginer until you reload the solution.


found at : http://stackoverflow.com/questions/10162436/visual-studio-2010-does-not-copy-folder-on-deployment-to-out-directory

Private accessors and TFS2012 Builds


sometimes old test containing privert accessors will fail the build with Error:
 
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\TeamTest\Microsoft.TeamTest.targets (14): Object reference not set to an instance of an object.

 

first try to remove the private accessors and use a mocking framework (pex/moles or VS2012 Fakes)
But if due to any reason, you cannot remove the usage of private accessors immediately from your tests, please try changing the TeamTest targets file ("C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\TeamTest\Microsoft.TeamTest.targets") and see whether running the shadow task in a separate process works or not.

Here are the steps you should do for this: -

  1. Edit the targets file ‘C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\TeamTest\Microsoft.TeamTest.targets’.

  1. Change ExecuteAsTool property (highlighted) from default false to true.

<Target Name="ResolveTestReferences" Condition="'@(Shadow)'!=''">
  <BuildShadowTask
      ExecuteAsTool="True"  <!—Default value is false, change it to true –>
      CurrentResolvedReferences="@(ReferencePath)"
      CurrentCopyLocalFiles="@(ReferenceCopyLocalPaths)"
      Shadows="@(Shadow)"
      ProjectPath="$(ProjectDir)"
      IntermediatePath="$(IntermediateOutputPath)"
      SignAssembly="$(SignAssembly)"
      KeyFile="$(AssemblyOriginatorKeyFile)"
      DelaySign="$(DelaySign)">
 
    <Output TaskParameter="FixedUpReferences" ItemName="ReferencePath"/>
    <Output TaskParameter="NewCopyLocalAssemblies" ItemName="ReferenceCopyLocalPaths"/>
  </BuildShadowTask>
</Target>

  1. Save the file. (and probably restart the machine as well so that the background msbuild processes definitely picks up the change)

 




RoboCopy Exit Codes

During my work at Capito ,i came to a client were wanted a Build-Deploy-Test using Lab build.
the build part worked well but we had a small problem with the deployment scripts.
we were using RoboCopy in the deployment scripts. apparently the return code are very different:


The return code from Robocopy is a bit map, defined as follows:


Hex
Decimal 
Meaning if set
0×10
16
Serious error. Robocopy did not copy any files.
Either a usage error or an error due to insufficient access privileges on the source or destination directories.
0×08
8
Some files or directories could not be copied
(copy errors occurred and the retry limit was exceeded).
Check these errors further.
0×04
4
Some Mismatched files or directories were detected.
Examine the output log. Some housekeeping may be needed.
0×02
2
Some Extra files or directories were detected.
Examine the output log for details.
0×01
1
One or more files were copied successfully (that is, new files have arrived).
0×00
0
No errors occurred, and no copying was done.
The source and destination directory trees are completely synchronized.

You can use this in a batch file to report anomalies, as follows:

    if errorlevel 16 echo ***FATAL ERROR*** & goto end
    if errorlevel 15 echo OKCOPY + FAIL + MISMATCHES + XTRA & goto end
    if errorlevel 14 echo FAIL + MISMATCHES + XTRA & goto end
    if errorlevel 13 echo OKCOPY + FAIL + MISMATCHES & goto end
    if errorlevel 12 echo FAIL + MISMATCHES& goto end
    if errorlevel 11 echo OKCOPY + FAIL + XTRA & goto end
    if errorlevel 10 echo FAIL + XTRA & goto end
    if errorlevel 9 echo OKCOPY + FAIL & goto end
    if errorlevel 8 echo FAIL & goto end
    if errorlevel 7 echo OKCOPY + MISMATCHES + XTRA & goto end
    if errorlevel 6 echo MISMATCHES + XTRA & goto end
    if errorlevel 5 echo OKCOPY + MISMATCHES & goto end
    if errorlevel 4 echo MISMATCHES & goto end
    if errorlevel 3 echo OKCOPY + XTRA & goto end
    if errorlevel 2 echo XTRA & goto end
    if errorlevel 1 echo OKCOPY & goto end
    if errorlevel 0 echo No Change & goto end

i found this at http://ss64.com/nt/robocopy-exit.html

Welcom

Hello everyone

this is my first post in this blog.
this blog is all about my (Liran Dobrish) finding about various subjects with TFS.
and related subjects