views:

598

answers:

2

I don't want to replace every file when I change some product information like version, product name and author name. A Visual Studio setup project has constant variables like TARGETDIR, SystemFolder and so on.

Is it possible to change setup project properties based on a referenced DLL?

PS. Can WiX do this?

A: 

I'm not sure I understand your question correctly. Did you mean that you want to change the project (dll) metadata easily?

If this is what you mean, then you can just change or set properties in the AssemblyInfo.cs file which is originally located in the Properties folder of the project. Usage example:

[assembly: AssemblyVersion("1.0.0.342")]

Furthermore, if you have many projects in the same solution you can define version information in one build.cs file and one config.cs file in the following way.

In every project's .csproj file add (for example)

<Compile Include="..\Configuration\build.cs">
  <Link>Configuration\build.cs</Link>
</Compile>
<Compile Include="..\Configuration\config.cs">
  <Link>Configuration\config.cs</Link>
</Compile>

In a common Configuration directory add a file config.cs. Inside you should write for example:


class ReferenceInfo
{
  internal const string Version = "1.0.0.342"";
  internal const string AssemblyVersion = "1.0.0.342"";
}

In same directory add a file build.cs and Inside you can write for example:


[assembly: AssemblyProduct("My Product")]

[assembly: AssemblyFileVersion(ReferenceInfo.Version)]
[assembly: AssemblyVersion(ReferenceInfo.AssemblyVersion)]

Hope it helps.

Sharon
Your answer isn't correct answer for my question. My question is how to change some property in setup project like Author name, Product name based on installed dll. For example, I add MySolution.App.dll to my setup project. I need to use AssemblyProduct value of MySolution.App.dll for product name in setup project. Thanks for try to answer my question.
Soul_Master
A: 

Visual Studio runs off of templates, so I think you might be talking about updating their default templates. If so they are located here:

C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\General\1033\AssemblyInfo.zip

I've edited these templates to ensure that all future projects that I create start with the values I need.

Arron