示例#1
0
        /// <summary>
        ///     Adds the assembly reference.
        /// </summary>
        /// <param name="assemblyPath">The assembly path.</param>
        public void AddAssemblyReference(string assemblyPath)
        {
            Guard.ArgumentNotNullOrEmptyString(assemblyPath, "assemblyPath");

            if (VsProject != null)
            {
                if (VsProject.Object is VSProject project)
                {
                    References references = project.References;
                    references?.Add(assemblyPath);
                }
                else
                {
                    AssemblyReferences references = (VsProject.Object as VSWebSite)?.References;

                    if (references != null)
                    {
                        if (System.IO.Path.IsPathRooted(assemblyPath))
                        {
                            references.AddFromFile(assemblyPath);
                        }
                        else
                        {
                            references.AddFromGAC(assemblyPath);
                        }
                    }
                }
            }
        }