public SLNToolsProject SetupCSharpProject(VSProject project, Configs.UnityProject.PluginProject config)
        {
            if (SolutionFile == null)
            {
                throw new InvalidOperationException("Solution file not found.");
            }
            if (project == null)
            {
                throw new ArgumentNullException(nameof(project));
            }
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            // Clone a new project for modification for solution.
            var newPath = Path.Combine(ProjectDirectory.FullName, Path.GetFileName(project.FilePath));

            project = VSProject.Clone(project, newPath, true);

            // Select configuration groups of the project for solution.
            var targetConfigurations = SelectConfigurationsForSolution(project, config.Configurations);

            SelectConfigurationPropertyGroups(project, targetConfigurations,
                                              out var targetPropertyGroups, out var redundantPropertyGroups);
            SelectConfigurationItemGroups(project, targetConfigurations, out _, out var redundantItemGroups);

            // Remove redundant configuration groups.
            project.RemovePropertyGroups(redundantPropertyGroups);
            project.RemoveItemGroups(redundantItemGroups);

            // Setup configuration groups.
            SetupOutputPath(project, targetPropertyGroups);

            // Setup build events.
            SetupPostBuildEvent(project, config);

            project.Save();

            RemoveCSharpProject(newPath);
            return(AddProjectToSolutionFile(project, targetPropertyGroups));
        }
        public static void SetupUnityPluginProject(VSProject project, UnityPluginParameter parameter)
        {
            Ensure.Argument.NotNull(project, nameof(project));
            Ensure.Argument.NotNull(parameter, nameof(parameter));

            var versions = parameter.Versions;

            if (versions == null)
            {
                return;
            }

            project.RemovePropertyGroups(project.ParseConditionalConfigurationPropertyGroups((string)null));
            project.RemoveItemGroups(project.ParseConditionalConfigurationItemGroups((string)null));

            var propertyGroupAnchor = project.DefaultPropertyGroup;
            var itemGroupAnchor     = project.DefaultReferenceGroup;

            foreach (var kvp in versions)
            {
                var ver  = kvp.Key;
                var info = kvp.Value;

                foreach (var type in EnumTraits <ProjectConfigurationType> .Values)
                {
                    SetupConfigurationGroupForUnity(
                        propertyGroupAnchor = project.CreatePropertyGroupAfter(propertyGroupAnchor),
                        type, parameter.ForEditor, ver);

                    var references = info.AssemblyReferences;
                    if (!CollectionUtil.IsNullOrEmpty(references))
                    {
                        SetupReferenceGroupForUnity(
                            itemGroupAnchor = project.CreateItemGroupAfter(itemGroupAnchor),
                            type, parameter.ForEditor, ver, references);
                    }
                }
            }
        }