Answered by:
How to build WiX setup from both developer's desktop and TFS build?

Question
-
The goal is to have a WiX setup project that works from both a developer's desktop or from the actual TFS build process itself. This is a question that has been asked but despite several hours of searching no obvious answer presents itself. The problem, of course, is that the TFS build moves the solution products to binaries, a different directory structure than the one that is present in a normal developer's build. Without rewriting the actual TFS build work flow process script file itself, is there a way to make a WiX setup project work in both environments? If so, how?
Richard Lewis Haggard
Thursday, October 3, 2013 7:00 PM
Answers
-
Almost there. There is still a syntax problem with how to handle non-existent environmental variables but that's a question for another time.
It looks like I should be able to modify my WiX script so that it includes this:
<?define SourcePath = "..\bin\$(var.Configuration)" ?> <?ifdef $(env.IsTfsBuildAgent) ?> <?define SourcePath = "..\..\..\binaries" ?> <?endif ?>
and change the sources to look like this:<File Id='HpaMonitorEXE' Name='TheApp.exe' Source='$(var.SourcePath)\TheApp.exe' KeyPath='yes'>
and include the environmental variable IsTfsBuildAgent on my build agents then the same file works in both developer and TFS build time. If I can actually get this to work on a conditional basis then all would be good now.
Richard Lewis Haggard
- Edited by Richard.Haggard Monday, October 7, 2013 3:54 PM Incorrect.
- Marked as answer by Richard.Haggard Friday, October 11, 2013 5:27 PM
Monday, October 7, 2013 3:21 PM
All replies
-
Hi Richard,
Thanks for your post.
What’s the version of your TFS? How do you build WIX project using Team Build?
Yes, as you said, Team Build will mapping the solution to build agent folder(under the same root folder path with binaries folder) on build agent machine.
To use TFS Build Server to build your Wix project, you should first make sure that you have the Wix binaries installed on your build machine. And you can live with VS setup project, and get the VS installed as well.
For how to build Wix installers using MSBuild, please refer to: http://msdn.microsoft.com/en-us/magazine/cc163456.aspx. And you also can invoke devenv in build process template to build your solution, please refer to this blog: http://geekswithblogs.net/jakob/archive/2010/05/14/building-visual-studio-setup-projects-with-tfs-2010-team-build.aspx.
John Qiao [MSFT]
<THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
Thanks
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.Friday, October 4, 2013 8:17 AMModerator -
Thank you for your kind and timely response.
Your questions:
Version: TFS 2010. Dev environment is VS 2010 moving to VS 2012 with the intention that all development be in 2012 sometime Real Soon Now.How is WiX being built? A solution that includes both the applications/assembles/data files and the WiX installer exists. A build definition exists for each solution so it is possible to ask TFS to build the solution which is also the same solution that developers use during development. Developers are responsible for altering the WiX project so that any new assemblies or required data files are included in the installation. They are required to verify the installation changes at development time with the expectation that when the TFS release build runs it will work without modification.
WiX binaries on build machine? Yes. This is an explicit installation. All developers are expected to download the WiX toolset and install it on their own development machines as well.
Suggestion to look at 'How to build WiX installers using MSBuild': Yes, I saw this but since this references a much older version 2 and is somewhat dated since we are now talking 3.7 these days I elected to go to the forums to ask directly of people who know more about these things than I do as opposed to blindly experimenting on my TFS build agent and perhaps breaking something in a serious fashion. Also I am reluctant to make modifications to build agent specific scripts. In any case, the problem at the moment is that the work flow during the TFS agent build moved the products to binaries and away from the folder that they normally would go to in a developer's build situation. It would seem that the simplest solution would be to make the WiX script smart enough to go to the proper source directory in the first place depending upon whether it was building on a desktop or a build agent.
How to invoke devenv in build process: This refers to the previous setup mechanism which is no longer supported in VS 2012 and is not related to WiX in any fashion.
So, back to the original question:
Does anyone have a solution as to how to structure things so that a WiX solution can build a viable setup project on both a developers machine and the TFS build agent? The preferred solution will be a modification of the WiX solution so that it can work in both environments. If that is not practical then a solution that involves changing the TFS build agent is acceptable.Richard Lewis Haggard
Friday, October 4, 2013 5:54 PM -
Hello,
I'm using WIX for to package all TFS builds for numerous build types and applications.
To make sure i understand the question, is the version of WIX tool set different from developers machines to build servers?Regards Ayman Zaza MCTS
Friday, October 4, 2013 9:17 PM -
No. The same software is everywhere.
Do your WiX projects work on a developer's desktop as well as the TFS build agent? How did you structure things to allow this to happen?
Richard Lewis Haggard
Saturday, October 5, 2013 5:03 AM -
Simply, on each solution we add new WIX project. using visual studio developer can build it because they use devenv, but in the build server it use msbuild, so you have to change solution file ( solution configuration) to build wixproj as same as build definition ( release | any CPU) and like other .net project.
And from Workflow build you have 3 options to package MSI since you don't need (_publish folder) any more.
- invoke process to copy msi from output folder (static path).
- Use (UpgradeTemplate.xaml) to write msbuild script to build and package, then set output path to the particular folder as a part of the package.
- Create custom activity in your workflow to copy any msi from build folder.
for me i'm using the second option since it give me more space to control what i need to package and copying from one location to other.
Regards.
Regards Ayman Zaza MCTS
- Proposed as answer by Ayman Zaza Saturday, October 5, 2013 9:51 PM
Saturday, October 5, 2013 1:25 PM -
Please remember that I'm new to WiX and there are many, many things that I have yet to properly understand. The fact that I've been able to get it to work on a developer's machine at all is a small miracle so the amount of effort required to make further changes is inordinate and subject to much teeth gnashing and hair pulling.
Currently, the WiX project has a known relative path to the modules it includes. Most of the modules are assemblies but some are simply files that must be present and because this application spans multiple languages there are localized resource assemblies buried under localization folders which must also be copied into the appropriate locations at install time. We had a lot of trouble telling WiX how to find these things in the first place and finally got it to work with this sort of syntax:
<File Id='HpaMonitorEXE' Name='HpaMonitor.exe' Source='..\bin\$(var.Configuration)\HpaMonitor.exe' KeyPath='yes'>
While being fuzzy on the details I think that the best way for our case is to use a variable that defines the relative path to the source which is conditionally constructed in a fashion that is appropriate for whether the build is being accomplished on a developer's desktop or on a build agent. It might be possible to use environmental variables since these appear to be available. The build agent could contain a variable to indicate that a build agent path should be used. That would get me out of the business of generating/modifying workflows, yet another aspect of the build process that I am woefully ignorant of, and keep WiX script changes down to the smallest possible delta. What do you think?
Richard Lewis Haggard
Monday, October 7, 2013 2:30 PM -
Almost there. There is still a syntax problem with how to handle non-existent environmental variables but that's a question for another time.
It looks like I should be able to modify my WiX script so that it includes this:
<?define SourcePath = "..\bin\$(var.Configuration)" ?> <?ifdef $(env.IsTfsBuildAgent) ?> <?define SourcePath = "..\..\..\binaries" ?> <?endif ?>
and change the sources to look like this:<File Id='HpaMonitorEXE' Name='TheApp.exe' Source='$(var.SourcePath)\TheApp.exe' KeyPath='yes'>
and include the environmental variable IsTfsBuildAgent on my build agents then the same file works in both developer and TFS build time. If I can actually get this to work on a conditional basis then all would be good now.
Richard Lewis Haggard
- Edited by Richard.Haggard Monday, October 7, 2013 3:54 PM Incorrect.
- Marked as answer by Richard.Haggard Friday, October 11, 2013 5:27 PM
Monday, October 7, 2013 3:21 PM -
Hi Richard,
Thanks for your reply.
Do you mean that you build your WIX project using MSBuild(VS 2012) on develop machine? And it can be built correctly?
To build solution using Team Build, we should ensure the following steps:
1 The solution can be built completely on build agent machine using VS(2012).
2 Ensure the your TFS Build Service account have the permission to build this solution on the build agent machine.
3 Ensure the solution can be built completely on build agent machine using MSBuild v4.0 command line manually.
Additionally, to build solution using Team Build, we need to ensure the Team Build Service can find the required dlls on build machine. We usually using the following two way to reference dlls when using Team Build:
1 Create a Assemblies folder under Solution, and add all your dlls in this folder. After we check in the solution into TFS, the Team Build Service will get the solution from TFS to build on the Build machine, in this case, the Assemblies folder under solution will be get together. The structure like this:
TeamProject
/Solution1
/Assemblies
/Poject1
/Poject2
/…
/Solution2
…
2 Create the same common folder on the Build machine as you created on your develop client, and the folder path is same. So when the Team Build to build the solution on build machine, it will try to find the dlls on the Build machine follow the path which your set in your project.
For how to build WIX project using MSBuild, please contact MSBuild experts for the better response.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.Tuesday, October 8, 2013 3:31 AMModerator -
This is long after your post but I thought the answer would be helpful to someone. For some reason the ifdef clause doesn't like the $(env.envvarname) syntax. The following works for us:
<?ifdef env.TF_BUILD_BINARIESDIRECTORY ?> <?define BinDir=$(env.TF_BUILD_BINARIESDIRECTORY) ?> <?else?> <?define BinDir="..\..\..\bin\FleetProxy\Release" ?> <?endif?>
Tuesday, May 27, 2014 2:55 AM -
Hi,
I am in same situtaion. This will work for me but how to define the Build varibale??
EXplain this line with steps.
and include the environmental variable IsTfsBuildAgent on my build agents then the same file works in both developer and TFS build time. If I can actually get this to work on a conditional basis then all would be good now.
Krishna
Thursday, September 8, 2016 3:45 AM -
This also not worked. I includethis code in my .wxi file and changed the source-path. But it is still executing the else condition.
<?ifdef env.TF_BUILD_BINARIESDIRECTORY ?>
<?define SourcePath=$(env.TF_BUILD_BINARIESDIRECTORY) ?>
<?else?>
<?define SourcePath="..\..\bin\$(var.Configuration)" ?>
<?endif?>Krishna
Thursday, September 8, 2016 5:17 AM