TFS support

Mar 25, 2015 at 7:55 AM
Hi,


I just started a new job in a new company. They (we?!) are using TFS here.
I create a Wix# setup project and it compiles fine!

However, when a nightly build try to build, it fails when building the WIX# setup pproject. It looks like it's trying to run the setup.exe and it fails with return code '1'.

mmm... looking at the setup and it looks like there is an exception (but it doesn't appear in the build log, desptie me Console.WriteLine it)

I wonder if Project.OutDir could be a problem (I use ",\bin\Debug")
Investigating now..
but if you got any idea! I'm new to TFS!
Mar 25, 2015 at 12:01 PM
Just some points...
  • Arguably VS project form NuGet is better than the sample project included in Wix# distro as it contains MSBuild targets (WixSharp.targets), which runs setup.exe during the build. While the project from the distro does it as a post-build event.
  • When building with BS/MSBuild it may help to set WixSharp.Project.SourceBaseDir and/or WixSharp.Project.OutDir
  • Sometimes executing "cscs.exe setup.cs" from MSBuild is a simplest an the most reliable option.
Mar 25, 2015 at 11:53 PM
Thanks Oleg!
Gotta look into that!...
Mar 26, 2015 at 12:12 AM
I think I found it Oleg!
(the problem, not the solution)
My colleague who manage TFS is not here today so I will ask here in case you know....

When I do my file collections I do it that way:

    var project = new Project
    {
        Dirs = new[] 
        {
            new Dir(TargetFolder)
            {
                DirFileCollections = new []
                {
                    new DirFiles(src_dir + @"\*.dll"),
                    new DirFiles(src_dir + @"\MDTClient.exe"),
                    new DirFiles(src_dir + @"\MDTClient.exe.config"),
                },
            },

};

where src_dir = @"..\MDTClient\bin\Debug"; obviously the src_dir property is wrong.... in the TFS build scenario... mmm... not sure what to do, might have to wait for colleague...
Mar 26, 2015 at 12:27 AM
mm.. I look at another project they have using Wix, and they use environment variable to get file location...
is there a way to do that with Wix# please?
Mar 26, 2015 at 12:36 AM
Edited Mar 26, 2015 at 12:36 AM
Basically how can I use the Wix syntax:

<File Id="MyExecutable" Name="$(var.MyProject.TargetFileName)" Source="$(var.MyProject.TargetPath)" DiskId="1" />

as in:
http://wixtoolset.org/documentation/manual/v3/votive/votive_project_references.html
Mar 26, 2015 at 1:38 AM
With the NuGet Wix# project the working directory is always set to the 'project directory' so you can always adjust your code references (e.g. SourceBaseDir/OutDir).
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Target Name="MSIAuthoring" AfterTargets="AfterBuild">
    <Message Importance="high" Text="Building MSI" />
    <Exec Command="&quot;$(TargetPath)&quot; /MBSBUILD:$(ProjectName)" WorkingDirectory="$(ProjectDir)"/>
  </Target>
</Project>
If you use just MSBuild executable task (should work just straight away under TFS) then you have a flexibility of ensuring cscs.exe is running with the deterministic 'currentdir'. You just need to pass '/l' parameter and the script engine will ensure that the current directory is set to the location of the script file (e.g. setup.cs):
    <Exec Command="cscs.exe /l &quot;$(ProjectDir)setup.cs&quot;"/>
Votive integration with VS is different as it is using a binary custom task so it accesses 'project variables'. The build script (setup.cs or $(ProjectName).exe) cannot doe this. Saying that you have prompted an interesting potential feature. I think it would be beneficial to make Wix# compiler to extend any environment variables in the path:
Project project =
            new Project("MyProduct",
                new Dir(@"%ProgramFiles%\My Company\My Product",
                    new File(@"%LATEST_RELEASE%\Files\Bin\MyApp.exe"),
                    new Dir(@"Docs\Manual",
                        new File(@"%LATEST_RELEASE%\Files\Docs\Manual.txt"))));
or
        project.OutDir = @"%LATEST_RELEASE%\MSI";
        project.SourceBaseDir = @"%LATEST_RELEASE%\Bin";
And now you can use MSBuild Extension Pack to set the environment variable(s) to the project variable name (pseudo-code):
    <SetEnv Name="LATEST_RELEASE" Value="$(var.MyProject.TargetPath)"/>
I will implement it as soon as possible.