Jakob Ehn

Exploring Visual Studio 2010 ALM at Inmeta (http:///www.inmeta.com)
posts - 42, comments - 216, trackbacks - 0

My Links

News

Microsoft Community Contributor Award 2011

Twitter





Tag Cloud

Archives

Post Categories

Blogs

Building Visual Studio Setup Projects with TFS 2010 Team Build

UPDATE: 2010-09-15 – Added details about the use of the ExitCode variable

 

One of the most common complaints from people starting to use Team Build is that is doesn’t support building Microsoft’s own Setup and Deployment project (*.vdproj). When creating a default build definition that compiles a solution containing a setup project, you’ll get the following warning:

The project file "MyProject.vdproj" is not supported by MSBuild and cannot be built.

 

This is what the problem is all about. MSBuild, that is used for compiling your projects, does not understand the proprietary vdproj format defined by Microsoft quite some time ago. Unfortunately there is no sign that this will change in the near future, in fact the setup projects has barely changed at all since they were introduced. VS 2010 brings no new features or improvements hen it comes to the setup projects.

VS 2010 does include a limited version of InstallShield which promises to be more MSBuild friendly and with more or less the same features as VS setup projects. I hope to get a closer look at this installer project type soon.

But, how do we go about to build a Visual Studio setup project and produce an MSI as part of a Team Build process? Well, since only one application known to man understands the vdproj projects, we will have to installa copy of Visual Studio on the build server. Sad but true. After doing this, we use the Visual Studio command line interface (devenv) to perform the build.

In this post I will show how to do this by using the InvokeProcess activity directly in a build workflow template. You’ll want to run build your setup projects after you have successfully compiled the projects.
 

  1. Install Visual Studio 2010 on the build server(s)

     
  2. Open your build process template /remember to branch or copy the xaml file before modifying it!)

     
  3. Locate the Compile the Project activity

     
  4. Select the activity and open the Variables tab at the lower right

  5. Add a new variable called ExitCode of type Int32. This variable will contain the exit code from the devenv process and can be validated for errors.

    image
  6. Drop an instance of the InvokeProcess activity from the toolbox onto the designer, after the Run MSBuild for Project activity

     
  7. Drop an instance of the WriteBuildMessage activity inside the Handle Standard Output section.
    • Set the Importance property to Microsoft.TeamFoundation.Build.Client.BuildMessageImportance.High
      (NB: This is necessary if you want the output from devenv to show up in the build log when running the build with the default verbosity)
    • Set the Message property to stdOutput

       
  8. Drop an instance of the WriteBuildError activity to the Handle Error Output section
    • Set the Message property to errOutput

       
  9. Select the InvokeProcess activity and set the values of the parameters to:


    image 

    Note that the Result is piped to the ExitCode variable.
  10. The finished workflow should look like this:


    image 

     
  11. This will generate the MSI files, but they won’t be copied to the drop location. This is because we are using devenv and not MSBuild, so we have to do this explicitly

     
  12. Drop a Sequence activity somewhere after the Copy to Drop location activity.

     
  13. Create a variable in the Sequence activity of type IEnumerable<String> and call it GeneratedInstallers

     
  14. Drop a FindMatchingFiles activity in the sequence activity and set the properties to:


    image 

     
  15. Drop a ForEach<String> activity after the FindMatchingFiles activity. Set the Value property to GeneratedInstallers

     
  16. Drop an InvokeProcess activity inside the ForEach activity.
    •  FileName: “xcopy.exe”
    • Arguments: String.Format("""{0}"" ""{1}""", item, BuildDetail.DropLocation)

  17. The Sequence activity should look like this:


    image 

     
  18. Save the build process template and check it in.

     
  19. Run the build and verify that the MSI’s is built and copied to the drop location.

 

Note 1: One of the drawback of using devenv like this in a team build is that since all the output from the default compilations is placed in the Binaries folder, the outputs is not avaialable when devenv is invoked, which causes the whole solution to rebuild again. In TFS 2008, this was pretty simple to fix by using the CustomizableOutDir property. In TFS 2010, the same feature is not avaialble. Jim Lamb blogged about this recently, have a look at it if you have a problem with this: http://blogs.msdn.com/jimlamb/archive/2010/04/13/customizableoutdir-in-tfs-2010.aspx
 

Note 2: Although the above solution works, a better approach is to wrap this in a custom activity that you can use in your builds. I will come back to this in a future post.

