开发者

Embed providing server URL into an MSI

开发者 https://www.devze.com 2022-12-14 04:13 出处:网络
I have an ASP.NET server that provides its client as an MSI download (similar to CCNet/CCTray). There can be more than a single server (for example, for dev/testing/production, but there may be differ

I have an ASP.NET server that provides its client as an MSI download (similar to CCNet/CCTray). There can be more than a single server (for example, for dev/testing/production, but there may be different production instances).

So client has to know server URL. I can not ask users for URL because it does not really make much sense for them, they do not know of any other servers anyway. So the MSI should have the server URL included.

Now, I can pre-build different versions of MSI for different environments (since there are already distinct build steps for these dev/test anyway), but this does not solve a question of several productions where the product is already built.

So I think server should modify th开发者_JAVA技巧e MSI and add the correct URL before serving it. Is it possible without rebuilding the msi? What is the easiest way to achieve this?


Basically an MSI file is just a database, using the Windows Installer API you can run arbitrary SQL on this database... for example:

Dim installer, database, view, result
Set installer = CreateObject("WindowsInstaller.Installer")
Set database = installer.OpenDatabase ("setup.msi", 1)
Set view = database.OpenView ("INSERT INTO Property (Property, Value) VALUES ('URLPROPERTY', 'http://some.server/blah/service')")
view.Execute
database.Commit
Set database = nothing

Just use this script in a post-build or pre-download process and you'll be sorted :)

For more information and additional (better) sample scripts, refer to the Windows SDK


I don't know of a way to modify the MSI itself, but you can have the server write the url to a known file on the client and have the MSI project read in that file (and delete it). That way you can have one MSI build for all servers.


Modifying MSI file on web server before serving it is not a good idea. What if someone requests the file while you are still updating it?

You are better off modifying your build process to produce a set of MSI files corresponding to production websites. Each website would have its own custom MSI file.

0

精彩评论

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