3F / vsSolutionBuildEvent

🎛 Event-Catcher with variety of advanced Actions to service projects, libraries, build processes, runtime environment of the Visual Studio, MSBuild Tools, and …
Other
79 stars 22 forks source link

#31: [v0.12.5] bug with configuration for Isolated Environments (CI.MSBuild, Devenv, etc.) #31

Closed 3F closed 8 years ago

3F commented 10 years ago

Originally reported by: Denis Kuzmin (Bitbucket: 3F, GitHub: 3F)


Found bug in v0.12.5

Problem with configuration for Isolated and other external Environments (CI.MSBuild, Devenv, etc.)

Symptoms:

For Visual Studio users should be ok

My patch for resolving problem:


030de0118b71303dc4f5b27d52907c80a82b3f60
 vsSolutionBuildEvent/API/EventLevel.cs              | 10 ++++++++--
 vsSolutionBuildEvent/UI/WForms/EventsFrm.cs         |  2 +-
 vsSolutionBuildEvent/vsSolutionBuildEventPackage.cs |  1 -
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/vsSolutionBuildEvent/API/EventLevel.cs b/vsSolutionBuildEvent/API/EventLevel.cs
index c1ef243..afea74f 100644
--- a/vsSolutionBuildEvent/API/EventLevel.cs
+++ b/vsSolutionBuildEvent/API/EventLevel.cs
@@ -24,6 +24,7 @@ using net.r_eg.vsSBE.Bridge;
 using net.r_eg.vsSBE.Bridge.CoreCommand;
 using net.r_eg.vsSBE.Clients;
 using net.r_eg.vsSBE.Configuration;
+using net.r_eg.vsSBE.Exceptions;
 using net.r_eg.vsSBE.SBEScripts;
 using net.r_eg.vsSBE.Scripts;
 using AppSettings = net.r_eg.vsSBE.Settings;
@@ -384,8 +385,12 @@ namespace net.r_eg.vsSBE.API
         /// <returns>If the method succeeds, it returns Codes.Success. If it fails, it returns an error code.</returns>
         public int solutionOpened(object pUnkReserved, int fNewSolution)
         {
-            var config      = (ConfigManager.Config)?? new Config();
-            var userConfig  = (ConfigManager.UserConfig)?? new UserConfig();
+            var config      = ConfigManager.Config;
+            var userConfig  = ConfigManager.UserConfig;
+
+            if(config == null || userConfig == null) {
+                throw new NotFoundException("Config is not ready for loading. User: {0} / Main: {1}", (userConfig != null), (config != null));
+            }

             bool isNew = !config.load(Environment.SolutionPath, Environment.SolutionFileName);
             userConfig.load(config.Link);
@@ -468,6 +473,7 @@ namespace net.r_eg.vsSBE.API
         /// <param name="cfg"></param>
         protected void configure(ISettings cfg)
         {
+            ConfigManager.addAndUse(new Config(), new UserConfig(), ContextType.Static); //TODO: Solution & Common context
             (new Logger.Initializer()).configure();

             // TODO: event with common settings for IEntryPointCore
diff --git a/vsSolutionBuildEvent/UI/WForms/EventsFrm.cs b/vsSolutionBuildEvent/UI/WForms/EventsFrm.cs
index 88a34cf..bfda215 100644
--- a/vsSolutionBuildEvent/UI/WForms/EventsFrm.cs
+++ b/vsSolutionBuildEvent/UI/WForms/EventsFrm.cs
@@ -1040,7 +1040,7 @@ namespace net.r_eg.vsSBE.UI.WForms
         {
             if(!App.IsCfgExists)
             {
-                Log.Fatal("Configuration data is corrupt. User: {0} / Main: {1}", (App.UserConfig == null), (App.Config == null));
+                Log.Fatal("Configuration data is corrupt. User: {0} / Main: {1}", (App.UserConfig != null), (App.Config != null));
                 MessageBox.Show("We can't continue. See details in log.", "Configuration data is corrupt");
                 FormClosing -= EventsFrm_FormClosing;
                 Close();
diff --git a/vsSolutionBuildEvent/vsSolutionBuildEventPackage.cs b/vsSolutionBuildEvent/vsSolutionBuildEventPackage.cs
index 32f3af8..cc857fa 100644
--- a/vsSolutionBuildEvent/vsSolutionBuildEventPackage.cs
+++ b/vsSolutionBuildEvent/vsSolutionBuildEventPackage.cs
@@ -243,7 +243,6 @@ namespace net.r_eg.vsSBE
         {
             var usrCfg = new UserConfig();
             usrCfg.load(usrCfg.getLink(Settings._.CommonPath, Config.Entity.NAME, null));
-            Settings.CfgManager.addAndUse(new Config(), usrCfg, ContextType.Static);

             Event = new API.EventLevel();
             ((IEntryPointCore)Event).load(Dte2, usrCfg.Data.Global.DebugMode);

it's applied in 030de011

Use it before new public release.

Comment if needed


3F commented 8 years ago

has been resolved in v0.12.6 - http://vssbe.r-eg.net/Changelist/

changelog entry:

* FIXED: Bug with configuration for Isolated and other external Environments ...