MSI データベースを編集して、MSI の製品コード、アップグレード コード、および製品名を変更しています。
参照:- http://www.codeproject.com/Articles/383481/Editing-an-MSI-Database
上記のすべてのパラメーターを変更できますが、 Package Code を変更できません。
パッケージコードを変更する方法を提案してください。
MSI データベースを編集して、MSI の製品コード、アップグレード コード、および製品名を変更しています。
参照:- http://www.codeproject.com/Articles/383481/Editing-an-MSI-Database
上記のすべてのパラメーターを変更できますが、 Package Code を変更できません。
パッケージコードを変更する方法を提案してください。
好奇心から、vbscript でそれを行う方法を見つけました。「プロパティ #9」はパッケージ コード (リビジョン番号) です。
Set wi = CreateObject("WindowsInstaller.Installer")
Set summary = wi.SummaryInformation("your.msi", 2)
summary.Property(9) = "{PUT-NEW-GUID-HERE}"
summary.Persist
ここでの要件は、同じ MSI を複数回インストールすることであると推測しています。つまり、その一連の GUID を変更する必要があります。ただし、その問題を解決するより一般的な方法は、MSINEWINSTANCE を使用することです。
https://msdn.microsoft.com/en-us/library/aa370326(v=vs.85).aspx
https://msdn.microsoft.com/en-us/library/aa369528(v=vs.85).aspx
毎回ベース MSI ファイルを変更しないようにします。
MSIがそれぞれのパッケージコードにキャッシュを作成し、MSIを使用してアプリケーションの別のインスタンスを作成することを制限しているため、必要だったので、これを行いました
using (var database = new Database(@"D:\\Nirvana\\WorkingCopy\\trunk\\proj1\\installer.msi", DatabaseOpenMode.Direct))
{
database.SummaryInfo.RevisionNumber = "{" + Guid.NewGuid() + "}";
}
パッケージコードを設定する必要があるのはなぜですか?
各ビルド中に自動生成されます。
Package 要素のドキュメントをご覧ください。
http://wixtoolset.org/documentation/manual/v3/xsd/wix/package.html
"製品またはマージ モジュールのパッケージ コード GUID。製品をコンパイルするとき、ビルドごとにパッケージ コードを生成できるようにするために、この属性を設定しないでください。マージ モジュールをコンパイルするとき、この属性をモジュール化ガイド。」
ランダムな GUID を自動的に生成する Nikolay スクリプトを拡張しました。このスクリプトはドラッグ アンド ドロップもサポートしており、引数を介して呼び出されるため (cscript を使用して簡単に自動化できます)、Windows インストーラー オブジェクトを作成する前にファイルが書き込み可能かどうかをチェックします (ファイルが InstEd などのアプリケーションによってロックされている場合は、エラーをスローします)。
Set objArgs = Wscript.Arguments
Set objFso = CreateObject("scripting.filesystemobject")
'iterate through all the arguments passed
' https://community.spiceworks.com/scripts/show/1653-drag-drop-vbscript-framework
For i = 0 to objArgs.count
on error resume next
'try and treat the argument like a folder
Set folder = objFso.GetFolder(objArgs(i))
'if we get an error, we know it is a file
If err.number <> 0 then
'this is not a folder, treat as file
ProcessFile(objArgs(i))
Else
'No error? This is a folder, process accordingly
For Each file In folder.Files
ProcessFile(file)
Next
End if
On Error Goto 0
Next
Function ProcessFile(sFilePath)
' http://www.wisesoft.co.uk/scripts/vbscript_file_modified_date.aspx
' Set objFile = objFSO.GetFile(sFilePath)
' MsgBox "Now processing file: " & CDATE( objFile.DateLastModified)
If Not IsWriteAccessible(sFilePath) Then WScript.Echo "Error persisting summary property stream" : Wscript.Quit 2
'Do something with the file here...
' https://stackoverflow.com/questions/31536349/set-package-code-of-msi-using-vbscript
Set installer = CreateObject("WindowsInstaller.Installer")
Set summary = installer.SummaryInformation(sFilePath, 2)
summary.Property(9) = CreateGuid()
summary.Persist
End Function
' https://stackoverflow.com/questions/968756/how-to-generate-a-guid-in-vbscript
Function CreateGuid()
CreateGuid = Left(CreateObject("Scriptlet.TypeLib").Guid,38)
End Function
' https://stackoverflow.com/questions/12300678/how-can-i-determine-if-a-file-is-locked-using-vbs
Function IsWriteAccessible(sFilePath)
' Strategy: Attempt to open the specified file in 'append' mode.
' Does not appear to change the 'modified' date on the file.
' Works with binary files as well as text files.
' Only 'ForAppending' is needed here. Define these constants
' outside of this function if you need them elsewhere in
' your source file.
Const ForReading = 1, ForWriting = 2, ForAppending = 8
IsWriteAccessible = False
Dim oFso : Set oFso = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
Dim nErr : nErr = 0
Dim sDesc : sDesc = ""
Dim oFile : Set oFile = oFso.OpenTextFile(sFilePath, ForAppending)
If Err.Number = 0 Then
oFile.Close
If Err Then
nErr = Err.Number
sDesc = Err.Description
Else
IsWriteAccessible = True
End if
Else
Select Case Err.Number
Case 70
' Permission denied because:
' - file is open by another process
' - read-only bit is set on file, *or*
' - NTFS Access Control List settings (ACLs) on file
' prevents access
Case Else
' 52 - Bad file name or number
' 53 - File not found
' 76 - Path not found
nErr = Err.Number
sDesc = Err.Description
End Select
End If
' The following two statements are superfluous. The VB6 garbage
' collector will free 'oFile' and 'oFso' when this function completes
' and they go out of scope. See Eric Lippert's article for more:
' http://blogs.msdn.com/b/ericlippert/archive/2004/04/28/when-are-you-required-to-set-objects-to-nothing.aspx
'Set oFile = Nothing
'Set oFso = Nothing
On Error GoTo 0
If nErr Then
Err.Raise nErr, , sDesc
End If
End Function