diff --git a/src/AddIns/Misc/CodeAnalysis/Src/FxCopWrapper.cs b/src/AddIns/Misc/CodeAnalysis/Src/FxCopWrapper.cs index 44e27a73dc..b2b63447f1 100644 --- a/src/AddIns/Misc/CodeAnalysis/Src/FxCopWrapper.cs +++ b/src/AddIns/Misc/CodeAnalysis/Src/FxCopWrapper.cs @@ -104,7 +104,11 @@ namespace ICSharpCode.CodeAnalysis if (IsFxCopPath(fxCopPath)) { return fxCopPath; } - + + fxCopPath = FromRegistry(Registry.ClassesRoot.OpenSubKey(@"FxCop.Project.9.0\Shell\Open\Command")); + if (IsFxCopPath(fxCopPath)) { + return fxCopPath; + } fxCopPath = FromRegistry(Registry.CurrentUser.OpenSubKey(@"Software\Classes\FxCopProject\Shell\Open\Command")); if (IsFxCopPath(fxCopPath)) { return fxCopPath; diff --git a/src/Libraries/ICSharpCode.Build.Tasks/Project/FxCop.cs b/src/Libraries/ICSharpCode.Build.Tasks/Project/FxCop.cs index acb7ed64a5..7257f8ad23 100644 --- a/src/Libraries/ICSharpCode.Build.Tasks/Project/FxCop.cs +++ b/src/Libraries/ICSharpCode.Build.Tasks/Project/FxCop.cs @@ -169,7 +169,7 @@ namespace ICSharpCode.Build.Tasks fxCopPath = key.GetValue("FxCopDir") as string; } } - if (!string.IsNullOrEmpty(fxCopPath) && File.Exists(Path.Combine(fxCopPath, ToolName))) { + if (IsFxCopPath(fxCopPath)) { return fxCopPath; } using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\Setup\EDev")) { @@ -177,21 +177,30 @@ namespace ICSharpCode.Build.Tasks fxCopPath = key.GetValue("FxCopDir") as string; } } - if (!string.IsNullOrEmpty(fxCopPath) && File.Exists(Path.Combine(fxCopPath, ToolName))) { + if (IsFxCopPath(fxCopPath)) { + return fxCopPath; + } + + fxCopPath = FromRegistry(Registry.ClassesRoot.OpenSubKey(@"FxCop.Project.9.0\Shell\Open\Command")); + if (IsFxCopPath(fxCopPath)) { return fxCopPath; } - fxCopPath = FromRegistry(Registry.CurrentUser.OpenSubKey(@"Software\Classes\FxCopProject\Shell\Open\Command")); - if (!string.IsNullOrEmpty(fxCopPath) && File.Exists(Path.Combine(fxCopPath, ToolName))) { + if (IsFxCopPath(fxCopPath)) { return fxCopPath; } fxCopPath = FromRegistry(Registry.ClassesRoot.OpenSubKey(@"FxCopProject\Shell\Open\Command")); - if (!string.IsNullOrEmpty(fxCopPath) && File.Exists(Path.Combine(fxCopPath, ToolName))) { + if (IsFxCopPath(fxCopPath)) { return fxCopPath; } return null; } + bool IsFxCopPath(string fxCopPath) + { + return !string.IsNullOrEmpty(fxCopPath) && File.Exists(Path.Combine(fxCopPath, ToolName)); + } + string FromRegistry(RegistryKey key) { // Code duplication: FxCopWrapper.cs in CodeAnalysis addin