Print | posted on Friday, May 14, 2010 8:38 AM | Filed Under [ TFS Team Build VSTS 2010 ]

Feedback

Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

I'm trying to follow these steps but I'm stuck on step 7. Alongside where I've entered [ExitCode] in the Result property there's a Compiler error stating: "Compiler error(s) encountered processing expression "[ExitCode]". 'ExitCode' is not declared. It may be inaccessible due to its protection level."

Please help.
7/6/2010 4:02 AM | Rob
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

I have created a build agent on another server so I can take the load off compiling on the TFS Server itself. I guess I need to install VS 2010 on the Build Server to get my applications to compile correctly. You mentioned installing VS 2010 on the build server, but what edition did you end up installing. I am cheap, I want to install the least expensive edition that I can. Can I install the Shell and get by with that?
7/15/2010 9:10 AM | Steve
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

excellent.
can you give an example or a step by step procedure of how to proceed ,for the same scenario?
Appreciate your help!

Thanks,
eswar
7/28/2010 8:22 AM | eswar
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

Thanks for the article, very well laid out and very helpful!

I get the same problem as Rob at step #7. If i just leave that field blank, though, instead of putting "[ExitCode]" in there then everything seems to work fine. I'm curious if I even need to do anything about it.

Also, on a side note, it seems to expect VB code in all the configuration properties. Is there an option somewhere to make it use C# ?

Thanks,
Jeremy
8/2/2010 1:40 AM | Jeremy
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

Thanks for the help, I managed to get this working, *except* that when the devenv command runs on the build server, the following error is logged. Package 'Microsoft.VisualStudio.TestTools.TestCaseManagement.QualityToolsPackage, Microsoft.VisualStudio.QualityTools.TestCaseManagement, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' failed to load.

Any ideas, can provide more info if necessary.
8/4/2010 9:11 AM | Chris
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

I was able to solve The package load failure by just using the arguments: "/Build " + localProject on the InvokeProcess activity
8/18/2010 10:49 PM | Rudi
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

addendum: switching to devenv.exe did the trick.
8/19/2010 12:54 AM | Rudi
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

All: i have updated the post with the details about the ExitCode variable, sorry for that. Note that in this example I do not actually check the variable afterwards. Do this by adding an If- or Switch activity after the InvokeProcess activity.
9/14/2010 7:17 PM | Jakob Ehn
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

Absolutely brilliant, this little article solved several issues that the MS documentation was useless for.

Thanks!
9/21/2010 6:16 PM | Kenn
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

Excellent post, very helpful. The trouble is I also have the QualityTools.TestCaseManagement issue mentioned above by Chris.

I think Rudi's solution above is a red herring, it actually results in devenv failing but it doesn't fail the build so it looks like the build has passed (check the log).

