예제 #1
0
        /// <summary>
        /// See <see cref="IWizard"/>.
        /// </summary>
        public void RunFinished()
        {
            VSLangProj80.VSProject2 vsProject = this.ActiveProject.Object as VSLangProj80.VSProject2;

            foreach (string path in this.forward.ProxyAssemblies)
            {
                AddAssemblyReference(vsProject, path);
            }

            this.forward.RunFinished();
        }
예제 #2
0
        /// <summary>
        /// Adds an assembly reference to a visual studio project.
        /// </summary>
        /// <param name="vsProject">The project to add the reference to.</param>
        /// <param name="path">The path to the assembly for which the reference is to be added.</param>
        private static void AddAssemblyReference(VSLangProj80.VSProject2 vsProject, string path)
        {
            bool   isSelfReference   = false;
            string referenceFileName = Path.GetFileName(path);

            // Decide if this is a self-reference
            foreach (EnvDTE.Configuration c in vsProject.Project.ConfigurationManager)
            {
                foreach (EnvDTE.OutputGroup og in c.OutputGroups)
                {
                    if (og.CanonicalName == "Built")
                    {
                        foreach (string str in (Array)og.FileNames)
                        {
                            if (str == referenceFileName)
                            {
                                isSelfReference = true;
                                break;
                            }
                        }
                    }

                    if (isSelfReference)
                    {
                        break;
                    }
                }

                if (isSelfReference)
                {
                    break;
                }
            }

            // Add reference, unless it is a self-reference
            if (!isSelfReference)
            {
                string referenceName           = Path.GetFileNameWithoutExtension(path);
                VSLangProj.Reference reference = vsProject.References.Item(referenceName);
                if (reference == null)
                {
                    Trace.WriteLine(string.Format(CultureInfo.InvariantCulture, "Adding reference to {0}", path));
                    reference = vsProject.References.Add(path);
                }

                reference.CopyLocal = true;
            }
            else
            {
                Trace.WriteLine(string.Format(CultureInfo.InvariantCulture, "Reference to {0} was determined to be a self reference and has not been added as a reference to the test project", path));
            }
        }
예제 #3
0
        public void Initialize(VSLangProj80.VSProject2 project)
        {
            solution        = project.Project.DTE.Solution;
            projectPath     = Path.GetDirectoryName(project.Project.FileName);
            referenceFolder = Path.Combine(projectPath, ".references");
            pomFile         = Path.Combine(projectPath, "pom.xml");

            initialized = true;
            if (!pomExist())
            {
                throw new Exception("Project has no valid pom file.");
            }
            CreateReferenceFolder();
        }