Showing posts with label TFS2012. Show all posts
Showing posts with label TFS2012. Show all posts

Saturday, November 22, 2014

Import Unit Tests to Test Cases

Using UI Automation and Unit tests in general is a good thing,
but VS does not provide a simple way of associating the tests to test cases.
you have to open a test case and associate the unit test, for one, two it ok,
for more then 10 its very tedious
in VS2010 we had a nice extesion called "Pronto",
in VS 2012 and above this does not work any more.

luckly the TCM command comes very handy here:
tcm testcase /import /collection:http://mytfs:8080/tfs/mycollection /teamproject:"myTeamProject" /storage:"fullpath_to_UT_DLL" [/filter:"test category"] [/syncsuite:"test suite id to update"]

this command will pass over all matching unit tests in the dll and add / update testcases.

MSDN TCM link : http://msdn.microsoft.com/en-us/library/ff942470.aspx

Saturday, April 13, 2013

Web Deployment in TFS2012 - Part 2

In the previouse post i have shown how to publish.
this we publish the whole site, but what if i need external resources or exclude some config files?
so i looked around good people and here is what i found (also validated):

Adding to the Deployment
 <PropertyGroup>
    <CopyAllFilesToSingleFolderForPackageDependsOn>
      CustomCollectFiles;
      $(CopyAllFilesToSingleFolderForPackageDependsOn);
    </CopyAllFilesToSingleFolderForPackageDependsOn>
  </PropertyGroup>
 
  <Target Name="CustomCollectFiles">
    <ItemGroup>
      <_CustomFiles Include="D:\Dev\W2012TFS2012Prd\DefaultCollection\Test\MySites\MvcApplication\Properties\PublishProfiles\**\*" />
 
      <FilesForPackagingFromProject  Include="%(_CustomFiles.Identity)">
        <DestinationRelativePath>Extra Files\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
      </FilesForPackagingFromProject>
    </ItemGroup>
  </Target>


Exclude From Deployment
<PropertyGroup>
    <ExcludeFilesFromPackageDependsOn>
        $(ExcludeFilesFromPackageDependsOn);
        _ExcludeAzureDlls
    </ExcludeFilesFromPackageDependsOn>
</PropertyGroup>

<Target Name="_ExcludeAzureDlls">
    <ItemGroup>
        <AzureFiles Include="@(FilesForPackagingFromProject)"
                    Exclude="@(FilesForPackagingFromProjectWithNoAzure)" />
        <ExcludeFromPackageFiles Include="@(AzureFiles)">
            <FromTarget>_ExcludeAzureEnvironmentDlls</FromTarget>
        </ExcludeFromPackageFiles>
    </ItemGroup>
</Target>

 
here is a MSDN FAQ about Web Deployment http://msdn.microsoft.com/en-us/library/ee942158.aspx it also helped abit

Web Deployement in TFS2012

Web Deployment in VS2012 relies on the new Publish framework and the use of publish profiles.
using these profile gives us the ability to create different publishing for different environments.

all that is nice and well and work splendid with the VS2012, but what with my Builds?

We have 2 options:
  1. Add to Build Definition, Process->Advanced->MSBuild Arguments "/p:DeployOnBuild=true /p:PublishProfile=<Publish Profile Name>"
  2. Add the following lines to a project configuration
<DeployOnBuild>True</DeployOnBuild>
<PublishProfile>Deploy2</PublishProfile>

Using option 2 works better with multiple websites in the same solution

Also for File System Publish update publish profile like this, because of a bug in the build:
<publishUrl>$(MSBuildThisFileDirectory)..\Deployment\</publishUrl>


$(MSBuildThisFileDirectory) - the location of the pubxml in the project properties

Shutdown TFS

The TFS contains many web services and some windows services.
You can use the TFSServiceControl command to stop or start all of the services and application pools Visual Studio Team Foundation Server uses. For example, you use this command when backing up or restoring databases, or when you are moving your deployment from one machine to another.

TFSServiceControl [quiesce|unquiesce]

Option
Description
quiesce
Stops or pauses all of the services, application pools, and operations in your deployment of Team Foundation Server. This is required for certain maintenance tasks, such as restoring databases.
unquiesce
Starts or restarts all of the services, application pools, and operations in your deployment of Team Foundation Server. This is required to return your server to operation after you run the command with the quiesce option.

TFPT Command Line Install

the TFS power tools are a strong and helpfull extenstion.
they only have one problem, they contain the Process Template Editor.
it's true that permission issues prevent you from performing mistakes.
but in every organization there are some people who have the permission and tempering with the process template is not somthing they should do.

i have looked around and could not find any documaentation about silent install with selected featues
so i look in the MSI  (InstEd) and using the Msiexec paramters, I managed to create a silent intall batch that enables you to select the features.

Features you can use:
FeatureDescription
CHECKINPOLICIESCheckin policies
TSXIntegration with Windows Shell
TSX_64Integration with Windows Shell for 64bit OS
CLICommand line Application (tfpt.exe)
VSIPIntegration with Visual Studio (Find, Rollback, ...)
TFPSPowerShell Scripts
PROCESSEDITORProcess Template Editor
BPABest Practices Analyzer
TCMACTest Attachment Cleaner
BRDatabase Backup Tools
TFSTORYBOARDStoryboard Shapes Authoring Tool (TFS2012 only)

Ex. install only checkin policies, windows shell integration, command line and Visual Studio integration
msiexec /quiet /i tfpt.msi ADDDEFAULT=CHECKINPOLICIES,TSX,CLI,VSIP

Various TFS Cache Directories

Visual Studio / TFS Cache

Windows XP, 2003
C:\Documents and Settings\[USER]\Local Settings\Application Data\Microsoft\Team Foundation\

Windows 7,2008,....
C:\users\[user]\AppData\Local\Microsoft\Team Foundation\

Test Agents
Windows XP, 2003
C:\Documents and Settings\[Agent Service User]\Local Settings\Application Data\VSEQT\QTAgent

Windows 7 ,2008 ,...
C:\Users\[Agent Service User]\AppData\Local\VSEQT\QTAgent

TFS Build Agents

Windows XP, 2003
C:\Documents and Settings\[Build Service User]\Local Settings\Temp\BuildAgent\[Agent ID]
C:\Documentsand Settings\[Build Service User]\Local Settings\Temp\BuildController\[Controller ID]

Windows 7,2008,....
C:\Users\[Build Service User]\AppData\Local\Temp\BuildAgent
C:\Users\[Build Service User]\AppData\Local\Temp\BuildController

 

Friday, March 22, 2013

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)