G2A Many GEOs
SHARE
TWEET

URL rewrite intellisense setup file updated for VS 2012

altair Jan 17th, 2013 2,136 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. // Helper script to update the Visual Studio XML Cache with rewrite schema
  3. //
  4.  
  5. /*
  6.  * This tool is provided by Ruslan Yakushev (http://ruslany.net) under the Microsoft Public License
  7.  * (http://www.microsoft.com/opensource/licenses.mspx).
  8.  * Updated for Visual Studio 2012 by Michal A. Valasek (http://www.rider.cz, http://www.aspnet.cz/)
  9.  *
  10.  * This license governs use of the accompanying software. If you use the software, you accept this license.
  11.  * If you do not accept the license, do not use the software.
  12.  *
  13.  * Definitions
  14.  * The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here
  15.  * as under U.S. copyright law. A "contribution" is the original software, or any additions or changes to the
  16.  *  software. A "contributor" is any person that distributes its contribution under this license.
  17.  *  "Licensed patents" are a contributor's patent claims that read directly on its contribution.
  18.  *  
  19.  *  Grant of Rights
  20.  *  (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations
  21.  *  in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to
  22.  *  reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution
  23.  *  or any derivative works that you create.
  24.  *  (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations
  25.  *  in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its
  26.  *  licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its
  27.  *  contribution in the software or derivative works of the contribution in the software.
  28.  *  
  29.  *  Conditions and Limitations
  30.  *  (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo,
  31.  *  or trademarks.
  32.  *  (B) If you bring a patent claim against any contributor over patents that you claim are infringed by
  33.  *  the software, your patent license from such contributor to the software ends automatically.
  34.  *  (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark,
  35.  *  and attribution notices that are present in the software.
  36.  *  (D) If you distribute any portion of the software in source code form, you may do so only under this
  37.  *  license by including a complete copy of this license with your distribution. If you distribute any
  38.  *  portion of the software in compiled or object code form, you may only do so under a license that
  39.  *  complies with this license.
  40.  *  (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express
  41.  *  warranties, guarantees, or conditions. You may have additional consumer rights under your local laws
  42.  *  which this license cannot change. To the extent permitted under your local laws, the contributors
  43.  *  exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.
  44.  */
  45.  
  46. function UpdateSchemaFile(schemaFileName) {
  47.     var rewriteSchemaFile = "rewrite.xsd";
  48.     var dotNetSchemaDir = vs11CommonTools.substring(0, vs11CommonTools.indexOf("Common7\\Tools")) + "Xml\\Schemas\\";
  49.     var dotNetSchemaFile = dotNetSchemaDir + schemaFileName;
  50.  
  51.     var sourceXml = new ActiveXObject("msxml2.DOMDocument.3.0");
  52.     var targetXml = new ActiveXObject("msxml2.DOMDocument.3.0");
  53.  
  54.     if (sourceXml.load(rewriteSchemaFile) == 0) {
  55.         WScript.Echo(" Failed to open file " + rewriteSchemaFile + ".");
  56.         return;
  57.     }
  58.  
  59.     if (targetXml.load(dotNetSchemaFile) == 0) {
  60.         WScript.Echo("Failed to open file " + dotNetSchemaFile + ". Make sure that the script is run in the elevated command prompt.");
  61.         return;
  62.     }
  63.  
  64.     // Check if the <rewrite> element is not defined in the DotNetConfig.xsd
  65.     var rewriteNode = rewriteNode = targetXml.selectSingleNode("//xs:schema/xs:element[@name='system.webServer']/xs:complexType/xs:choice/xs:element[@name='rewrite']");
  66.     if (rewriteNode != null) {
  67.         rewriteNode.parentNode.removeChild(rewriteNode);
  68.     }
  69.  
  70.     rewriteNode = sourceXml.selectSingleNode("//xs:schema/xs:element[@name='rewrite']");
  71.     if (rewriteNode == null) {
  72.         WScript.Echo("The definition for the <rewrite> element is not found in the file " + rewriteSchemaFile + ".");
  73.         return;
  74.     }
  75.  
  76.     var systemWebServerNode = targetXml.selectSingleNode("//xs:schema/xs:element[@name='system.webServer']/xs:complexType/xs:choice");
  77.     if (systemWebServerNode == null) {
  78.         WScript.Echo("The definition for the <system.webServer> element is not found in the file " + dotNetSchemaFile + ".");
  79.         return;
  80.     }
  81.  
  82.     // Add the <rewrite> element definition to the schema
  83.     systemWebServerNode.appendChild(rewriteNode);
  84.  
  85.     // Make a copy of original schema file in case anything goes wrong
  86.     fso.CopyFile(dotNetSchemaFile, dotNetSchemaFile + ".bak", true);
  87.  
  88.     // Save the changes to the schema file
  89.     targetXml.save(dotNetSchemaFile);
  90.  
  91.     WScript.Echo("Updated " + schemaFileName)
  92. }
  93.  
  94. var shell = new ActiveXObject("WScript.Shell");
  95. var vs11CommonTools = shell.ExpandEnvironmentStrings("%VS110COMNTOOLS%");
  96. var fso = new ActiveXObject("Scripting.FileSystemObject");
  97.  
  98. // Check if Visual Studio is installed
  99. if (vs11CommonTools.length == 0) {
  100.     WScript.Echo("Could not find Visual Studio 2012 installation path");
  101.     WScript.Quit(1);
  102. }
  103.  
  104. WScript.Echo("Updating Visual Studio Schema Cache files:");
  105. UpdateSchemaFile("DotNetConfig35.xsd");
  106. UpdateSchemaFile("DotNetConfig40.xsd");
  107. UpdateSchemaFile("1033\\DotNetConfig.xsd");
RAW Paste Data
Ledger Nano X - The secure hardware wallet
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top