After upgrading a WiX installer project (.wixproj) file to v4, the MSBuild step in the project to set the TargetName of the installer file output is no longer working.
I would like to dynamically append the assembly version of the application to be installed to the TargetName of the msi file name i.e. MyApplication.X.X.X.X.msi
.
Below is a snippet of the .wixproj file in its current state (I have removed some code for the sake of brevity):
<Project InitialTargets="SetVersion;BeforeBuild;CopyLinkedContentFiles">
<Import Project="Sdk.props" Sdk="WixToolset.Sdk" Version="4.0.0-rc.1" />
[...]
<Target Name="SetVersion">
<GetAssemblyIdentity AssemblyFiles="$(SolutionDir)\bin\$(Platform)\$(Configuration)\MyApp.exe">
<Output TaskParameter="Assemblies" ItemName="Assembly" />
</GetAssemblyIdentity>
<CreateProperty Value="$(SolutionName).%(Assembly.Version)">
<Output TaskParameter="Value" PropertyName="TargetName" />
</CreateProperty>
<PropertyGroup>
<DefineConstants>BuildVersion=%(Assembly.Version)</DefineConstants>
</PropertyGroup>
</Target>
<Target Name="CopyLinkedContentFiles" BeforeTargets="Build">
<Copy SourceFiles="%(Content.Identity)" DestinationFiles="%(Content.Link)" SkipUnchangedFiles="true" OverwriteReadOnlyFiles="true" Condition="'%(Content.Link)' != ''" />
</Target>
<Import Project="Sdk.targets" Sdk="WixToolset.Sdk" Version="4.0.0-rc.1" />
[...]
</Project>
The .wixproj previous had the following code to adjust the TargetName
:
<Target Name="SetVersion">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
<SccProjectName>SAK</SccProjectName>
<SccProvider>SAK</SccProvider>
<SccAuxPath>SAK</SccAuxPath>
<SccLocalPath>SAK</SccLocalPath>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\OCS.Service\</SolutionDir>
</PropertyGroup>
<GetAssemblyIdentity AssemblyFiles="$(SolutionDir)\bin\$(Platform)\$(Configuration)\MyApp.exe">
<Output TaskParameter="Assemblies" ItemName="AssemblyVersion" />
</GetAssemblyIdentity>
<PropertyGroup>
<DefineConstants>BuildVersion=%(AssemblyVersion.Version)</DefineConstants>
</PropertyGroup>
<PropertyGroup>
<TargetName>$(SolutionName).%(AssemblyVersion.Version)</TargetName>
</PropertyGroup>
</Target>
The latter solution worked as expected prior to upgrading to v4, however, upon building the project and inspecting the output of the build, the change to the TargetName
have not been applied.