我有下面的代碼,但是我雖然在BeforeInstall訪問屬性和檢索值部署:this.Context.Parameters沒有提供整個安裝過程
this.Context.Parameters["SERVICENAME"]
,在OnCommitted相同屬性返回「」。
哪裏這個數據去,它是如何被清空,在哪裏可以找到每一種方法和什麼的秩序崩潰被傳遞在哪裏?
[RunInstaller(true)]
public partial class ProjectInstaller : System.Configuration.Install.Installer
{
public string ServiceName { get; protected set; }
/// <summary>
///
/// </summary>
public ProjectInstaller()
{
InitializeComponent();
}
/// <summary>
///
/// </summary>
/// <param name="savedState"></param>
protected override void OnBeforeInstall(IDictionary savedState)
{
base.OnBeforeInstall(savedState);
this.ServiceName = this.Context.Parameters["SERVICENAME"].ToString();
this.serviceInstaller1.ServiceName = this.ServiceName;
this.serviceInstaller1.DisplayName = this.ServiceName;
}
/// <summary>
////
/// </summary>
/// <param name="savedState"></param>
protected override void OnCommitted(IDictionary savedState)
{
base.OnCommitted(savedState);
string targetDirectory = Path.GetDirectoryName(Context.Parameters["AssemblyPath"]); ;
string path = System.IO.Path.Combine(targetDirectory, "Services.Win32.exe.config");
System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
xDoc.Load(path);
System.Xml.XmlNode node = xDoc.SelectSingleNode("/configuration/applicationSettings/Services.Win32.Properties.Settings/setting[@name='TaskManagerServiceName']/value");
node.InnerText = (this.ServiceName); // here this.ServiceName is "" so was this.Context.Parameters[""SERVICENAME"] when i was using that
xDoc.Save(path);
}