Beispiel #1
0
        /// <summary>
        /// Adds the non core plugin.
        /// </summary>
        /// <param name="projectService">The project service.</param>
        /// <param name="plugin">The plugin.</param>
        /// <param name="source">The source.</param>
        /// <param name="destination">The destination.</param>
        /// <param name="extensionSource">The extension source.</param>
        /// <param name="extensionDestination">The extension destination.</param>
        internal void AddNonCorePlugin(
            IProjectService projectService,
            Plugin plugin,
            string source,
            string destination,
            string extensionSource,
            string extensionDestination)
        {
            TraceService.WriteLine("PluginsService::AddNonCorePlugin " + plugin.FriendlyName);

            //// only do if destination file doesn't exist
            if (this.fileSystem.File.Exists(destination) == false)
            {
                projectService.AddReference(
                    "Lib",
                    destination,
                    source,
                    this.settingsService.IncludeLibFolderInProjects);
            }

            //// only do if extensionDestination file doesn't exist
            if (this.fileSystem.File.Exists(extensionDestination) == false)
            {
                projectService.AddReference(
                    "Lib",
                    extensionDestination,
                    extensionSource,
                    this.settingsService.IncludeLibFolderInProjects);

                this.BuildSourceFile(projectService, extensionSource, extensionDestination, plugin.FriendlyName);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Adds the plugin.
        /// </summary>)
        /// <param name="projectService">The project service.</param>
        /// <param name="plugin">The plugin.</param>
        /// <param name="folderName">Name of the folder.</param>
        /// <param name="extensionName">Name of the extension.</param>
        internal void AddPlugin(
            IProjectService projectService,
            Plugin plugin,
            string folderName,
            string extensionName)
        {
            TraceService.WriteLine("PluginsService::AddPlugin " + plugin.FriendlyName);

            string projectPath = projectService.GetProjectPath();
            string source      = plugin.Source;
            string destination = string.Format(@"{0}\Lib\{1}", projectPath, plugin.FileName);

            //// at this moment we only want ot do the core as this plugin might not be
            //// supported in the ui project.
            if (extensionName == Settings.Core)
            {
                projectService.AddReference(
                    "Lib",
                    destination,
                    source,
                    this.settingsService.IncludeLibFolderInProjects);
            }
            else if (extensionName == Settings.CoreTests)
            {
                projectService.AddReference(
                    "Lib",
                    destination,
                    source,
                    this.settingsService.IncludeLibFolderInProjects);
            }
            else
            {
                //// now if we are not the core project we need to add the platform specific assemblies
                //// and the bootstrap item templates!

                string extensionSource = this.GetExtensionSource(folderName, extensionName, source);

                string extensionDestination = this.GetExtensionDestination(folderName, extensionName, destination);

                if (this.fileSystem.File.Exists(extensionSource))
                {
                    //// if the plugin is supported add in the core library.

                    this.AddNonCorePlugin(
                        projectService,
                        plugin,
                        source,
                        destination,
                        extensionSource,
                        extensionDestination);
                }
            }
        }
        /// <summary>
        /// Processes the config.
        /// </summary>
        /// <param name="visualStudioService">The visual studio service.</param>
        /// <param name="projectService">The project service.</param>
        /// <param name="codeConfig">The code config.</param>
        internal void ProcessConfig(
            IVisualStudioService visualStudioService,
            IProjectService projectService, 
            CodeConfig codeConfig)
        {
            TraceService.WriteLine("ServicesService::ProcessConfig");

            if (codeConfig != null)
            {
                //// do we have any dependent plugins?
                codeConfig.DependentPlugins.ForEach(x => this.AddDependantPlugin(visualStudioService, x));

                string sourceDirectory = this.settingsService.MvvmCrossAssembliesPath;

                //// don't need to add reference if we are going to use nuget.
                if (this.settingsService.UseNugetForServices == false)
                {
                    foreach (string reference in codeConfig.References)
                    {
                        projectService.AddReference(
                            "Lib",
                            projectService.GetProjectPath() + @"\Lib\" + reference,
                            sourceDirectory + @"\" + reference,
                            this.settingsService.IncludeLibFolderInProjects,
                            this.settingsService.CopyAssembliesToLibFolder);
                    }
                }

                //// if we want to add via nuget then generate the command.
                if (this.settingsService.UseNugetForServices ||
                    codeConfig.NugetInstallationMandatory == "Y")
                {
                    ////this.nugetService.UpdateViaNuget(projectService, codeConfig);
                }

                //// apply any code dependencies
                IEnumerable<string> messages = this.codeConfigService.ApplyCodeDependencies(
                    visualStudioService,
                    codeConfig);

                this.Messages.AddRange(messages);
            }
        }
        /// <summary>
        /// Adds the core.
        /// </summary>
        /// <param name="projectService">The project service.</param>
        /// <param name="plugin">The plugin.</param>
        /// <param name="codeConfig">The code config.</param>
        /// <param name="addPluginFromLocalDisk">if set to <c>true</c> [add plugin from local disk].</param>
        /// <param name="destination">The destination.</param>
        /// <param name="source">The source.</param>
        /// <returns>True or false.</returns>
        internal bool AddCorePlugin(
            IProjectService projectService,
            Plugin plugin,
            CodeConfig codeConfig,
            bool addPluginFromLocalDisk,
            string destination,
            string source)
        {
            TraceService.WriteLine("PluginService::AddCorePlugin plugin=" + plugin.FriendlyName);

            //// inform the user that we cant install from nuget.
            if (this.codeConfigService.NugetRequestedAndNotSupported(codeConfig))
            {
                this.Messages.Add(
                    plugin.FriendlyName
                    + " plugin does not support being installed via Nuget and has been installed from the local machine.");
            }

            //// don't need to add reference if we are going to use nuget.
            if (addPluginFromLocalDisk)
            {
                //// only do if destination file doesn't exist
                if (this.fileSystem.File.Exists(destination) == false)
                {
                    projectService.AddReference(
                        "Lib",
                        destination,
                        source,
                        this.settingsService.IncludeLibFolderInProjects,
                        this.settingsService.CopyAssembliesToLibFolder);
                }
            }

            return true;
        }
        /// <summary>
        /// Adds the non core plugin.
        /// </summary>
        /// <param name="projectService">The project service.</param>
        /// <param name="plugin">The plugin.</param>
        /// <param name="source">The source.</param>
        /// <param name="destination">The destination.</param>
        /// <param name="extensionSource">The extension source.</param>
        /// <param name="extensionDestination">The extension destination.</param>
        /// <param name="addPluginFromLocalDisk">if set to <c>true</c> [add plugin from local disk].</param>
        /// <returns>
        /// True or false.
        /// </returns>
        public bool AddUIPlugin(
            IProjectService projectService,
            Plugin plugin,
            string source,
            string destination,
            string extensionSource,
            string extensionDestination,
            bool addPluginFromLocalDisk)
        {
            TraceService.WriteLine("PluginService::AddUIPlugin plugin=" + plugin.FriendlyName);

            bool added = false;

            string[] projectNameParts = projectService.Name.Split('.');

            //// we need to look for the ui specific config file,
            Plugin uiPlugin = new Plugin
                              {
                                  FriendlyName = plugin.FriendlyName + "." + projectNameParts[1]
                              };

            CodeConfig codeConfig = this.codeConfigFactory.GetPluginConfig(uiPlugin);

            this.codeConfigService.ProcessCodeConfig(
                projectService,
                codeConfig,
                extensionSource,
                extensionDestination);

            //// only do if destination file doesn't exist
            if (this.fileSystem.File.Exists(destination) == false)
            {
                if (addPluginFromLocalDisk)
                {
                    projectService.AddReference(
                        "Lib",
                        destination,
                        source,
                        this.settingsService.IncludeLibFolderInProjects,
                        this.settingsService.CopyAssembliesToLibFolder);
                }
            }

            //// only do if extensionDestination file doesn't exist
            if (this.fileSystem.File.Exists(extensionDestination) == false)
            {
                if (addPluginFromLocalDisk)
                {
                    projectService.AddReference(
                        "Lib",
                        extensionDestination,
                        extensionSource,
                        this.settingsService.IncludeLibFolderInProjects,
                        this.settingsService.CopyAssembliesToLibFolder);
                }

                added = true;

                this.RequestBootstrapFile(
                    projectService,
                    plugin);
            }

            return added;
        }
        /// <summary>
        /// Processes the code config.
        /// </summary>
        /// <param name="projectService">The project service.</param>
        /// <param name="friendlyName">Name of the friendly.</param>
        /// <param name="extensionSource">The extension source.</param>
        /// <param name="extensionDestination">The extension destination.</param>
        /// <returns>The code config.</returns>
        public CodeConfig ProcessCodeConfig(
            IProjectService projectService,
            string friendlyName,
            string extensionSource,
            string extensionDestination)
        {
            TraceService.WriteLine("CodeConfigService::ProcessCodeConfig " + friendlyName);

            //// grab the code config if it exists and process it.
            CodeConfig codeConfig = this.GetUICodeConfig(projectService, friendlyName);

            if (codeConfig != null)
            {
                //// process it if we are using local disk copy.
                if (this.UseLocalDiskCopy(codeConfig))
                {
                    string sourceDirectory = this.fileSystem.Path.GetDirectoryName(extensionSource);
                    string destinationDirectory = this.fileSystem.Path.GetDirectoryName(extensionDestination);

                    if (codeConfig.References != null)
                    {
                        codeConfig.References.ForEach(
                            x => projectService.AddReference(
                                "Lib",
                                destinationDirectory + @"\" + x,
                                sourceDirectory + @"\" + x,
                                this.settingsService.IncludeLibFolderInProjects,
                                this.settingsService.CopyAssembliesToLibFolder));
                    }
                }
            }

            return codeConfig;
        }
        /// <summary>
        /// Processes the config.
        /// </summary>
        /// <param name="visualStudioService">The visual studio service.</param>
        /// <param name="projectService">The project service.</param>
        /// <param name="configFile">The config file.</param>
        internal void ProcessConfig(
            IVisualStudioService visualStudioService,
            IProjectService projectService, 
            string configFile)
        {
            TraceService.WriteLine("ServicesService::ProcessConfig");

            CodeConfig codeConfig = this.codeConfigService.GetCodeConfigFromPath(configFile);

            if (codeConfig != null)
            {
                //// do we have any dependent plugins?
                if (codeConfig.DependentPlugins != null)
                {
                    foreach (string dependentPlugin in codeConfig.DependentPlugins)
                    {
                        List<Plugin> plugins = new List<Plugin>();

                        string source = this.settingsService.InstalledDirectory + @"\Plugins\" + dependentPlugin;

                        //// append dll if its missing.
                        if (source.ToLower().EndsWith(".dll") == false)
                        {
                            source += ".dll";
                        }

                        FileInfo fileInfo = new FileInfo(source);

                        Plugin plugin = this.pluginTranslator.Translate(fileInfo);

                        plugins.Add(plugin);

                        this.pluginsService.AddPlugins(
                            visualStudioService,
                            plugins,
                            string.Empty,
                            false);
                    }
                }

                string sourceDirectory = this.settingsService.InstalledDirectory + @"\Plugins\Core";

                //// don't need to add reference if we are going to use nuget.
                if (this.settingsService.UseNugetForServices == false)
                {
                    foreach (string reference in codeConfig.References)
                    {
                        projectService.AddReference(
                            "Lib",
                            projectService.GetProjectPath() + @"\Lib\" + reference,
                            sourceDirectory + @"\" + reference,
                            this.settingsService.IncludeLibFolderInProjects,
                            this.settingsService.CopyAssembliesToLibFolder);
                    }
                }

                //// if we want to add via nuget then generate the command.
                if (this.settingsService.UseNugetForServices ||
                    codeConfig.NugetInstallationMandatory == "Y")
                {
                    ////this.nugetService.UpdateViaNuget(projectService, codeConfig);
                }

                //// apply any code dependencies
                IEnumerable<string> messages = this.codeConfigService.ApplyCodeDependencies(
                    visualStudioService,
                    codeConfig);

                this.Messages.AddRange(messages);
            }
        }
        /// <summary>
        /// Adds the non core plugin.
        /// </summary>
        /// <param name="projectService">The project service.</param>
        /// <param name="friendlyName">Name of the friendly.</param>
        /// <param name="source">The source.</param>
        /// <param name="destination">The destination.</param>
        /// <param name="extensionSource">The extension source.</param>
        /// <param name="extensionDestination">The extension destination.</param>
        /// <param name="addPluginFromLocalDisk">if set to <c>true</c> [add plugin from local disk].</param>
        /// <returns>True or false.</returns>
        public bool AddUIPlugin(
            IProjectService projectService,
            string friendlyName,
            string source,
            string destination,
            string extensionSource,
            string extensionDestination,
            bool addPluginFromLocalDisk)
        {
            TraceService.WriteLine("PluginService::AddUIPlugin " + friendlyName);

            bool added = false;

            this.codeConfigService.ProcessCodeConfig(
                projectService,
                friendlyName,
                extensionSource,
                extensionDestination);

            //// only do if destination file doesn't exist
            if (this.fileSystem.File.Exists(destination) == false)
            {
                if (addPluginFromLocalDisk)
                {
                    projectService.AddReference(
                        "Lib",
                        destination,
                        source,
                        this.settingsService.IncludeLibFolderInProjects,
                        this.settingsService.CopyAssembliesToLibFolder);
                }
            }

            //// only do if extensionDestination file doesn't exist
            if (this.fileSystem.File.Exists(extensionDestination) == false)
            {
                if (addPluginFromLocalDisk)
                {
                    projectService.AddReference(
                        "Lib",
                        extensionDestination,
                        extensionSource,
                        this.settingsService.IncludeLibFolderInProjects,
                        this.settingsService.CopyAssembliesToLibFolder);
                }

                added = true;

                this.RequestBootstrapFile(
                    projectService,
                    friendlyName);
            }

            return added;
        }
        /// <summary>
        /// Processes the code config.
        /// </summary>
        /// <param name="projectService">The project service.</param>
        /// <param name="codeConfig">The code config.</param>
        /// <param name="extensionSource">The extension source.</param>
        /// <param name="extensionDestination">The extension destination.</param>
        public void ProcessCodeConfig(
            IProjectService projectService,
            CodeConfig codeConfig,
            string extensionSource,
            string extensionDestination)
        {
            TraceService.WriteLine("CodeConfigService::ProcessCodeConfig");

            if (codeConfig != null)
            {
                //// process it if we are using local disk copy.
                if (this.UseLocalDiskCopy(codeConfig))
                {
                    string sourceDirectory = this.fileSystem.Path.GetDirectoryName(extensionSource);
                    string destinationDirectory = this.fileSystem.Path.GetDirectoryName(extensionDestination);

                    codeConfig.References.ForEach(
                        x => projectService.AddReference(
                            "Lib",
                            destinationDirectory + @"\" + x,
                            sourceDirectory + @"\" + x,
                            this.settingsService.IncludeLibFolderInProjects,
                            this.settingsService.CopyAssembliesToLibFolder));
                }
            }
        }
        /// <summary>
        /// Adds the plugin.
        /// </summary>
        /// <param name="projectService">The project service.</param>
        /// <param name="plugin">The plugin.</param>
        /// <param name="folderName">Name of the folder.</param>
        /// <param name="extensionName">Name of the extension.</param>
        /// <returns>True or false.</returns>
        internal bool AddPlugin(
            IProjectService projectService,
            Plugin plugin,
            string folderName,
            string extensionName)
        {
            TraceService.WriteLine("PluginsService::AddPlugin " + plugin.FriendlyName);

            bool added = false;

            string projectPath = projectService.GetProjectPath();
            string source = plugin.Source;
            string destination = string.Format(@"{0}\Lib\{1}", projectPath, plugin.FileName);

            //// at this moment we only want ot do the core as this plugin might not be
            //// supported in the ui project.
            if (extensionName == Settings.Core ||
                extensionName == Settings.CoreTests)
            {
                //// dont need to add reference if we are going to use nuget.
                if (this.SettingsService.UseNugetForPlugins == false)
                {
                    projectService.AddReference(
                        "Lib",
                        destination,
                        source,
                        this.SettingsService.IncludeLibFolderInProjects);
                }

                added = true;
            }
            else
            {
                //// now if we are not the core project we need to add the platform specific assemblies
                //// and the bootstrap item templates!

                string extensionSource = this.GetExtensionSource(folderName, extensionName, source);

                string extensionDestination = this.GetExtensionDestination(folderName, extensionName, destination);

                if (this.FileSystem.File.Exists(extensionSource))
                {
                    //// if the plugin is supported add in the core library.

                    added = this.AddNonCorePlugin(
                        projectService,
                        plugin.FriendlyName,
                        source,
                        destination,
                        extensionSource,
                        extensionDestination);
                }
            }

            return added;
        }
        /// <summary>
        /// Adds the non core plugin.
        /// </summary>
        /// <param name="projectService">The project service.</param>
        /// <param name="friendlyName">Name of the friendly.</param>
        /// <param name="source">The source.</param>
        /// <param name="destination">The destination.</param>
        /// <param name="extensionSource">The extension source.</param>
        /// <param name="extensionDestination">The extension destination.</param>
        /// <returns>True or false.</returns>
        internal bool AddNonCorePlugin(
            IProjectService projectService,
            string friendlyName,
            string source,
            string destination,
            string extensionSource,
            string extensionDestination)
        {
            TraceService.WriteLine("PluginsService::AddNonCorePlugin " + friendlyName);

            bool added = false;

            //// only do if destination file doesn't exist
            if (this.FileSystem.File.Exists(destination) == false)
            {
                if (this.SettingsService.UseNugetForPlugins == false)
                {
                    projectService.AddReference(
                        "Lib",
                        destination,
                        source,
                        this.SettingsService.IncludeLibFolderInProjects);
                }
            }

            //// only do if extensionDestination file doesn't exist
            if (this.FileSystem.File.Exists(extensionDestination) == false)
            {
                if (this.SettingsService.UseNugetForPlugins == false)
                {
                    projectService.AddReference(
                        "Lib",
                        extensionDestination,
                        extensionSource,
                        this.SettingsService.IncludeLibFolderInProjects);
                }

                added = true;
                this.BuildSourceFile(projectService, extensionSource, extensionDestination, friendlyName);
            }

            return added;
        }