Control Visual Studio .NET development environment

xiaoxiao2021-03-06  108

When the SUPERLIB component installer has encountered several troubles. Mainly to complete a few functions: Add a wizard to the Virsual Studio .NET to guide users to complete some simple work; add a new Tab to the Virsual Studio .NET 2003 toolbox and register the Web Form Control in the Superlib component library . About adding a new TAB to the Virsual Studio .NET 2003 toolbox and register the web form control in the Superlib component library, a few days have been posted: http://www.cnblogs.com/haozidong/articles /52432.HTM does a wizard, and it has also encountered a bit of trouble. Today, the custom wizard is also completed, summarizing it out. First post the reference article, English, too long, not translated. Http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/customwebwiz.asp http://msdn.microsoft.com/library/en-us/dv_vstechart/ HTML / CUSTOMPROJECTWIZ.ASP Add a Web Form Wizard with the above article enough, I am talking about how to add a custom C # ASP.NET Web Application Wizard, about modifying the default.js file. The situation is that we need to replace the standard WebForm1 in the Ordinary C # ASP.NET Web Application Wizard to our own (other than web.config directly), because our WebForm1 may need a different namespace reference, may Registering tagprefix, there may already have a few of our own standard controls, and more. Existing wizards automatically generate a webform1.aspx.cs file when adding WebForm1.apsX to the project, so that although in accordance with the practice in the above article, we have added custom WebForm1.aspx.cs, modify Templates.inf , Modified Default.js to complete the delete automatically generated WebForm1.aspx.cs and so on. It seems OK? However, each time you use a new wizard to generate an project, you will be able to add WebForm1.aspx.cs, will prompt WebForm1.aspx.cs already existed, depressed! I want to add a little debug in Default.js, with Alert, the result is not, the wizard's execution environment does not support the alert command, what should I do? Haha, use FileSystemObject to ok: var file = fso.opentextfile ("c: //aaa.txt", 8, true); fso.writeline ("aaaaaaa"); then write debugging information in text file (Maybe you will be prompted: No permissions, don't worry, just run the next time).

In the web engineering, the path of the file is http: //localhost/webapplication1/webform1.aspx, so in this format, so use FileSystemObject with the SavedeleteFile function in the above article to delete the automatic adding webform1.aspx.cs file, How to do? We need this to do this: if (strtarget == "Webform1.aspx") {if (Projfile! = Null) {var item = doesfileexistinproj (Projfile, "WebForm1.aspx.cs"); if (item! = Null) Item. Here, you should pay attention to the structure of the project, WebForm1.aspx.cs get the next level in WebForm1.aspx in Webform1.aspx. OK? Has not yet, although it is possible to delete the automatic adding webform1.aspx.cs file, but after the wizard is completed, WebForm1.aspx.cs is not hidden. The corresponding RESX file is not seen, what is going on? It turns out that RESX is automatically generated when the development environment opens WebForm1.aspx, and WebForm1.aspx.cs is also hidden at this time. Before performing the above delete file code, WebForm1.aspx has been opened in the development environment, we need After adding your own WebForm1.aspx.cs, the development environment opens WebForm1.aspx. Since AddFilesToProject defined function: function AddFilesToProject (oProj, strProjectName, strProjectPath, InfFile, AddItemFile) {try {dte.SuppressUI = false; var projItems; if (AddItemFile) projItems = oProj; else projItems = oProj.ProjectItems; var strTemplatePath = wizard .Findsymbol ("Templates_Path");

Var stratpl = ""; var strname = "";

// if (not a web project) IF (strProjectPath.Charat (strProjectPath.length - 1)! = "//") strProjectPath = "//";

