Solve the problem that the .NET (WebApplication) installation deployment cannot choose the installation path.

zhaozj2021-02-17  53

(1) Description ????? WebApplication When installing deployment, you cannot choose the installation path; resolve the idea: ??? (1) Create a console application createWebDir.exe, the role is to create a web virtual directory. ??? (2) Installing the deployment to install the WINDOWS Application Deployment, not the WebApplication installation ?????????? Deployment. Because Windows Application is installed, the operation is selected, the path is selected .????????? Save in [Targetdir]. ??? (3) Add custom operations to install the deployment - "Custom Action", select CreateWebDir.exe, its properties: ?????? (a) arguments = bug2000 [targetdir] , Ie CreatewebDir.exe passed into two ???????????????? parameters. BUG2000 refers to a web virtual directory; [targetdir] refers to the physical directory. ??????? (b) installerclass = false, set to non-ProjectInstaller class

(2) Creating a console application createwebdir.exe ??? (1) main.cs ???????? (2) createwebdir.cs ?? see "IIS Control management - the creation and management of Web virtual directory "?????? (3) InIfile.cs See" Operation of INI file (ASP.NET C #) "

(3) Main.cs? File

Using system; using system.directoryservices; using system.Runtime.InteropServices;

Namespace CreateweBDir {? ///

Summary of /// Class1. ? ///

Class Start

? {

?? ///

??/// The main entry point for the application. ?? /// parameter args: ?? /// ??? args [0]: virtual path ?? /// ??? args [1]: physical path ?? // ??? Args [2] : The server name, can not enter, default localhost ?? /// ??? ?? /// run example: ?? // ??? CreateWebDir.exe Virdirtest D: / Work ?? //??? CreateWebdir.exe Virdirtest D: / Work? Deve-server ?? ///

?? [stathread]

?? static void main (string [] args

?? {

??? INT i;

??? String inIfile;

??? f (args.length> 1)

??? {

???? inIfile = args [1];

???? if (inIfile.substring (inIfile.length-1, 1) == "//")

????? INIFILE = args [1] "bug2004.ini";

???? Else

????? INIFILE = args [1] "// bug2004.ini";

???}

??? ELSE

???? INIFILE = @ "c: /bug2004.ini";

????? String inIfile = @ "d :/bug2000.ini"; ??? if (! file.exists (inifi)) ??? {???? using (filestream fs = file.create (inIfile) ) ???? {????? fs.close (); ????} ???} ??? INIFILE Myini = new inIfile (InIfile);

??? for (i = 0; i

??? {

???? Myini.iniWriteValue ("WebDir", "arg" i.tostring (), args [i]);

???}

???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

??? String sserver = "localhost"; ??? if (args.length> 2) sserver = args [2];

??? iismanager iismg = new iiSMANager (sserver); ??? Iismg.connect (); ?????? ife (iismg.exists (args [0])) ??? {???? console.write (Args [0] "is exist!"); ???? Myini.iniWriteValue ("WebDir", "WebDirexist", "TRUE"); ???} ??? Else ??? {???? Myini.iniWriteValue ("WebDir", "WebDirexist", "False");

???? Iismg.get_anonymoususeuser (); ???? string [] Anonymoususer = new string [2]; ???? anonymoususeuser [0] = Iismg.anonymoususeuseusername; ???? anonymoususer [1] = iismg.anonymoususeuserpass ;

???? virtualdirectory newvirdir = new virtualdirectory (args [0], args [1], anonymoususer); ???? if (iismg.create (newvirdir)) ???? {????? console.write Args [0] "Create Success!"); ????? Myini.iniWriteValue ("WebDir", "WebDircReated", "True"); ????} ???? Else ???? {? ???? console.write (args [0] "creates unsuccessful!"); ????? Myini.iniWriteValue ("WebDir", "WebDircReated", "false"); ????} ?? ?

??? Iismg.close (); ??}

?}}

转载请注明原文地址:https://www.9cbs.com/read-28939.html

New Post(0)