private void SetupPostBuildEvent(VSProject project, Configs.UnityProject.PluginProject config)
        {
            var dllAssetDirectory = config.DllAssetDirectory ?? DefaultDllAssetDirectory;

            if (!dllAssetDirectory.StartsWith("Assets"))
            {
                throw new ArgumentException("Unity asset path expected.", nameof(config.DllAssetDirectory));
            }

            var assetDir = Path.Combine(ProjectDirectory.FullName, dllAssetDirectory);

            assetDir = assetDir.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);

            var copyCmd = $@"xcopy ""$(TargetDir)$(TargetName).*"" ""{assetDir}"" /i /y";

            //if (!config.CreateDllAssetDirectoryIfNecessary)
            //    copyCmd = $@"if exist ""{assetDir}"" ({copyCmd})";

            // The approach below doesn't work since it add the property to existing PropertyGroup such as the
            // PropertyGroup that contains ProjectGuid and AssemblyName, this is usually the first PropertyGroup in
            // the .csproj file, and MSBuild evaluate $(TargetDir) and $(TargetName) as empty string. To ensure the
            // macros available, we need to add the PostBuildEvent property after
            // <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />.
            //project.MSBuildProject.SetProperty("PostBuildEvent", copyCmd);

            SetBuildEvent(project, "PostBuildEvent", copyCmd);
        }
        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));
        }