开发者

Can't create correct folder structure in my MSI

My application stores data in

C:\Documents and Settings\All Users\Application Data\Company\Product\foo

However if开发者_运维知识库 I use Application.CommonAppDataPath in my code, it is appending the assembly version on the end pf the path. eg

C:\Documents and Settings\All Users\Application Data\Company\Product\foo\1.0.2.0

This means that my app cant find the data I was expecting. I can manipulate my code to strip off the last folder, but what I'd really like to do is to have my MSI create the appropriate assembly versioned folder.

I have tried;

[CommonAppDataFolder][Manufacturer]\[ProductName]\[Version]\
[CommonAppDataFolder][Manufacturer]\[ProductName]\[ProductVersion]\ 

But neither gives me the correct structure. (In fact one doesn't create a folder and the other creates one based on the MSI version).

So is there a way of creating the appropriate folder through the msi, or do I need to resort to either parsing the AppDataPath, or having my app create the version folder and the supporting structures it needs?


If you define ProductVersion property in your MSI, then it would work. (Or you can call it whatever you like.)

As far as I know there's no standard property in Windows Installer which has the version of the assembly. Hence you have to create it yourself.

The disadvantage of this approach is that you have to manually update this version property in Setup project when the version of your assembly changes.


ProductVersion is a predefined installer property which stores your MSI version. This is a much more reliable version for your application data folder path than the assembly version.

Most installers write this version somewhere (for example the registry) and then the installed application reads and uses it.

It also has more sense this way. You are installing a version of your product, not the version of a file. If the assembly version stays the same in two different installer versions, some conflicts may occur.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