var strTextStream = InfFile.OpenAsTextStream (1, -2); while (! strTextStream.AtEndOfStream) {strTpl = strTextStream.ReadLine (); if (strTpl = "!") {strName = strTpl; var strTarget = ""; var strFile = ""; if (AddItemFile!) {strTarget = GetCSharpTargetName (strName, strProjectName);} else {strTarget = wizard.FindSymbol ( "ITEM_NAME");} var fso; fso = new ActiveXObject ( "Scripting.FileSystemObject"); var TemporaryFolder = 2; var tfolder = fso.GetSpecialFolder (TemporaryFolder); var strTempFolder = fso.GetAbsolutePathName (tfolder.Path); var strFile = strTempFolder "//" fso.GetTempName (); var strClassName = strTarget.split ( " Wizard.addsymbol ("Safe_Class_name", STRCLASSNAME [0]); Wizard.Addsymbol ("Safe_Item_Name", STRCLASSNAME [0]);

Var startemplate = setemplatePath "//" stratpl; var bcopyonly = false; var strext = startpl.substr (strtpl.lastIndexof ("."); if (strext == ". BMP" || strext == ". ICO "|| strets ==". GIF "|| strets ==". RTF "|| strets ==". CSS ") bcopyonly = true; wizard.renderTemplate (Strtemplate, Strfile, Bcopyonly, true);

Var Projfile = Projitems.addFromTemplate (STRFILE, STRTARGET); SafeDeletefile (FSO, STRFILE); if (Projfile) SetFileProperties (Projfile, Strname);

IF (strtarget == "Webform1.aspx.cs") {var item = doesfileexistinproj (oproj, "webform1.aspx"); if (item! = null) {var window = item.open (vsViewkindprimary); window.visible = True;}} if (strujet == "Webform1.aspx") {if (projfile! = null) {var item = doesfileexistinproj (Projfile, "Webform1.aspx.cs"); if (item! = null) Item.delete ();}}}} strTextStream.Close ();} catch (e) {strTextStream.Close (); throw e;}} function AddFilesToCSharpProject standard function AddFilesToCSharpProject (oProj, strProjectName, strProjectPath, InfFile, AddItemFile) {try { DTE.SUPPRESSUI = FALSE; VAR Projitems; if (additemfile) Projitems = oproj; else projitems = oproj.projectItems; var strTemplatePath = Wizard.FindSymbol ("Templates_Path");

Var stratpl = ""; var strname = "";

// if (not a web project) IF (strProjectPath.Charat (strProjectPath.length - 1)! = "//") strProjectPath = "//";

var strTextStream = InfFile.OpenAsTextStream (1, -2); while (! strTextStream.AtEndOfStream) {strTpl = strTextStream.ReadLine (); if (strTpl = "!") {strName = strTpl; var strTarget = ""; var strFile = ""; Ing (! Additemfile) {stratarget = getcsharptargetname (strname, strprojectname);} else {stratarget = wizard.findsymbol ("item_name");}

var fso; fso = new ActiveXObject ( "Scripting.FileSystemObject"); var TemporaryFolder = 2; var tfolder = fso.GetSpecialFolder (TemporaryFolder); var strTempFolder = fso.GetAbsolutePathName (tfolder.Path); var strFile = strTempFolder "// " fso.getTempname ();

Var strclassname = stratarget.split ("."); wizard.addsymbol ("Safe_Class_Name", StrclassName [0]); Wizard.Addsymbol ("Safe_Item_name", strclassname [0]);

Var startemplate = setemplatePath "//" stratpl; var bcopyonly = false; var strext = startpl.substr (strtpl.lastIndexof ("."); if (strext == ". BMP" || strext == ". ICO "|| strets ==". GIF "|| strets ==". RTF "|| strets ==". CSS ") bcopyonly = true; wizard.renderTemplate (Strtemplate, Strfile, Bcopyonly, true);

Var Projfile = Projitems.addFromTemplate (STRFILE, STRTARGET); SafeDeletefile (FSO, STRFILE); if (Projfile) SetFileProperties (Projfile, Strname);

Var Bopen = false; if (additemfile) bopen = true; Else IF (doopenfile) Bopen = true;

IF (Bopen) {var window = projfile.open (vsViewkindprimary); window.visible = true;}}} strtextStream.close ();} catch (e) {strTextStream.close (); throw e;}} The modification is no longer listed.

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

New Post(0)