Pass build.number to msi filename from wix project

Using Teamcity v2024.07.3, I previously used a Visual Studio (sln) build runner to build my solution. This solution includes a Wix v4 installer. Using the sln runner I could add /p:Version=%build.number% as a command line parameter and the build.number would then be included in the msi filename upon build.

Since the sln build runner is now deprecated and I have upgraded to Visual Studio 2022 I am trying to change the build runner to use devenv. But the devenv runner doesn't support the /p switch so how do I now pass the build.number to the build? I have tried /ProjectConfig "Version=%build.number%" as a command line switch but this doesn't change the version in the filename, instead leaving it as 1.0.0.0 which is the default $(Version) property in the project file.

0
3 comments
Hi Nbell,

Since TeamCity 2019.2.3, we have stopped providing active support for the Visual Studio (sln) runner.
Since the Visual Studio (sln) runner uses MSBuild for building projects under its hood, you can softly migrate to using the .NET build runner with the `msbuild` command. Your configured Visual Studio (sln) settings (such as command line parameters) will work similarly with `msbuild`.

For more detailed information please refer to https://www.jetbrains.com/help/teamcity/net.html.

Best Regards,
Tom
0

Hi Tom,

Thanks for your response.  That was my initial thinking.  The trouble is there are 147 projects in my solution and msbuild throws up 20 or 30 errors, and yet it builds without an issue in visual studio.  I was looking for a way to mimic the visual studio build so I was looking at the devenv runner which I assumed also used msbuild under the hood.  

I had some issues solving some of the msbuild errors, particularly as they involved changing the source code which I am reluctant to do. So if there is a resolution to the filename issue using devenv that would be preferable.

Thanks

Nick

0
Hi Nbell,

I understand your frustration. If you prefer to stick with devenv, here's a workaround: 

You can add a pre-build Command Line step in your TeamCity build configuration to modify the version number in your .csproj or .wixproj file using PowerShell or a script. For example:

powershell -Command "(Get-Content 'path\to\your.wixproj') -replace '<Version>1.0.0.0</Version>', '<Version>%build.number%</Version>' | Set-Content 'path\to\your.wixproj'"

This will ensure that the correct version number (build.number) is inserted into the project file before the devenv build starts.
0

Please sign in to leave a comment.