国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

一步步做自己的webinstall安裝包

2020-01-18 00:27:13
字體:
來源:轉載
供稿:網友
1、 為了能更好的操作IIS,先添加個類庫(InstallClassLibrary)到項目中。附代碼
復制代碼 代碼如下:

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.DirectoryServices;
using System.Diagnostics;
using System.Windows.Forms;
using System.Security.AccessControl;
using System.IO;
namespace InstallClassLibrary
{
[RunInstaller(true)]
public partial class WebInstaller : Installer
{
public WebInstaller()
{
InitializeComponent();
}
public override void Install(IDictionary stateSaver)
{
base.Install(stateSaver);
CreateVirtualDir();//以下代碼為更改網站指定目錄權限
DirectoryInfo di = new DirectoryInfo("d://yourpath//xml");
if((di.Attributes&FileAttributes.ReadOnly)!=0)
di.Attributes=FileAttributes.Normal;
DirectorySecurity ds=di.GetAccessControl();
ds.AddAccessRule(new FileSystemAccessRule("NETWORK SERVICE",FileSystemRights.Modify,InheritanceFlags.ObjectInherit|InheritanceFlags.ContainerInherit,
PropagationFlags.None,AccessControlType.Allow));
di.SetAccessControl(ds);
//
}
void CreateVirtualDir()
{
try
{
DirectoryEntry root = new DirectoryEntry("IIS://localhost/W3SVC/1/root");
DirectoryEntry newRoot = root.Children.Add("virtualName", root.SchemaClassName);
newRoot.Properties["Path"][0] = "d://yourpath"; //this.Context.Parameters["targetdir"];
newRoot.Properties["AppIsolated"][0] = 2; // 值 0 表示應用程序在進程內運行,值 1 表示進程外,值 2 表示進程池
newRoot.Properties["AccessScript"][0] = true; // 可執行腳本
newRoot.Invoke("AppCreate", true);
newRoot.Properties["DefaultDoc"][0] = "login.aspx";//設置起始頁
newRoot.Properties["AppFriendlyName"][0] = "applicationName"; // 應用程序名
newRoot.CommitChanges();
root.CommitChanges();
}
catch (Exception ee)
{
MessageBox.Show("虛擬目錄創建失敗!您可以手動創建! " + ee.Message + ";" + ee.Source + ";" + ee.TargetSite + ";" + ee.InnerException + ";" + ee.StackTrace, "Error", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0);
}
}
}
}

2、添加安裝項目到解決方案中,然后在該安裝項目(Setup)中添加-項目輸出,把WEB內容和剛才建立的類庫添加到目錄中。
3、在安裝項目左鍵在屬性窗口中更改制造商,安裝程序的標題、是否針對所有用戶安裝、產品名等內容。
右鍵-視圖-自定義操作,右鍵安裝-添加自定義操作-應用程序文件夾,選擇“安裝類庫(InstallClassLibrary)”,添加完成后,在文件系統中右鍵應用程序文件夾設置默認安裝目錄。
若還想去定義更多的用戶安裝數據,請增加用戶界面。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 云南省| 镇巴县| 鹤庆县| 酉阳| 新竹县| 奈曼旗| 正蓝旗| 大同县| 那曲县| 都江堰市| 遵义县| 大城县| 龙里县| 湛江市| 清水河县| 桂阳县| 吴忠市| 沭阳县| 马龙县| 会泽县| 荣昌县| 临潭县| 尖扎县| 布尔津县| 雅安市| 花垣县| 台安县| 休宁县| 迭部县| 庆安县| 拉孜县| 铜陵市| 彩票| 上林县| 襄汾县| 滦平县| 岗巴县| 莱阳市| 河南省| 大安市| 区。|