Freigeben über


Building setup projects with Team Build and running tests on product install

Setup projects (.vdproj) do not have a project system format that can be understood by MSBuild. Hence MSBuild cannot build these projects directly and consequently neither can Team Build. What we can do however is use the devenv /build command to build the vdproj files and generate msi installers. As I set out to build setup projects and install them on the build machine in order to run tests on those, I followed the sequence of steps listed below:

Override the target AfterCompile in the TFSBuild.proj file. Include an Exec task in the target to build the setup project separately using devenv /build.

<Target Name="AfterCompile">
<Exec Command="&quot;$(VSINSTALLDIR)\Common7\IDE\devenv&quot; ..\Sources\MySolution\MySetup\MySetup.vdproj /Build"/>
</Target>

Now, if you kick off a build, the msi is built, but is dropped into the bin folder under the Sources folder in the build directory. But in order to get it into the drop location, you need to edit the "Output file name" property in the setup project properties to ..\..\..\Sources\ since you cannot pass the output directory to the command line. Now, when you kick off a build, you see the msi file in the Binaries folder on the build machine and consequently the drop location. The caveat is that you will need VS installed on the build machine if you want to build using devenv.

Invariably the problem arises that you would want to build the setup project in different flavors now. The solution to that one is slightly tricky. Remember, you cannot pass in the output directory on the command line, that is why you have to build the setup project in the Binaries folder and then include a task to copy the dlls to the appropriate flavor's folder. Then again, you can build the setup project in a different flavor and re copy the dlls into the appropriate folder. You can use the /ProjectConfig switch to specify the flavor in which the setup project is to be built.

Now that you have built setup projects, you want to do something else. Run tests on the installed product to pronounce it good or bad. Consider a solution that has a console application, a setup project and a test project. The setup project is built into an msi that dumps the created exe into a folder called say "D:\Program Files\MySetup". Now, the test project has a generic test that calls the console application's exe from the same folder. If the install has happened successfully on a machine, the test calls the console application exe and based on the behaviour may either pass or fail. But, in case the product is not even installed, then the test aborts saying that the exe is not found. So, now after the AfterCompile custom task builds the setup project, you put in another custom target BeforeTest. Include a task "Exec" in this target that will call the setup.msi file with the /quiet switch to install the product without launching the UI. Right after this target, tests are run in the Test target and the generic test will not abort if the install has succeeded.

<Target Name="BeforeTest">
<Exec Command="..\Binaries\Setup1.msi /quiet"/>
</Target>

While writing this task, I hit an error in install. This was due to the build service account not being an admin on the build machine and install rights being denied to the account. After adding the build service account as admin on the machine, remember to restart the build service. Now, the install succeeds and the tests run on the installed product.

Feel free to post comments if you need help with any other related scenarios.

