欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

一步步做自己的webinstall安裝包

 更新時(shí)間:2012年10月15日 23:31:07   作者:  
眾所周知,在VS環(huán)境下自帶的WEBINSTALL項(xiàng)目無法選擇安裝路徑,這讓很多開發(fā)者頭痛不已。現(xiàn)提供一種辦法供大家參考
1、 為了能更好的操作IIS,先添加個(gè)類庫(InstallClassLibrary)到項(xiàng)目中。附代碼
復(fù)制代碼 代碼如下:

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();//以下代碼為更改網(wǎng)站指定目錄權(quán)限
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 表示應(yīng)用程序在進(jìn)程內(nèi)運(yùn)行,值 1 表示進(jìn)程外,值 2 表示進(jìn)程池
newRoot.Properties["AccessScript"][0] = true; // 可執(zhí)行腳本
newRoot.Invoke("AppCreate", true);
newRoot.Properties["DefaultDoc"][0] = "login.aspx";//設(shè)置起始頁
newRoot.Properties["AppFriendlyName"][0] = "applicationName"; // 應(yīng)用程序名
newRoot.CommitChanges();
root.CommitChanges();
}
catch (Exception ee)
{
MessageBox.Show("虛擬目錄創(chuàng)建失??!您可以手動(dòng)創(chuàng)建! " + ee.Message + ";" + ee.Source + ";" + ee.TargetSite + ";" + ee.InnerException + ";" + ee.StackTrace, "Error", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0);
}
}
}
}

2、添加安裝項(xiàng)目到解決方案中,然后在該安裝項(xiàng)目(Setup)中添加-項(xiàng)目輸出,把WEB內(nèi)容和剛才建立的類庫添加到目錄中。
3、在安裝項(xiàng)目左鍵在屬性窗口中更改制造商,安裝程序的標(biāo)題、是否針對(duì)所有用戶安裝、產(chǎn)品名等內(nèi)容。
右鍵-視圖-自定義操作,右鍵安裝-添加自定義操作-應(yīng)用程序文件夾,選擇“安裝類庫(InstallClassLibrary)”,添加完成后,在文件系統(tǒng)中右鍵應(yīng)用程序文件夾設(shè)置默認(rèn)安裝目錄。
若還想去定義更多的用戶安裝數(shù)據(jù),請(qǐng)?jiān)黾佑脩艚缑妗?

相關(guān)文章

最新評(píng)論