Esempio n. 1
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        public Host()
        {
            GitPaths = Utils.FindExePath("git.exe");

            NuGetPaths = Utils.FindExePath("nuget.exe");

            Results = new List <LogEntry>();

            Directory.CreateDirectory(PluginPath);

#if MEF
            AggregateCatalog catalog = new AggregateCatalog();
            catalog.Changed += Catalog_Changed;

            catalog.Catalogs.Add(new AssemblyCatalog(GetType().Assembly));
            catalog.Catalogs.Add(new DirectoryCatalog(@".\Plugins"));

            container = new CompositionContainer(catalog);

            try
            {
                container.ComposeParts(this);
            }
            catch (CompositionException compositionException)
            {
                Console.WriteLine(compositionException.ToString());
            }
#else
            container.InjectPluginsFromFolder(PluginPath);

            container.InjectAssembly(typeof(Log).Assembly);

            container.CompleteConfiguration();
#endif

            //! Detemine path of MsBuild.exe
            // See https://developercommunity.visualstudio.com/content/problem/2813/cant-find-registry-entries-for-visual-studio-2017.html
            //
            RegistryKey hklm = Registry.LocalMachine;
            RegistryKey vs7  = hklm.OpenSubKey(@"SOFTWARE\WOW6432Node\Microsoft\VisualStudio\SxS\VS7", false);

            if (vs7 == null)
            {
                // ERROR
            }

            this.VS2017Path = vs7.GetValue("15.0").ToString();

            if (!Directory.Exists(MSBuildPath))
            {
                // ERROR
            }

            this.MSBuildPath = Path.Combine(VS2017Path, @"MSBuild\15.0\Bin\MSBuild.exe");

            if (!File.Exists(MSBuildPath))
            {
                // ERROR
            }
        }