一步步做自己的webinstall安裝包
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)文章
.net core webapi jwt 更為清爽的認(rèn)證詳解
這篇文章主要介紹了.net core webapi jwt 更為清爽的認(rèn)證詳解,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2019-05-05ASP.NET中MVC傳遞數(shù)據(jù)的幾種形式總結(jié)
這篇文章主要介紹了ASP.NET中MVC傳遞數(shù)據(jù)的幾種形式,以實(shí)例形式較為詳細(xì)的分析總結(jié)了MVC數(shù)據(jù)傳遞的相關(guān)技巧與注意事項(xiàng),具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-10-10.Net 文本框?qū)崿F(xiàn)內(nèi)容提示的實(shí)例代碼(仿Google、Baidu)
這篇文章主要介紹了.Net 文本框?qū)崿F(xiàn)內(nèi)容提示的實(shí)例代碼,需要的朋友可以參考下2014-02-02Repeater控件與PagedDataSource結(jié)合實(shí)現(xiàn)分頁功能
Repeater控件與PagedDataSource相結(jié)合實(shí)現(xiàn)其分頁功能,如果控件開發(fā)人員需對(duì)自定義數(shù)據(jù)綁定控件提供分頁支持,即可使用此類2014-01-01.Net語言Smobiler開發(fā)利用Gridview控件設(shè)計(jì)較復(fù)雜的表單
這篇文章主要為大家詳細(xì)介紹了.Net語言Smobiler開發(fā)利用Gridview控件設(shè)計(jì)較復(fù)雜的表單,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-09-09微信公眾平臺(tái)開發(fā)之認(rèn)證"成為開發(fā)者".Net代碼解析
這篇文章主要為大家詳細(xì)解析了微信公眾平臺(tái)開發(fā)之認(rèn)證"成為開發(fā)者".Net代碼,感興趣的小伙伴們可以參考一下2016-06-06.net下實(shí)現(xiàn)Word動(dòng)態(tài)填加數(shù)據(jù)打印
.net下實(shí)現(xiàn)Word動(dòng)態(tài)填加數(shù)據(jù)打印...2007-04-04