The company that I work for has a product that is used by multiple customers. Unfortunately, one of the customers does not like the name we gave the product and has paid for it to be assigned a different name. As we support the same product with two names, the best way for us to manage this has been to change the AssemblyTitle and AssemblyProduct in the WinForms project's AssemblyInfo.cs file.
As the Setup projects also need to give the product name, to prevent issues with developers forgetting to change name, I have created 2 separate Setup projects, one for each product name, but which are otherwise the same and reference the same WinForms project.
To make sure the AssemblyInfo.cs file is correct, I was thinking of automating this through a PreBuild Event for each Setup project. Does anyone know an effective way to do this? Most of my research has led me to links showing how to change information within the Setup project.
Thanks
MSBuild Community Tasks has an AssemblyInfo task that'll allow you to generate an AssemblyInfo file. Call this task inside a PreBuild event and you're good to go!
EDIT, Some details...
Assuming you've already got the community tasks installed, add this Import statement atop your *.csproj:
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
Next uncomment the <Target Name=BeforeBuild">
section at the end of the project file and add the AssembyInfo task, so you end up with something like this:
<Target Name="BeforeBuild">
<AssemblyInfo OutputFile="Properties\AssemblyInfo.cs"
CodeLanguage="CS"
AssemblyCompany="My Company"
AssemblyCopyright="(C) My Company, 2013"
AssemblyFileVersion="1.0.0.0"
AssemblyInformationalVersion="1.0.0.0"
AssemblyTitle="My Assembly Title"
AssemblyProduct="My Product"
AssemblyVersion="1.0.0.0"
/>
</Target>
Reload your project and build, you should see your values attached to the assembly.