Comments

  • Anonymous
    March 01, 2006
    Rob Caron points us to a process guidance print tool. He also talks about TDD in Agitator and Team System....

  • Anonymous
    May 19, 2006

    This article describes how to have
    TFS's build functionality accomodate and build setup and deploy...

  • Anonymous
    May 19, 2006
    Better even, just use Wix (http://wix.sourceforge.net) that has native support for MSBuild ;).

  • Anonymous
    September 03, 2006
    Hi ,When using BuildTypes ,I am not getting the DeploymentPackage (.msi)file in Release mode,instead it is always creating the deployment package in Debug mode .The following content is my TFSBuild.proj test build tmserver Test D:BuildSample \prog_126Build false Symptom=build break;Steps To Reproduce=Start the build using Team Build <!-- CODE ANALYSIS To change CodeAnalysis behavior edit this value. Valid values for this can be Default,Always or Never.

     Default - To perform code analysis as per the individual project settings Always  - To always perform code analysis irrespective of project settings Never   - To never perform code analysis irrespective of project settings --><RunCodeAnalysis>Never</RunCodeAnalysis><!--  UPDATE ASSOCIATED WORK ITEMS Set this flag to enable/disable updating associated workitems on a successful build--><UpdateAssociatedWorkItems>true</UpdateAssociatedWorkItems><!-- Title for the work item created on build failure --><WorkItemTitle>Build failure in build:</WorkItemTitle><!-- Description for the work item created on build failure --><DescriptionText>This work item was created by Team Build on a build failure.</DescriptionText><!-- Text pointing to log file location on build failure --><BuildlogText>The build log file is at:</BuildlogText><!-- Text pointing to error/warnings file location on build failure --><ErrorWarningLogText>The errors/warnings log file is at:</ErrorWarningLogText>
    <Target Name="AfterCompile">    <Exec  Command='"C:Program FilesMicrosoft Visual Studio 8Common7IDEdevenv.com" "$(SolutionRoot)TT1WebSetupWebSetup.vdproj" /ReBuild /ProjectConfig ' />    <Copy SourceFiles="$(SolutionRoot)TT1WebSetupReleaseWebSetup.msi" DestinationFolder="$(DropLocation)$(BuildNumber)" /></Target>
    My objective is ,After building this build type ,i have to get the deployment package in Release modeHelp me out with this issue

  • Anonymous
    January 09, 2007
    You could also use the DevEnv build task to simplify it. You will still need VS installed.Tasks: http://www.gotdotnet.com/codegallery/codegallery.aspx?id=b4d6499f-0020-4771-a305-c156498db75eSample:   <Tools.DevEnv VisualStudio="8.0" Path="MySetup.vdproj" Config="Release" OutputFolder="$(SolutionRoot)..BuildType" Clean="true"/>Regards... FreeToDev

  • Anonymous
    March 19, 2007
    The comment has been removed

  • Anonymous
    May 30, 2007
    I whant to automate the proceses in our teem. But I can't build the msi project neither with msbuild.exe nor Nant nor through the command prompt. Even devenv.exe cann't build *.vdproj through the command prompt. I will aprisiate very much if  anutthara tell me how to do any of these steps correctly. Thank you.

  • Anonymous
    June 19, 2007
    Thanks for the tips it got my build server running. I forgot the whole installation permissions thing, I assumed that the configuration of the build server would have given the appropriate permissions to the TFS Service Account.

  • Anonymous
    June 28, 2007
    The comment has been removed

  • Anonymous
    July 12, 2007
    Because many Visual Studio project types are not supported in MSBuild, many Team Build users end up needing

  • Anonymous
    August 20, 2007
    I am able to build and install succesfully by following above mentioned step. Issue arises in scenario where i run the build for the second time. Since it has already installed the application during first build. It cannot install again. It runs in silence mode, actually its waiting for user intervention whether to reinstall or repair the application. Due this build process runs infinetly without ending. Any help on this scenario is appreciated.

  • Anonymous
    August 21, 2007
    Hi Jignesh- You should probably include a task to uninstall the build in your tfsbuild proj file after tests are executed. HTH.Also, I am on a different team now and dont have the full context on the current scene on setup proj scenario with Team Build. :(http://blogs.msdn.com/buckh should be the best place to ask setup proj or Team Build related qs

  • Anonymous
    August 22, 2007
    Jignesh, if you are installing the application you would need to uninstall the application before installing it again.  The Build forum on MSDN is a good place to ask questions: http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=481&SiteID=1.Buck

  • Anonymous
    October 29, 2007
    The article is good... But I tried the thing suggested by you in my TFS build script. But Unfortunately it's keep on going...what went wrong here.Any idea?

  • Anonymous
    December 28, 2007
    hi,i have two configuration set up.<ConfigurationToBuild Include="Development|Mixed Platforms">     <FlavorToBuild>Development</FlavorToBuild>     <PlatformToBuild>Mixed Platforms</PlatformToBuild>   </ConfigurationToBuild>

     &nbsp;&lt;ConfigurationToBuild Include=&quot;Testing|Mixed Platforms&quot;&gt;     &nbsp;&lt;FlavorToBuild&gt;Testing&lt;/FlavorToBuild&gt;     &nbsp;&lt;PlatformToBuild&gt;Mixed Platforms&lt;/PlatformToBuild&gt; &nbsp;&lt;/ConfigurationToBuild&gt;
     </ItemGroup>i can run one environment at one time .Can you help me how we can run both(development&testing) at one time.

  • Anonymous
    February 12, 2008
    For Shefeek:I presume the name of your TFS build and/or project path contains spaces.it is easy to work this around by adding a second quote after devenv and another one before the /build.This should do the trick

  • Anonymous
    March 25, 2008
    The comment has been removed

  • Anonymous
    April 14, 2008
    The comment has been removed

  • Anonymous
    June 26, 2008
    В идеале, при гибкой (Agile) разработке процесс сборки решения и его развертывания в среде тестирования

  • Anonymous
    September 02, 2008
    Is it possible to build a setup project without installing VS on the build server? Because I'm required not to install VS there

  • Anonymous
    September 10, 2008
    Thanks for the assistence - you answered my questions perfectly.

  • Anonymous
    September 12, 2008
    PingBack from http://alipka.wordpress.com/2006/03/19/tfsmsbuild-caveats/

  • Anonymous
    April 16, 2009
    This post is almost 2 years old. Are we still not able to build Set project (vdproj) via MSBuild???