此文章有參考國外網頁http://leon.mvps.org/DotNet/RegasmInstaller.aspx
步驟
1.在Installer專案中,打開Custom Actions介面
2.在Install右鍵,選擇加入自訂動作
3.Application Folder雙點進入,選擇自己的SolidEdge AddIn元件
4.在commit目錄重複第3項動作
5.在AddIn元件加入以下程式碼,
需要注意執行的Framework是x86、x64版本,如果SolidEdge是支援x64,則安裝外掛要以x64的
regasm.exe安裝
[RunInstaller(true)]
public partial class RegisterDll : Installer
{
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
public override void Commit(System.Collections.IDictionary savedState)
{
base.Commit(savedState);
// Get the location of regasm
//string regasmPath = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory() + @"regasm.exe";
//x64
string regasmPath = @"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe";
// Get the location of our DLL
string componentPath = typeof(RegisterDll).Assembly.Location;
// Execute regasm
System.Diagnostics.Process.Start(regasmPath, "/codebase \"" + componentPath + "\"");
}
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);
}
}
6.測試專案安裝是否成功