[mapguide-commits] r9956 - in trunk/Tools/MgInstantSetup: InstantSetup InstantSetup.Core
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed Aug 10 08:59:37 PDT 2022
Author: jng
Date: 2022-08-10 08:59:36 -0700 (Wed, 10 Aug 2022)
New Revision: 9956
Modified:
trunk/Tools/MgInstantSetup/InstantSetup.Core/AppCmd.cs
trunk/Tools/MgInstantSetup/InstantSetup.Core/IISSetupConfigurationProcess.cs
trunk/Tools/MgInstantSetup/InstantSetup/IISConfigCtrl.Designer.cs
trunk/Tools/MgInstantSetup/InstantSetup/IISConfigCtrl.cs
Log:
Add flag to register netstandard assembly reference for mapviewernet if required (will be required for MGOS 4.0 Preview 4 and newer releases)
Fixes #2850
Modified: trunk/Tools/MgInstantSetup/InstantSetup/IISConfigCtrl.Designer.cs
===================================================================
--- trunk/Tools/MgInstantSetup/InstantSetup/IISConfigCtrl.Designer.cs 2022-08-10 15:57:43 UTC (rev 9955)
+++ trunk/Tools/MgInstantSetup/InstantSetup/IISConfigCtrl.Designer.cs 2022-08-10 15:59:36 UTC (rev 9956)
@@ -47,6 +47,7 @@
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.rdDotNet = new System.Windows.Forms.RadioButton();
this.rdPhp = new System.Windows.Forms.RadioButton();
+ this.chkRefNetstandard = new System.Windows.Forms.CheckBox();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numSitePort)).BeginInit();
@@ -270,15 +271,27 @@
this.rdPhp.UseVisualStyleBackColor = true;
this.rdPhp.CheckedChanged += new System.EventHandler(this.rdPhp_CheckedChanged);
//
+ // chkRefNetstandard
+ //
+ this.chkRefNetstandard.AutoSize = true;
+ this.chkRefNetstandard.Location = new System.Drawing.Point(12, 352);
+ this.chkRefNetstandard.Name = "chkRefNetstandard";
+ this.chkRefNetstandard.Size = new System.Drawing.Size(368, 17);
+ this.chkRefNetstandard.TabIndex = 2;
+ this.chkRefNetstandard.Text = "Add netstandard reference (needed for MGOS 4.0 Preview 4 and newer)";
+ this.chkRefNetstandard.UseVisualStyleBackColor = true;
+ this.chkRefNetstandard.CheckedChanged += new System.EventHandler(this.chkRefNetstandard_CheckedChanged);
+ //
// IISConfigCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.chkRefNetstandard);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Name = "IISConfigCtrl";
- this.Size = new System.Drawing.Size(422, 358);
+ this.Size = new System.Drawing.Size(422, 383);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
@@ -289,6 +302,7 @@
this.groupBox4.ResumeLayout(false);
this.groupBox4.PerformLayout();
this.ResumeLayout(false);
+ this.PerformLayout();
}
@@ -313,5 +327,6 @@
private System.Windows.Forms.RadioButton rdPhp;
private System.Windows.Forms.TextBox txtAppPool;
private System.Windows.Forms.Label label7;
+ private System.Windows.Forms.CheckBox chkRefNetstandard;
}
}
Modified: trunk/Tools/MgInstantSetup/InstantSetup/IISConfigCtrl.cs
===================================================================
--- trunk/Tools/MgInstantSetup/InstantSetup/IISConfigCtrl.cs 2022-08-10 15:57:43 UTC (rev 9955)
+++ trunk/Tools/MgInstantSetup/InstantSetup/IISConfigCtrl.cs 2022-08-10 15:59:36 UTC (rev 9956)
@@ -47,6 +47,9 @@
rdDotNet.Checked = _confImpl.EnableDotNet;
rdPhp.Checked = _confImpl.EnablePhp;
+
+ chkRefNetstandard.Enabled = rdDotNet.Checked;
+ _confImpl.AddNetstandardReference = chkRefNetstandard.Checked;
}
public AbstractSetupConfigurationProcess Config
@@ -64,6 +67,8 @@
{
_confImpl.EnableDotNet = rdDotNet.Checked;
_confImpl.EnablePhp = rdPhp.Checked;
+ chkRefNetstandard.Enabled = rdDotNet.Checked;
+ _confImpl.AddNetstandardReference = chkRefNetstandard.Checked;
}
private void rdPhp_CheckedChanged(object sender, EventArgs e)
@@ -106,5 +111,10 @@
{
_confImpl.ApplicationPool = txtAppPool.Text;
}
+
+ private void chkRefNetstandard_CheckedChanged(object sender, EventArgs e)
+ {
+ _confImpl.AddNetstandardReference = chkRefNetstandard.Checked;
+ }
}
}
Modified: trunk/Tools/MgInstantSetup/InstantSetup.Core/AppCmd.cs
===================================================================
--- trunk/Tools/MgInstantSetup/InstantSetup.Core/AppCmd.cs 2022-08-10 15:57:43 UTC (rev 9955)
+++ trunk/Tools/MgInstantSetup/InstantSetup.Core/AppCmd.cs 2022-08-10 15:59:36 UTC (rev 9956)
@@ -3,6 +3,7 @@
using System.Text;
using System.IO;
using System.Diagnostics;
+using System.Xml;
namespace InstantSetup.Core
{
@@ -199,9 +200,9 @@
return Process.Start(psi);
}
- internal void SetupCore(FormatLineWriter writer, bool b64BitMapGuide)
+ internal void SetupCore(FormatLineWriter writer, bool b64BitMapGuide, bool referenceNetstandard)
{
- writer($"Running a series of appcmd calls to set up IIS (64-bit: {b64BitMapGuide})");
+ writer($"Running a series of appcmd calls to set up IIS (64-bit: {b64BitMapGuide}, ref netstandard: {referenceNetstandard})");
Process p = null;
p = StartAppCmdProcess(writer, string.Format(CREATE_FASTCGI, _phpDir));
@@ -277,6 +278,64 @@
p = StartAppCmdProcess(writer, string.Format(SET_MAPVIEWERNET_REQ_VALIDATION_MODE, _webSite, _virtualDir));
Trace.TraceInformation(p.StandardOutput.ReadToEnd()); p.WaitForExit();
//if (p.ExitCode != 0) Debugger.Break();
+
+ //HACK: I'm pretty sure there's a way to do this through appcmd, but I can't figure it out
+ //so we'll add the necessary reference through XML document manipulation
+ if (referenceNetstandard)
+ {
+ var webConfigPath = Path.Combine(this._webExtensionsRootDir, "www", "mapviewernet", "web.config");
+ if (File.Exists(webConfigPath))
+ {
+ var webConfig = new XmlDocument();
+ webConfig.Load(webConfigPath);
+
+ bool bChanged = false;
+
+ // We should have at least a configuration/system.web/compilation element already there
+ var conf = webConfig.SelectSingleNode("//configuration/system.web/compilation");
+ if (conf != null)
+ {
+ const string NETSTANDARD_REF = "netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51";
+
+ XmlNode asmNode = null;
+ if (conf["assemblies"] == null)
+ {
+ asmNode = webConfig.CreateElement("assemblies");
+ conf.AppendChild(asmNode);
+ bChanged = true;
+ }
+
+ var nsRefNode = asmNode.SelectSingleNode($"add[assembly='{NETSTANDARD_REF}']");
+ if (nsRefNode == null)
+ {
+ nsRefNode = webConfig.CreateElement("add");
+
+ var asmAttr = webConfig.CreateAttribute("assembly");
+ asmAttr.Value = NETSTANDARD_REF;
+
+ nsRefNode.Attributes.Append(asmAttr);
+
+ asmNode.AppendChild(nsRefNode);
+ bChanged = true;
+ writer($"Added netstandard reference to web.config");
+ }
+
+ if (bChanged)
+ {
+ webConfig.Save(webConfigPath);
+ writer($"web.config updated");
+ }
+ }
+ else
+ {
+ writer($"ERROR: Could not find the expected configuration/system.web/compilation element in this web.config file!");
+ }
+ }
+ else
+ {
+ writer($"WARNING: Expected to find ({webConfigPath}), but it could not be found!");
+ }
+ }
}
internal void SetDefaultDotNetViewer(FormatLineWriter writer)
Modified: trunk/Tools/MgInstantSetup/InstantSetup.Core/IISSetupConfigurationProcess.cs
===================================================================
--- trunk/Tools/MgInstantSetup/InstantSetup.Core/IISSetupConfigurationProcess.cs 2022-08-10 15:57:43 UTC (rev 9955)
+++ trunk/Tools/MgInstantSetup/InstantSetup.Core/IISSetupConfigurationProcess.cs 2022-08-10 15:59:36 UTC (rev 9956)
@@ -65,6 +65,8 @@
public bool Enable32BitAppsOnWin64 { get; set; }
+ public bool AddNetstandardReference { get; set; }
+
protected override void DoBackupConfigFiles(FormatLineWriter writer)
{
@@ -83,7 +85,7 @@
protected override void ConfigureWebServer(FormatLineWriter writer)
{
var cmd = new AppCmd(this.AppCmdPath, this.WebSiteName, this.VirtualDirectoryName, this.ApplicationPool, this.WebTierRootDir, this.WebTierPhpDir);
- cmd.SetupCore(writer, this.Is64BitMapGuide);
+ cmd.SetupCore(writer, this.Is64BitMapGuide, this.AddNetstandardReference);
if (this.EnableDotNet)
cmd.SetDefaultDotNetViewer(writer);
else if (this.EnablePhp)
More information about the mapguide-commits
mailing list