I think the issue is that I'm using VS2010 Premium instead of Ultimate and that the QualityTools.TestCaseManagement.DLL is failing to load because the LoadTest.DLL file isn't installed (I'm not trying to do Load Testing btw).

Does anyone have a solution to this problem?

I'm currently participating in a thread on it, but we don't seem to be getting anywhere, over here: http://social.msdn.microsoft.com/Forums/en-US/tfsbuild/thread/cbfb80ed-0c8f-4f2a-889c-635ccca9db8c/
9/28/2010 8:29 PM | Rob
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

The issue I mentioned above seems to be resolved by using devenv.exe instead of devenv.com

If you know of or find a problem with this method then please, please, please post a comment on the MSDN thread mentioned in my above comment.
11/9/2010 2:52 AM | Rob
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

This is very good and helpful but I still have a problem. I'm using devenv to build some non-Microsoft compiler projects (e.g., C, Fortran) that MSBuild can't handle. I see the logged output and in some cases I see errors (e.g., no such source file), but the devenv errors don't seem to come in as error output so the TFS build says no errors (even though the devenv log clearly shows compile and link errors). What are people doing for this?
12/2/2010 10:23 AM | MattC
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

MattC, see Jakob's post from 9/21/2010 7:17 PM

I think you'll need to check the ExitCode variable and then raise errors accordingly. Does that help?
12/15/2010 10:36 PM | Rob
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

Thanks for such a comprehensive post. I am able to get the .msi's but I am unable to get the dll's which are a result of building this project... I have tried to copy the ExitCode at some location but I found no success... can you please help me through this.
12/23/2010 7:00 PM | Nachiket
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

This is a good work around.
But as a permanent solution if you share an article/steps how to leverage the free install shield version comes with VS2010 it will be more help ful..
1/11/2011 10:48 PM | Senthilraj
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

Hi,

I tried these steps to build the .vdproj. Unfortunately, no msi's are generated/copied to the drop folder.
I've checked in the process template after making changes.
Can you guide..what could be wrong?
2/15/2011 8:21 AM | Sonali Noolkar
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

Sonali: Make sure that you are building the solution configuration that contains the setup project. By default, this is the Release configuration, but it might be different in your setup. Otherwise, run the build in diagnostic mode and check the log for details
2/15/2011 8:24 AM | Jakob Ehn
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

Thanks Jakob for the reply.

The solution file contains the setup project. The issue was that I had space in the folder name in TFS. enclosed the variable localproject in queotes like ...+ """" + localProject + """" and it worked.

However I am getting below errors:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.com /Build Debug "D:\Builds\5\AO SDMC.NET\WebApplicationStarterKit4_CI\Sources\WebApplication.sln"

Microsoft (R) Visual Studio Version 10.0.30319.1.
Copyright (C) Microsoft Corp. All rights reserved.

Package 'Microsoft.VisualStudio.TestTools.TestCaseManagement.QualityToolsPackage, Microsoft.VisualStudio.QualityTools.TestCaseManagement, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' failed to load.

Package 'Microsoft.VisualStudio.TestTools.TestCaseManagement.QualityToolsPackage, Microsoft.VisualStudio.QualityTools.TestCaseManagement, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' failed to load.

Also there are 4 other errors with no message associated.

Can you please guide for these unknown errors?
2/21/2011 9:51 AM | Sonali Noolkar
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

Jakob,
It looks like I am missing something. Would you please let me know the parameters to be passed as part of MSBuild argument?

I am trying to get the msi deployed onto destination server from TFS.
2/24/2011 9:58 PM | Sumit
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

Hi,

at the begining, thanks for the post, it helped me a lot.

I got similar problem with "Package 'Microsoft.VisualStudio.TestTools.TestCaseManagement.QualityToolsPackage, Microsoft.VisualStudio.QualityTools.TestCaseManagement, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' failed to load.".

I resolved it by changing devenv.com to devenv.exe in path to visual studio.

Hope this will help somebody.

Best regards,
Maciej
3/4/2011 1:46 PM | Maciej Wolniewicz
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

I came across a fairly simple way to have the output of each project end up in their respective bin/[configuration] so that when compiling the .vdproj, the entire solution is not rebuilt. In step 10 listed above, find "Run MSBuild for Project". Select this activity, and in the properties window, clear the property OutDir. This will enable the normal OutputPath of project. However, none of the output files will be copied to the Binaries directory and will then not end up in the drop folder. There will be a warning about in the tfs build log. However, what you will see in the drop folder is the log file and the .msi/.exe, depending on which files were specified to be copied over the drop folder in step 14 when defining the "Find generated installers" activity.
3/18/2011 10:44 PM | Dave
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

I can't figure out where the Copy to Drop activity is... Maybe I am just blind. Is it possible that the label is something else? Also, could you tell me what high-level parent this is supposed to be in?
3/22/2011 10:30 PM | Nate
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

Hi Jakob,

Thanks for the post. It is really helpful. I have a couple of questions though:

(1) Regarding the ExitCode variable, I'm still not quite sure with what condition should I use with a If or switch because I'm getting "Compiler error(s) encountered processing expression "[ExitCode]". 'ExitCode' is not declared. It may be inaccessible due to its protection level." error.
(2) Also, I'm getting the same error for localProject.

I would really appreciate if you could help me fix these errors. I'm new to MSBuild 4.0.

Thanks a ton,
Paresh
3/24/2011 9:58 PM | Paresh
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

Hi Jakob,

I'm still waiting for your response on the two queries I have above. Please please help me, its real urgent.

Can anyone else help me out please?

Thanks a ton,
Paresh
3/26/2011 10:40 PM | Paresh
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

@Paresh: Sorry for the late answer.

If you can't reference a workflow variable (such as localProject), the reason is usually that you the variable is not in the current scope. localProject is declared inside the "Compile the Project" sequence activity,
which means that you can only reference the variable within that activity.

Reagarding the ExitCode variable, have you added the variable to the "Compile the Project" sequence activity (Step 5 above). If so, you should be able to reference the variable later in the same scope.
3/29/2011 9:05 AM | Jakob Ehn
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

Hi Jakob,

I'm still waiting for your response on the two queries I have above. Please please help me, its real urgent.

Can anyone else help me out please?

folding mountain bike
4/21/2011 7:40 PM | eric
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

Hi. I have some problems. I think that I misunderstood some section.
Until section 11 you describe how to create msi, but where can I find created files?
In section 12 you wrote drop a sequence somewhere after "copy to drop", but where should I find "copy to drop" sequence? Where do you mean by "somewhere"?
7/3/2011 10:02 AM | Rami
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

Hi,

I have configured the TFS system in my client Win 7 machine and the MSIs are not getting built and the error is showing as "These files could not be found and will not be loaded.
The operation could not be completed". I modified the argument for devenv as String.Format("{0} /build {1}|{2}", localProject, platformConfiguration.Configuration, platformConfiguration.Platform) as the argument shown in this article was showing error to "use devenv [solutionfile | projectfile | anyfile.ext] [switches]""

When I invoke the command from console it builds the MSI But not from the Teambuild system.

Please let me know what could be the error.

Earlier I was always
7/25/2011 1:02 PM | Mush
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

Hi -

When I removed the build configurations, the error is not shown and the project is getting built, but throws error related to DLL reference path. Please elt me know the best way to fix this.
7/25/2011 2:19 PM | Mush
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

Thank you! this is exactly what I was looking for and your steps are very detailed!
8/8/2011 8:30 PM | GratefulCoder
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

Whole solution is getting copied into the sources folder but i fo not see the compiled files under bin folder...
8/17/2011 5:34 PM | Jas
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

I found the problem. I was trying to build a business intelligence solution. For some reason it does not like to specify the project configuration.I set it as default. But how can i specify the solution and the project to build inside a single build definition?
8/17/2011 6:34 PM | Jas
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

Xcopy does not work when a build is scheduled in TFS 2010
8/23/2011 2:19 AM | TJ
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

I'm trying to follow these steps but I'm stuck on step 16. Returned message is saying: 'Item' is a type and cannot be used as an expression.
9/13/2011 7:42 PM | Amanda
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

This is just awesome!

For those wondering where to find the "Copy To Drop" activity, this is where I found it
Run On Agent-->Try Compile, Test...(Finally Block)-->Revert Workspace and Copy Files to Drop Location

Cheers!
10/5/2011 7:28 PM | Gandalf
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

This is awesome!

I do have a few questions though. I have implemented this for one of our projects and it was successfully building the MSI files and copying them, however it has stopped working. Any ideas on how to update this to handle any potential errors?

The MSI files doesn't seem to be generated by the invoking of DevEnv. However when we build manually on TFS machine running DevEnv the MSI file is found in the \release folder for our setup project. Any ideas?
10/7/2011 4:11 PM | Bill
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

@Bill: Make sure that you are building the correct solution configuration, e.g. Release|Any CPU for example, and that this configuration includes the setup project. Otherwise you need to check the output from devenv, run the build with diagnostic verbosity and examine the output from devenv
10/10/2011 9:22 AM | Jakob Ehn
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

great post, one of the few on tfs 2010
10/11/2011 11:07 PM | james
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

Hi there,
for step 13, i couldn't find type "IEnumerable<String>" from the dropdown window to create the variable. am i missing some assamplies?
thanks!
10/13/2011 8:11 PM | Lin
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

Which edition of Visual Studio is needed on the build system?
Does the Express Edition also work?
10/17/2011 8:10 AM | J. Meyer
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

For xcopy failing on scheduled builds, check permissions for the Build Service account on the sourcecode folder (e.g. C:\Builds). I use the Network Service account and so gave Full Control to Network Service on C:\Builds. The scheduled build was then successful.
11/1/2011 3:21 PM | Darren
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

Lin
The IEnumerable<String> is found by; Browse for types. find IEnumerable<t>. Then there will be a combo slection allowing you to change the 't' to String.
Now when you select OK it will fill that cell and there will be an additional entry for that cell that will be "system.collections.generic.ienumerable<System.String>

Randy
11/11/2011 9:53 PM | Ransch
Gravatar

# re: Building Visual Studio Setup Projects with TFS 2010 Team Build

Can you post the xaml file you used for this project?
12/9/2011 11:35 PM | Philip Ammann
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

Powered by: