Пример #1
0
        public static bool AddKeelRefToProject(Project pjt)
        {
            bool      ok = false;
            VSProject p2;

            if (pjt == null)
            {
                return(true);
            }
            string s = new Uri(typeof(Keel.DB.Common).Assembly.CodeBase).LocalPath;

            p2 = ProjectToVSProject(pjt);
            if (p2 != null)
            {
                if (p2.References.Find(typeof(Keel.IDatabase).Namespace) == null)
                {
                    try
                    {
                        Reference r = p2.References.Add(s);
                        ok = true;
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            else if (pjt.Kind == "{E24C65DC-7377-472b-9ABA-BC803B73C61A}")
            {
                VsWebSite.VSWebSite vsws = pjt.Object as VsWebSite.VSWebSite;
                vsws.References.AddFromFile(s);
            }

            return(ok);
        }
Пример #2
0
        public static bool AddProjectRefToProject(Project pjt1, Project pjt2)
        {
            bool ok = false;

            if (pjt1 == null || pjt2 == null)
            {
                return(true);
            }
            VSProject p2;

            p2 = ProjectToVSProject(pjt2);
            if (p2 != null)
            {
                if (p2.References.Find(pjt2.Name) == null)
                {
                    try
                    {
                        string    s = new Uri(typeof(Keel.DB.Common).Assembly.CodeBase).LocalPath;
                        Reference r = p2.References.AddProject(pjt1);
                        ok = true;
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            else if (pjt1.Kind == "{E24C65DC-7377-472b-9ABA-BC803B73C61A}")
            {
                VsWebSite.VSWebSite vsws = pjt1.Object as VsWebSite.VSWebSite;
                vsws.References.AddFromProject(pjt2);
            }
            return(ok);
        }
Пример #3
0
        public List <Assembly> GetReferences()
        {
            Project         project = dte.Solution.Projects.Item(1);
            List <Assembly> list    = new List <Assembly>();

            if (project.Object is VSLangProj.VSProject)
            {
                VSLangProj.VSProject vsproject = (VSLangProj.VSProject)project.Object;
                foreach (VSLangProj.Reference reference in vsproject.References)
                {
                    try
                    {
                        if (reference.StrongName)
                        {
                            //System.Configuration, Version=2.0.0.0,
                            //Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A
                            list.Add(Assembly.Load(

                                         reference.Identity +
                                         ", Version=" + reference.Version +
                                         ", Culture=" + (string.IsNullOrEmpty(reference.Culture) ?
                                                         "neutral" : reference.Culture) +
                                         ", PublicKeyToken=" + reference.PublicKeyToken));
                        }
                        else
                        {
                            list.Add(Assembly.Load(reference.Path));
                        }
                    }
                    catch (System.IO.FileLoadException ex)
                    {
                    }
                }
            }
            else if (project.Object is VsWebSite.VSWebSite)
            {
                VsWebSite.VSWebSite vswebsite = (VsWebSite.VSWebSite)project.Object;
                foreach (VsWebSite.AssemblyReference reference in vswebsite.References)
                {
                    list.Add(Assembly.Load(reference.StrongName));
                }
            }
            return(list);
        }
Пример #4
0
        bool addVSWebProjectReference(Artifact.Artifact artifact, string name)
        {
            try
            {
                VsWebSite.VSWebSite website = (VsWebSite.VSWebSite)project.Object;

                Assembly a = Assembly.LoadFile(artifact.FileInfo.FullName);
                if (a.ToString().Split(",".ToCharArray())[0].ToLower().StartsWith("interop.", true, CultureInfo.InvariantCulture))
                {
                    MessageBox.Show("Cannot add COM Interop reference from a Maven Artifact, just use Add Reference if you wish to add a COM reference.", "Add Maven Artifact", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return(false);
                }

                bool referenced = false;
                try
                {
                    referenced = (website.References.Item(name) != null);
                }
                catch
                {
                    referenced = false;
                }

                if (referenced)
                {
                    MessageBox.Show(this, "A version of artifact is already added to the project, please remove it first before adding this version.", this.Text);
                    return(false);
                }

                // not need to written in pom anymore
                //addArtifactToPom(artifact);

                website.References.AddFromFile(artifact.FileInfo.FullName);
                return(true);
            }
            catch
            {
                MessageBox.Show("Cannot add COM reference from a Maven Artifact.", "Add Maven Artifact", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }
        }
Пример #5
0
        private void DoRefreshGeneratedFiles()
        {
            UpdateResyncProgressBar();

            string[] syncFolders = m_addInSettings.SyncFolderList.Split(new char[] { ';' });

            foreach (Project proj in m_applicationObject.Solution.Projects)
            {
                if (proj.Kind == VSSolutionUtils.ProjectKindSolutionFolder || proj.Object == null)
                {
                    // The project is either unavailable or a solution folder
                }
                else if (proj.Kind == VSSolutionUtils.ProjectKindWeb)
                {
                    VsWebSite.VSWebSite webSite = proj.Object as VsWebSite.VSWebSite;
                    webSite.Refresh();
                }
                else
                {
                    UpdateResyncProgressBar(proj.Name);
                    // Search for the existing
                    foreach (string folder in syncFolders)
                    {
                        string folderCleaned = folder.Replace('/', '\\').Trim('\\');
                        if (folderCleaned.Length > 0)
                        {
                            string folderPath = proj.Properties.Item("FullPath").Value.ToString().Trim('\\') + "\\" + folderCleaned;

                            ProjectItem folderItem = null;
                            foreach (ProjectItem item in proj.ProjectItems)
                            {
                                if (item.Kind == EnvDTE.Constants.vsProjectItemKindPhysicalFolder &&
                                    folderPath == item.Properties.Item("FullPath").Value.ToString().Trim('\\'))
                                {
                                    folderItem = item;
                                }
                            }

                            if (System.IO.Directory.Exists(folderPath))
                            {
                                bool skip = false;

                                // Get the list of files in the filesystem
                                ArrayList filesystemFileList = GetFileListFromFilesystem(folderPath);

                                if (folderItem != null)
                                {
                                    // Get the list of files in the solution tree
                                    ArrayList solutionTreeFileList = GetFileListFromProjectTree(folderItem);
                                    // Generate a hash for the filesystem list
                                    int filesHash = GetArrayListHashCode(filesystemFileList);
                                    // Generate a hash for the solution tree list
                                    int solutionHash = GetArrayListHashCode(solutionTreeFileList);

                                    // If the hash codes are the same, we don't need to do a resync
                                    if (filesHash == solutionHash)
                                    {
                                        UpdateResyncProgressBar("Files have not changed since last resync: " + proj.Name + "/" + folderItem.Name, 1, 1);
                                        skip = true;
                                    }
                                }
                                if (!skip)
                                {
                                    if (folderItem != null)
                                    {
                                        folderItem.Remove();
                                    }
                                    UpdateResyncProgressBar(folderCleaned, 0, filesystemFileList.Count);
                                    //folderItem = proj.ProjectItems.
                                    ((VSLangProj.VSProject)proj.Object).Refresh();

                                    folderItem = proj.ProjectItems.AddFromDirectory(folderPath);
                                    CollapseProject(proj.Name);
                                    RemoveIgnoredItems(folderItem.ProjectItems, filesystemFileList.Count);
                                }
                            }
                            else
                            {
                                if (folderItem != null)
                                {
                                    folderItem.Remove();
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #6
0
        /// <summary>
        /// Adds a reference to the selected project.
        /// </summary>
        /// <remarks>
        /// REF=http://www.codeproject.com/KB/macros/EnvDTE.aspx
        /// </remarks>
        /// <param name="project"></param>
        /// <param name="referenceStrIdentity"></param>
        /// <param name="browseUrl"></param>
        public static void AddProjectReference(Project project, string referenceStrIdentity, string browseUrl)
        {
            //browseUrl is either the File Path or the Strong Name
            //(System.Configuration, Version=2.0.0.0, Culture=neutral,
            //                       PublicKeyToken=B03F5F7F11D50A3A)
            string path = "";

            if (!browseUrl.StartsWith(referenceStrIdentity))
            {
                //it is a path
                path = browseUrl;
            }

            if (project.Object is VSLangProj.VSProject)
            {
                VSLangProj.VSProject vsproject = (VSLangProj.VSProject)project.Object;
                VSLangProj.Reference reference = null;
                try
                {
                    reference = vsproject.References.Find(referenceStrIdentity);
                }
                catch (Exception)
                {
                    //it failed to find one, so it must not exist.
                    //But it decided to error for the fun of it. :)
                }
                if (reference == null)
                {
                    if (path == "")
                    {
                        vsproject.References.Add(browseUrl);
                    }
                    else
                    {
                        vsproject.References.Add(path);
                    }
                }
                else
                {
                    throw new Exception("Reference already exists.");
                }
            }
            else if (project.Object is VsWebSite.VSWebSite)
            {
                VsWebSite.VSWebSite         vswebsite = (VsWebSite.VSWebSite)project.Object;
                VsWebSite.AssemblyReference reference = null;
                try
                {
                    foreach (VsWebSite.AssemblyReference r in vswebsite.References)
                    {
                        if (r.Name == referenceStrIdentity)
                        {
                            reference = r;
                            break;
                        }
                    }
                }
                catch (Exception)
                {
                    //it failed to find one, so it must not exist.
                    //But it decided to error for the fun of it. :)
                }
                if (reference == null)
                {
                    if (path == "")
                    {
                        vswebsite.References.AddFromGAC(browseUrl);
                    }
                    else
                    {
                        vswebsite.References.AddFromFile(path);
                    }
                }
                else
                {
                    throw new Exception("Reference already exists.");
                }
            }
            else
            {
                throw new Exception("Currently, system is only set up " +
                                    "to do references for normal projects.");
            }
        }
Пример #7
0
 /// <summary>
 /// Gets a list of all project references.
 /// </summary>
 /// <remarks>
 /// REF=http://www.codeproject.com/KB/macros/EnvDTE.aspx
 /// </remarks>
 /// <returns></returns>
 public static List <KeyValuePair <string, string> > GetReferences(Project project)
 {
     if (project.Object is VSLangProj.VSProject)
     {
         VSLangProj.VSProject vsproject             = (VSLangProj.VSProject)project.Object;
         List <KeyValuePair <string, string> > list =
             new List <KeyValuePair <string, string> >();
         foreach (VSLangProj.Reference reference in vsproject.References)
         {
             if (reference.StrongName)
             {
                 //System.Configuration, Version=2.0.0.0,
                 //Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A
                 list.Add(new KeyValuePair <string, string>(reference.Identity,
                                                            reference.Identity +
                                                            ", Version=" + reference.Version +
                                                            ", Culture=" + (string.IsNullOrEmpty(reference.Culture) ? "neutral" : reference.Culture) +
                                                            ", PublicKeyToken=" + reference.PublicKeyToken));
             }
             else
             {
                 list.Add(new KeyValuePair <string, string>(
                              reference.Identity, reference.Path));
             }
         }
         return(list);
     }
     else if (project.Object is VsWebSite.VSWebSite)
     {
         VsWebSite.VSWebSite vswebsite = (VsWebSite.VSWebSite)project.Object;
         //List<string> list = new List<string>();
         List <KeyValuePair <string, string> > list =
             new List <KeyValuePair <string, string> >();
         foreach (VsWebSite.AssemblyReference reference in vswebsite.References)
         {
             string value = "";
             if (reference.FullPath != "")
             {
                 FileInfo f = new FileInfo(reference.FullPath + ".refresh");
                 if (f.Exists)
                 {
                     using (FileStream stream = f.OpenRead())
                     {
                         using (StreamReader r = new StreamReader(stream))
                         {
                             value = r.ReadToEnd().Trim();
                         }
                     }
                 }
             }
             if (value == "")
             {
                 list.Add(new KeyValuePair <string, string>(reference.Name,
                                                            reference.StrongName));
             }
             else
             {
                 list.Add(new KeyValuePair <string, string>(reference.Name, value));
             }
         }
         return(list);
     }
     else
     {
         throw new Exception("Currently, system is only set up to " +
                             "do references for normal projects.");
     }
 }
Пример #8
0
        public WebFormBaseGengerator(Project pjt1, string ctlname, List <SQLTableInfo> stltmp)
        {
            pjt = pjt1;
            stl = stltmp;
            Common.ShowInfo("正在准备控件" + ctlname);
            Solution2 slu     = (Solution2)Common.chDTE.Solution;
            string    itmname = ctlname + ".ascx";// Kit.GetProjectLaneExt(Kit.GetProjectLangType(pjt));

            if (itmname == null)
            {
                throw new Exception("错误002 不支持此项目类型");
            }

            pi = Kit.GetProjectItemByName(pjt, itmname);
            if (pi != null)
            {
                pi.Delete();
            }
            VsWebSite.VSWebSite ws = pjt.Object as VsWebSite.VSWebSite;
            try
            {
                DeleteFile(itmname);
                if (ws != null)
                {
                    pi = ws.AddFromTemplate("", "WebUserControl.vstemplate", Kit.GetProjectLangStr2(Kit.GetProjectLangType(pjt)), itmname, true, "", "");
                }
                else
                {
                    if (IsWebApplication())
                    {
                        //WAProjectExtender wpe = pjt.get_Extender("WebApplication") as WAProjectExtender;
                        string pit = slu.GetProjectItemTemplate("WebUserControl.zip", Kit.GetProjectLangStr(Kit.GetProjectLangType(pjt)) + "\\Web");
                        if (pit == null)
                        {
                            throw new Exception("错误003 未能得到对应项目模板,请确认此语言项目是否正确安装!");
                        }
                        pi = pjt.ProjectItems.AddFromTemplate(pit, itmname);
                    }
                }
                // pi = pjt.ProjectItems.AddFromTemplate(pit, itmname+".cs");
                //pi = pjt.ProjectItems.AddFromTemplate(pit, itmname);
            }
            catch (Exception)
            {
                pi = null;
            }
            if (pi == null)
            {
                pi = Kit.GetProjectItemByName(pjt, itmname);
            }
            if (pi == null)
            {
                return;
            }
            XmlSerializer xs = new XmlSerializer(typeof(AscxDom));
            XmlReader     xr = XmlReader.Create(new MemoryStream(Properties.Resources.WebUserControl));

            if (xs.CanDeserialize(xr))
            {
                ctlDom = xs.Deserialize(xr) as AscxDom;
            }
            if (IsWebApplication())
            {
                cns = new System.CodeDom.CodeNamespace(Kit.GetRootNamespace(pjt));
                cns.Comments.Add(new CodeCommentStatement("生成日期:" + DateTime.Now.ToString("yyyyMMddHHmmss")));
                cns.Comments.Add(new CodeCommentStatement("KeelKit版本:" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()));
                ccu.Namespaces.Add(cns);
                ctd           = new CodeTypeDeclaration(ctlname);
                ctd.IsPartial = true;
                ctd.IsClass   = true;
                cns.Types.Add(ctd);
            }
        }
        private void PerformAction(string action, Project project, Cloud cloud, ProjectDirectories dir,
                                   Func <IVcapClient, DirectoryInfo, VcapClientResult> function)
        {
            var worker = new BackgroundWorker();

            Messenger.Default.Register <NotificationMessageAction <string> >(this,
                                                                             message =>
            {
                if (message.Notification.Equals(Messages.SetProgressData))
                {
                    message.Execute(action);
                }
            });

            var window     = new ProgressDialog();
            var dispatcher = window.Dispatcher;
            var helper     = new WindowInteropHelper(window);

            helper.Owner = (IntPtr)(dte.MainWindow.HWnd);
            worker.WorkerSupportsCancellation = true;
            worker.DoWork += (s, args) =>
            {
                if (worker.CancellationPending)
                {
                    args.Cancel = true; return;
                }

                Messenger.Default.Send(new ProgressMessage(0, "Starting " + action));

                if (worker.CancellationPending)
                {
                    args.Cancel = true; return;
                }

                if (!Directory.Exists(dir.StagingPath))
                {
                    dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send(new ProgressMessage(10, "Creating Staging Path"))));
                    Directory.CreateDirectory(dir.StagingPath);
                }

                if (worker.CancellationPending)
                {
                    args.Cancel = true; return;
                }

                if (Directory.Exists(dir.DeployFromPath))
                {
                    dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send(new ProgressMessage(10, "Creating Precompiled Site Path"))));
                    Directory.Delete(dir.DeployFromPath, true);
                }

                if (worker.CancellationPending)
                {
                    args.Cancel = true; return;
                }

                dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send(new ProgressMessage(30, "Preparing Compiler"))));

                VsWebSite.VSWebSite site = project.Object as VsWebSite.VSWebSite;
                if (site != null)
                {
                    site.PreCompileWeb(dir.DeployFromPath, true);
                }
                else
                {
                    string frameworkPath = (site == null) ? project.GetFrameworkPath() : String.Empty;

                    if (worker.CancellationPending)
                    {
                        args.Cancel = true; return;
                    }
                    string objDir = Path.Combine(dir.ProjectDirectory, "obj");
                    if (Directory.Exists(objDir))
                    {
                        Directory.Delete(objDir, true); // NB: this can cause precompile errors
                    }

                    var process = new System.Diagnostics.Process()
                    {
                        StartInfo = new ProcessStartInfo()
                        {
                            FileName               = Path.Combine(frameworkPath, "aspnet_compiler.exe"),
                            Arguments              = String.Format("-nologo -v / -p \"{0}\" -f -u -c \"{1}\"", dir.ProjectDirectory, dir.DeployFromPath),
                            CreateNoWindow         = true,
                            ErrorDialog            = false,
                            UseShellExecute        = false,
                            RedirectStandardOutput = true
                        }
                    };

                    if (worker.CancellationPending)
                    {
                        args.Cancel = true; return;
                    }
                    dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send(new ProgressMessage(40, "Precompiling Site"))));
                    process.Start();
                    string output = process.StandardOutput.ReadToEnd();
                    process.WaitForExit();
                    if (false == String.IsNullOrEmpty(output))
                    {
                        dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send(new ProgressError("Asp Compile Error: " + output))));
                        return;
                    }
                }

                dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send(new ProgressMessage(50, "Logging in to Cloud Foundry"))));

                if (worker.CancellationPending)
                {
                    args.Cancel = true; return;
                }

                var client = new VcapClient(cloud);
                VcapClientResult result = client.Login();
                if (result.Success == false)
                {
                    dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send(new ProgressError("Failure: " + result.Message))));
                    return;
                }

                dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send(new ProgressMessage(75, "Sending to " + cloud.Url))));
                if (worker.CancellationPending)
                {
                    args.Cancel = true; return;
                }

                result = function(client, new DirectoryInfo(dir.DeployFromPath));
                if (result.Success == false)
                {
                    dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send(new ProgressError("Failure: " + result.Message))));
                    return;
                }
                dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send(new ProgressMessage(100, action + " complete."))));
            };

            worker.RunWorkerAsync();
            if (!window.ShowDialog().GetValueOrDefault())
            {
                worker.CancelAsync();
            }
        }
Пример #10
0
        public List <Assembly> GetReferences()
        {
            Project         project = CurrentProject;
            List <Assembly> list    = new List <Assembly>();

            string       fullProjectPath = project.Properties.Item("FullPath").Value.ToString();
            string       outputDir       = Path.Combine(fullProjectPath, project.ConfigurationManager.ActiveConfiguration.Properties.Item("OutputPath").Value.ToString());
            string       outputFileName  = Path.Combine(outputDir, project.Properties.Item("OutputFileName").Value.ToString());
            AssemblyName assemblyName    = new AssemblyName(project.Properties.Item("AssemblyName").Value.ToString());

            assemblyName.CodeBase = outputFileName;
            try
            {
                Assembly projectAssembly = Assembly.Load(assemblyName);
                list.Add(projectAssembly);
            }
            catch (Exception ex)
            {
                //TODO: some diag info (especially when the project is not built yet) could be very useful.
            }

            if (project.Object is VSLangProj.VSProject)
            {
                VSLangProj.VSProject vsproject = (VSLangProj.VSProject)project.Object;
                foreach (VSLangProj.Reference reference in vsproject.References)
                {
                    if (reference.Identity.StartsWith("System") || reference.Identity.StartsWith("Microsoft") || reference.Identity.StartsWith("mscorlib"))
                    {
                        continue;
                    }

                    try
                    {
                        if (reference.StrongName)
                        {
                            //System.Configuration, Version=2.0.0.0,
                            //Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A
                            list.Add(Assembly.Load(
                                         reference.Identity +
                                         ", Version=" + reference.Version +
                                         ", Culture=" + (string.IsNullOrEmpty(reference.Culture) ?
                                                         "neutral" : reference.Culture) +
                                         ", PublicKeyToken=" + reference.PublicKeyToken));
                        }
                        else
                        {
                            list.Add(Assembly.Load(reference.Path));
                        }
                    }
                    catch (Exception e)
                    {
                    }
                }
            }
            else if (project.Object is VsWebSite.VSWebSite)
            {
                VsWebSite.VSWebSite vswebsite = (VsWebSite.VSWebSite)project.Object;
                foreach (VsWebSite.AssemblyReference reference in vswebsite.References)
                {
                    list.Add(Assembly.Load(reference.StrongName));
                }
            }
            return(list);
        }
Пример #11
0
        /// <summary>
        /// Adds the provided Reference to the received Project.
        /// </summary>
        /// <param name="targetProject">Project to add the Reference.</param>
        /// <param name="referencedProject">Project to be referenced.</param>
        public static void AddReferenceToProject(Project targetProject, Project referencedProject)
        {
            if (targetProject.FullName == referencedProject.FullName)
            {
                return;
            }

            if (targetProject.Object is VSLangProj.VSProject)
            {
                VSLangProj.VSProject vsproject = (VSLangProj.VSProject)targetProject.Object;
                VSLangProj.Reference reference = null;

                try
                {
                    reference = vsproject.References.Find(referencedProject.Name);
                }
                catch (Exception)
                {
                    // It failed to find one, so it must not exist.
                }

                if (reference == null)
                {
                    try
                    {
                        vsproject.References.AddProject(referencedProject);
                    }
                    catch (Exception)
                    {
                        // Add warning to ErrorList pane
                        VisualStudioHelper.AddToErrorList(TaskErrorCategory.Warning,
                                                          string.Format(Resources.Warning_ManuallyAddReference, referencedProject.Name, targetProject.Name),
                                                          targetProject, null, null, null);
                    }
                }
                else
                {
                    // Reference already exists.
                }
            }
            else if (targetProject.Object is VsWebSite.VSWebSite)
            {
                VsWebSite.VSWebSite         vswebsite = (VsWebSite.VSWebSite)targetProject.Object;
                VsWebSite.AssemblyReference reference = null;

                try
                {
                    foreach (VsWebSite.AssemblyReference r in vswebsite.References)
                    {
                        if (r.Name == referencedProject.Name)
                        {
                            reference = r;
                            break;
                        }
                    }
                }
                catch (Exception)
                {
                    // It failed to find one, so it must not exist.
                }

                if (reference == null)
                {
                    try
                    {
                        vswebsite.References.AddFromProject(referencedProject);
                    }
                    catch (Exception)
                    {
                        // Add warning to ErrorList pane
                        VisualStudioHelper.AddToErrorList(TaskErrorCategory.Warning,
                                                          string.Format(Resources.Warning_ManuallyAddReference, referencedProject.Name, targetProject.Name),
                                                          targetProject, null, null, null);
                    }
                }
                else
                {
                    // Reference already exists.
                }
            }
            else
            {
                // Add warning to ErrorList pane
                VisualStudioHelper.AddToErrorList(TaskErrorCategory.Warning,
                                                  string.Format(Resources.Warning_ManuallyAddReference, referencedProject.Name, targetProject.Name),
                                                  targetProject, null, null, null);
            }
        }
Пример #12
0
        /// <summary>
        /// Adds the provided Reference to the received Project.
        /// </summary>
        /// <param name="targetProject">Project to add the Reference.</param>
        /// <param name="referenceIdentity">Reference Identity (Name).</param>
        /// <param name="browseUrl">URL of the Reference (same as the Identity if it is in the GAC).</param>
        public static void AddReferenceToProject(Project targetProject,
                                                 string referenceIdentity, string browseUrl)
        {
            string path = string.Empty;

            if (browseUrl.StartsWith(referenceIdentity) == false)
            {
                // It is a path
                path = browseUrl;
            }

            if (targetProject.Object is VSLangProj.VSProject)
            {
                VSLangProj.VSProject vsproject = (VSLangProj.VSProject)targetProject.Object;
                VSLangProj.Reference reference = null;

                try
                {
                    reference = vsproject.References.Find(referenceIdentity);
                }
                catch (Exception)
                {
                    // It failed to find one, so it must not exist.
                }

                if (reference == null)
                {
                    try
                    {
                        if (string.IsNullOrWhiteSpace(path))
                        {
                            vsproject.References.Add(browseUrl);
                        }
                        else
                        {
                            vsproject.References.Add(path);
                        }
                    }
                    catch (Exception)
                    {
                        // Add warning to ErrorList pane
                        VisualStudioHelper.AddToErrorList(TaskErrorCategory.Warning,
                                                          string.Format(Resources.Warning_ManuallyAddReference, referenceIdentity, targetProject.Name),
                                                          targetProject, null, null, null);
                    }
                }
                else
                {
                    // Reference already exists.
                }
            }
            else if (targetProject.Object is VsWebSite.VSWebSite)
            {
                VsWebSite.VSWebSite         vswebsite = (VsWebSite.VSWebSite)targetProject.Object;
                VsWebSite.AssemblyReference reference = null;

                try
                {
                    foreach (VsWebSite.AssemblyReference r in vswebsite.References)
                    {
                        if (r.Name == referenceIdentity)
                        {
                            reference = r;
                            break;
                        }
                    }
                }
                catch (Exception)
                {
                    // It failed to find one, so it must not exist.
                }

                if (reference == null)
                {
                    if (string.IsNullOrWhiteSpace(path))
                    {
                        vswebsite.References.AddFromGAC(browseUrl);
                    }
                    else
                    {
                        vswebsite.References.AddFromFile(path);
                    }
                }
                else
                {
                    // Reference already exists.
                }
            }
            else
            {
                // Add warning to ErrorList pane
                VisualStudioHelper.AddToErrorList(TaskErrorCategory.Warning,
                                                  string.Format(Resources.Warning_ManuallyAddReference, referenceIdentity, targetProject.Name),
                                                  targetProject, null, null, null);
            }
        }
Пример #13
0
        /// <summary>
        /// The actually processing happens in this method
        /// </summary>
        private void UpdateSolution()
        {
            AddToStatus("Adding AndroMDA support to solution...");

            Project commonProject       = null;
            Project coreProject         = null;
            Project schemaExportProject = null;
            Project testProject         = null;
            Project webProject          = null;
            Project webCommonProject    = null;

            m_srcPath = m_settings.SolutionWizardResourcesLocation + "\\";
            m_dstPath = m_configuration["solution.path"] + "\\";

            string versionControlType = m_configuration["application.versioncontrol"];
            bool   versionControl     = versionControlType != "None";
            string ignoreFile         = string.Empty;

            switch (versionControlType)
            {
            case "CVS":
                ignoreFile = ".cvsignore";
                break;
            }

            nvelocityContext = new VelocityContext();
            foreach (string key in m_configuration.Keys)
            {
                object value = m_configuration[key];
                if (m_configuration[key] == "true" || m_configuration[key] == "false")
                {
                    value = GetConfigSettingBool(key);
                }

                nvelocityContext.Put("wizard." + key, value);
                nvelocityContext.Put("wizard_" + key.Replace('.', '_'), value);
            }

            AddToStatus("Creating AndroMDA configuration files...");

            // Create mda directory
            CreateDirectory("mda");
            // Create mda/conf directory
            CreateDirectory("mda/conf");

            // Render /cvsignore
            if (versionControl)
            {
                WriteFile("cvsignore", ignoreFile);
            }

            if (m_configuration["application.andromda.bootstrap"] == "Apache Maven 2.x")
            {
                // Render /pom.xml
                WriteFile("pom.xml", WriteFileProperties.RenderTemplate | WriteFileProperties.ParseVariables);

                // Render /mda/pom.xml
                WriteFile("mda/pom.xml", WriteFileProperties.RenderTemplate | WriteFileProperties.ParseVariables);

                // Render /mda/conf/andromda.xml
                WriteFile("mda/conf/andromda.xml", WriteFileProperties.RenderTemplate | WriteFileProperties.ParseVariables);

                // Create mda/conf/mappings directory
                CreateDirectory("mda/conf/mappings");

                // Render /mda/conf/mappings/MergeMappings.xml
                WriteFile("mda/conf/mappings/MergeMappings.xml");

                // Render /mda/conf/mappings/NHibernateTypeMappings.xml (Required for NHibernate 1.2)
                WriteFile("mda/conf/mappings/NHibernateTypeMappings.xml");

                // Create mda/resources
                CreateDirectory("mda/resources");

                // Create mda/resources
                CreateDirectory("mda/resources/templates");

                // Create mda/resources
                CreateDirectory("mda/resources/templates/cs");

                // Create mda/resources
                CreateDirectory("mda/resources/templates/nspring");

                // Create mda/resources
                CreateDirectory("mda/resources/templates/nhibernate");
            }

            // Write mda/cvsignore
            if (versionControl)
            {
                WriteFile("mda/cvsignore", "mda/" + ignoreFile);
            }


            AddToStatus("Creating empty model file...");
            // Create mda/src directory
            CreateDirectory("mda/src");
            // Create mda/src/uml directory
            CreateDirectory("mda/src/uml");

            {
                string modelPackageXML = "<UML:Model xmi.id='_9_5_1_874026a_1149883877463_480535_0' name='" + m_configuration["solution.name"] + "'><UML:Namespace.ownedElement>";
                string xmiIdBase       = "_9_5_1_874026a_" + DateTime.Now.Ticks.ToString();
                modelPackageXML += GetXMI(m_configuration["solution.name"].Split('.'), xmiIdBase);
                modelPackageXML += "</UML:Namespace.ownedElement></UML:Model>";

                string emptyModelFileData = ReadFile("mda/src/uml/empty-model.xmi");

                emptyModelFileData = emptyModelFileData.Replace("${wizard.model.packagestructure.xml}", modelPackageXML);

                WriteFileProperties modelProperties = WriteFileProperties.SourceFileIsContent | WriteFileProperties.RenderTemplate | WriteFileProperties.ParseVariables;
                if (GetConfigSettingBool("application.model.zipped"))
                {
                    modelProperties |= WriteFileProperties.Compressed;
                }
                WriteFile(emptyModelFileData, "mda/src/uml/" + m_configuration["application.model.filename"], modelProperties);
            }



            // Create the AndroMDA solution folder
            AddToStatus("Adding solution folder...");
            Solution2 sol            = m_applicationObject.Solution as Solution2;
            Project   solutionFolder = null;

            try
            {
                solutionFolder = sol.AddSolutionFolder("AndroMDA");
                if (m_configuration["application.andromda.bootstrap"] == "Apache Maven 2.x")
                {
                    solutionFolder.ProjectItems.AddFromFile(m_dstPath + "mda\\pom.xml");
                }
                solutionFolder.ProjectItems.AddFromFile(m_dstPath + "mda\\conf\\andromda.xml");
                solutionFolder.ProjectItems.AddFromFile(m_dstPath + "mda\\conf\\mappings\\MergeMappings.xml");
                solutionFolder.ProjectItems.AddFromFile(m_dstPath + "mda\\conf\\mappings\\NHibernateTypeMappings.xml");
                //solutionFolder.ProjectItems.AddFromFile(m_dstPath + "mda\\src\\uml\\" + m_configuration["application.model.filename"]);
            }
            catch { }

            //////////////////////////////////
            // Create/find the common project
            if (GetConfigSettingBool("projects.common.create"))
            {
                AddToStatus("Creating common project " + m_configuration["projects.common.name"] + "...");
                commonProject = VSSolutionUtils.AddClassLibraryProjectToSolution(m_configuration["projects.common.name"], (Solution2)m_applicationObject.Solution);
            }
            else
            {
                AddToStatus("Using existing common project " + m_configuration["projects.common.name"] + "...");
                commonProject = VSSolutionUtils.FindProjectByName(m_configuration["projects.common.name"], m_applicationObject.Solution);
            }

            try { commonProject.ProjectItems.AddFolder("src", Constants.vsProjectItemKindPhysicalFolder); } catch { }
            try { commonProject.ProjectItems.AddFolder("target", Constants.vsProjectItemKindPhysicalFolder); } catch { }

            // Write common/cvsignore
            if (versionControl)
            {
                WriteFile("Common/cvsignore", m_configuration["projects.common.dir"] + "/" + ignoreFile);
            }


            //////////////////////////////////
            // Create/find the core project
            if (GetConfigSettingBool("projects.core.create"))
            {
                AddToStatus("Creating core project " + m_configuration["projects.core.name"] + "...");
                coreProject = VSSolutionUtils.AddClassLibraryProjectToSolution(m_configuration["projects.core.name"], (Solution2)m_applicationObject.Solution);
            }
            else
            {
                AddToStatus("Using existing core project " + m_configuration["projects.core.name"] + "...");
                coreProject = VSSolutionUtils.FindProjectByName(m_configuration["projects.core.name"], m_applicationObject.Solution);
            }
            try { coreProject.ProjectItems.AddFolder("src", Constants.vsProjectItemKindPhysicalFolder); } catch {}
            try { coreProject.ProjectItems.AddFolder("target", Constants.vsProjectItemKindPhysicalFolder); } catch { }

            // Write core/cvsignore
            if (versionControl)
            {
                WriteFile("Core/cvsignore", m_configuration["projects.core.dir"] + "/" + ignoreFile);
            }


            //////////////////////////////////
            // Create the schema export project
            if (GetConfigSettingBool("projects.schemaexport.create"))
            {
                AddToStatus("Creating schema export project " + m_configuration["projects.schemaexport.name"] + "...");
                schemaExportProject = VSSolutionUtils.AddConsoleAppProjectToSolution(m_configuration["projects.schemaexport.name"], (Solution2)m_applicationObject.Solution);

                WriteFile("SchemaExport/App.config", m_configuration["projects.schemaexport.dir"] + "/App.config");
                WriteFile("SchemaExport/nhibernate.config", m_configuration["projects.schemaexport.dir"] + "/nhibernate.config");
                WriteFile("SchemaExport/SchemaExport.cs", m_configuration["projects.schemaexport.dir"] + "/SchemaExport.cs");
                WriteFile("SchemaExport/TestDataManager.cs", m_configuration["projects.schemaexport.dir"] + "/TestDataManager.cs");

                ProjectItem appConfig        = schemaExportProject.ProjectItems.AddFromFile(m_dstPath + m_configuration["projects.schemaexport.dir"] + "\\App.config");
                ProjectItem nhibernateConfig = schemaExportProject.ProjectItems.AddFromFile(m_dstPath + m_configuration["projects.schemaexport.dir"] + "\\nhibernate.config");

                // Set the config files 'Copy to Output Directory' property to 'Copy if Newer'
                appConfig.Properties.Item("CopyToOutputDirectory").Value        = 2;
                appConfig.Properties.Item("BuildAction").Value                  = VSLangProj.prjBuildAction.prjBuildActionContent;
                nhibernateConfig.Properties.Item("CopyToOutputDirectory").Value = 2;
                nhibernateConfig.Properties.Item("BuildAction").Value           = VSLangProj.prjBuildAction.prjBuildActionContent;

                schemaExportProject.ProjectItems.AddFromFile(m_dstPath + m_configuration["projects.schemaexport.dir"] + "\\SchemaExport.cs");
                schemaExportProject.ProjectItems.AddFromFile(m_dstPath + m_configuration["projects.schemaexport.dir"] + "\\TestDataManager.cs");

                // Write SchemaExport/cvsignore
                if (versionControl)
                {
                    WriteFile("SchemaExport/cvsignore", m_configuration["projects.schemaexport.dir"] + "/" + ignoreFile);
                }
            }


            //////////////////////////////////
            // Configure the web project
            if (GetConfigSettingBool("projects.web.configure"))
            {
                //////////////////////////////////
                // Create/find the web project
                if (GetConfigSettingBool("projects.web.create"))
                {
                    AddToStatus("Creating web project " + m_configuration["projects.web.name"] + "...");
                    webProject = VSSolutionUtils.AddWebProjectToSolution(m_configuration["projects.web.name"], (Solution2)m_applicationObject.Solution);
                }
                else
                {
                    AddToStatus("Using existing web project " + m_configuration["projects.web.name"] + "...");
                    webProject = VSSolutionUtils.FindProjectByName(m_configuration["projects.web.dir"], m_applicationObject.Solution);
                }

                // Write the nhibernate.config if required
                if (GetConfigSettingBool("projects.web.usenhibernateconfig"))
                {
                    WriteFile("Web/nhibernate.config", webProject.Name + "nhibernate.config", WriteFileProperties.DestinationPathAlreadyComplete | WriteFileProperties.ParseVariables);
                }

                string webConfigDstFile = webProject.Name + "Web.config";

                if (!System.IO.File.Exists(webConfigDstFile))
                {
                    // Write out the web.config file
                    WriteFile("Web/web.config", webConfigDstFile, WriteFileProperties.DestinationPathAlreadyComplete | WriteFileProperties.ParseVariables);
                    webProject.ProjectItems.AddFromFile(webConfigDstFile);
                }

                // Open the web.config file
                System.Configuration.Configuration webconfig = OpenWebConfig(webConfigDstFile);

                // If the nhibernate settings are stored in nhibernate.config
                if (GetConfigSettingBool("projects.web.usenhibernateconfig"))
                {
                    // Add that to the app settings
                    if (webconfig.AppSettings.Settings["nhibernate.config"] == null)
                    {
                        webconfig.AppSettings.Settings.Add("nhibernate.config", "~/nhibernate.config");
                    }
                    else
                    {
                        webconfig.AppSettings.Settings.Add("nhibernate.config", "~/nhibernate.config");
                    }
                    // Remove the nhibernate section if it exists
                    if (webconfig.Sections.Get("nhibernate") != null)
                    {
                        webconfig.Sections.Remove("nhibernate");
                    }
                }
                else
                {
                    // Remove the nhibernate.config app setting if it exists
                    if (webconfig.AppSettings.Settings["nhibernate.config"] != null)
                    {
                        webconfig.AppSettings.Settings.Remove("nhibernate.config");
                    }

                    // Add the nhibernate config to the web.config
                    DefaultSection nhibernateSection = new DefaultSection();
                    nhibernateSection.SectionInformation.Type = "System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089";

                    nhibernateSection.SectionInformation.SetRawXml(ParseVariables(ReadFile("web/web.config.nhibernate")));

                    webconfig.Sections.Add("nhibernate", nhibernateSection);
                }

                // Write Web/cvsignore and Web\Bin\cvsignore
                if (versionControl)
                {
                    WriteFile("web/cvsignore", webProject.Name + ignoreFile, WriteFileProperties.DestinationPathAlreadyComplete);
                    CreateDirectory(webProject.Name + "Bin", false);
                    WriteFile("web/bin/cvsignore", webProject.Name + "Bin\\" + ignoreFile, WriteFileProperties.DestinationPathAlreadyComplete);
                }

                if (GetConfigSettingBool("projects.web.common.configure"))
                {
                    // Create/find the core project
                    if (GetConfigSettingBool("projects.web.common.create"))
                    {
                        AddToStatus("Creating web common project " + m_configuration["projects.web.common.name"] + "...");
                        webCommonProject = VSSolutionUtils.AddClassLibraryProjectToSolution(m_configuration["projects.web.common.name"], (Solution2)m_applicationObject.Solution);
                    }
                    else
                    {
                        AddToStatus("Using existing web common project " + m_configuration["projects.web.common.name"] + "...");
                        webCommonProject = VSSolutionUtils.FindProjectByName(m_configuration["projects.web.common.name"], m_applicationObject.Solution);
                    }
                }

                // Get the web site object
                VsWebSite.VSWebSite webSite = webProject.Object as VsWebSite.VSWebSite;

                // Refresh folder view
                webSite.Refresh();

                // Add Membership support
                if (GetConfigSettingBool("projects.web.addmembership"))
                {
                    AddToStatus("Adding membership support...");

                    string      file;
                    ProjectItem membershipFolder = VSSolutionUtils.FindProjectFolder(webCommonProject, "Membership");
                    if (membershipFolder == null)
                    {
                        membershipFolder = webCommonProject.ProjectItems.AddFolder("Membership", Constants.vsProjectItemKindPhysicalFolder);
                    }

                    // Render DomainMembershipProvider.cs
                    WriteFile("Membership/DomainMembershipProvider.cs", m_configuration["projects.web.common.dir"] + "/Membership/DomainMembershipProvider.cs");
                    membershipFolder.ProjectItems.AddFromFile(m_dstPath + m_configuration["projects.web.common.dir"] + "\\Membership\\DomainMembershipProvider.cs");

                    // Render DomainRoleProvider.cs
                    WriteFile("Membership/DomainRoleProvider.cs", m_configuration["projects.web.common.dir"] + "/Membership/DomainRoleProvider.cs");
                    membershipFolder.ProjectItems.AddFromFile(m_dstPath + m_configuration["projects.web.common.dir"] + "\\Membership\\DomainRoleProvider.cs");

                    // Render DomainMembershipUser.cs
                    WriteFile("Membership/DomainMembershipUser.cs", m_configuration["projects.web.common.dir"] + "/Membership/DomainMembershipUser.cs");
                    membershipFolder.ProjectItems.AddFromFile(m_dstPath + m_configuration["projects.web.common.dir"] + "\\Membership\\DomainMembershipUser.cs");

                    // Create core/src/* folder tree from namespace
                    string   solutionName = m_configuration["solution.name"];
                    string[] namespaces   = solutionName.Split('.');
                    file = m_configuration["projects.core.dir"] + "\\src\\";
                    foreach (string folder in namespaces)
                    {
                        file = file + folder;
                        CreateDirectory(file);
                        file = file + "\\";
                    }
                    CreateDirectory(file + "Domain");
                    CreateDirectory(file + "Service");

                    // Render UserDao.cs
                    WriteFile("Membership/UserDao.cs", file + "Domain/UserDao.cs");
                    coreProject.ProjectItems.AddFromFile(m_dstPath + file + "Domain\\UserDao.cs");

                    // Render MembershipService.cs
                    WriteFile("Membership/MembershipService.cs", file + "Service/MembershipService.cs");
                    coreProject.ProjectItems.AddFromFile(m_dstPath + file + "Service\\MembershipService.cs");

                    ConfigurationSectionGroup systemweb = webconfig.SectionGroups["system.web"];

                    systemweb.Sections["membership"].SectionInformation.SetRawXml(ParseVariables(ReadFile("web/web.config.membershipsection")));
                    systemweb.Sections["roleManager"].SectionInformation.SetRawXml(ParseVariables(ReadFile("web/web.config.rolesection")));

                    systemweb.Sections["membership"].SectionInformation.ForceSave  = true;
                    systemweb.Sections["roleManager"].SectionInformation.ForceSave = true;

                    // Turn on authentication
                    systemweb.Sections["authentication"].SectionInformation.SetRawXml("<authentication mode=\"Forms\"> <forms name=\"FormsAuth\" timeout=\"30\" loginUrl=\"~/Public/Login.aspx\" defaultUrl=\"~/Default.aspx\" path=\"/\" protection=\"All\"/></authentication>");
                }

                // Save the changes to the web.config
                webconfig.Save();
            }

            // Create the lib directory
            CreateDirectory("Lib");

            // Write the libraries out
            WriteBinaryFile("Lib/AndroMDA.NHibernateSupport.dll");
            WriteBinaryFile("Lib/Bamboo.Prevalence.dll");
            WriteBinaryFile("Lib/Castle.DynamicProxy.dll");
            //WriteBinaryFile("Lib/HashCodeProvider.dll");
            WriteBinaryFile("Lib/Iesi.Collections.dll");
            WriteBinaryFile("Lib/log4net.dll");
            WriteBinaryFile("Lib/NHibernate.Caches.Prevalence.dll");
            WriteBinaryFile("Lib/NHibernate.Caches.SysCache.dll");
            WriteBinaryFile("Lib/NHibernate.dll");
            //WriteBinaryFile("Lib/NHibernate.Nullables2.dll");
            WriteBinaryFile("Lib/Nullables.dll");
            WriteBinaryFile("Lib/Nullables.NHibernate.dll");


            //////////////////////////////////
            // Configure the tests project
            if (GetConfigSettingBool("projects.tests.configure"))
            {
                // Create/find the core project
                if (GetConfigSettingBool("projects.tests.create"))
                {
                    AddToStatus("Creating testing project " + m_configuration["projects.tests.name"] + "...");
                    testProject = VSSolutionUtils.AddClassLibraryProjectToSolution(m_configuration["projects.tests.name"], (Solution2)m_applicationObject.Solution);
                }
                else
                {
                    AddToStatus("Using existing testing project " + m_configuration["projects.tests.name"] + "...");
                    testProject = VSSolutionUtils.FindProjectByName(m_configuration["projects.tests.name"], m_applicationObject.Solution);
                }
                WriteFile("Tests/App.config", m_configuration["projects.tests.dir"] + "/App.config", WriteFileProperties.RenderTemplate | WriteFileProperties.ParseVariables);
                WriteFile("Tests/nhibernate.config", m_configuration["projects.tests.dir"] + "/nhibernate.config");

                ProjectItem appConfig        = testProject.ProjectItems.AddFromFile(m_dstPath + m_configuration["projects.tests.dir"] + "\\App.config");
                ProjectItem nhibernateConfig = testProject.ProjectItems.AddFromFile(m_dstPath + m_configuration["projects.tests.dir"] + "\\nhibernate.config");

                // Set the config files 'Copy to Output Directory' property to 'Copy if Newer'
                appConfig.Properties.Item("CopyToOutputDirectory").Value        = 2;
                appConfig.Properties.Item("BuildAction").Value                  = VSLangProj.prjBuildAction.prjBuildActionContent;
                nhibernateConfig.Properties.Item("CopyToOutputDirectory").Value = 2;
                nhibernateConfig.Properties.Item("BuildAction").Value           = VSLangProj.prjBuildAction.prjBuildActionContent;

                AddToStatus("Writing NUnit assemblies...");

                WriteBinaryFile("Lib/nunit.core.dll");
                WriteBinaryFile("Lib/nunit.framework.dll");

                AddToStatus("Adding NUnit references...");

                VSProject vsTestProj = (VSProject)testProject.Object;
                vsTestProj.References.Add(m_dstPath + "Lib\\nunit.core.dll");
                vsTestProj.References.Add(m_dstPath + "Lib\\nunit.framework.dll");

                if (GetConfigSettingBool("projects.tests.scenariounit"))
                {
                    AddToStatus("Writing ScenarioUnit assemblies...");
                    WriteBinaryFile("Lib/NXUnit.Framework.dll");
                    WriteBinaryFile("Lib/AndroMDA.ScenarioUnit.dll");
                    AddToStatus("Adding ScenarioUnit references...");
                    vsTestProj.References.Add(m_dstPath + "Lib\\NXUnit.Framework.dll");
                    vsTestProj.References.Add(m_dstPath + "Lib\\AndroMDA.ScenarioUnit.dll");
                    ProjectItem testDataFolder = testProject.ProjectItems.AddFolder("TestData", Constants.vsProjectItemKindPhysicalFolder);
                    testDataFolder.ProjectItems.AddFolder("actual_output", Constants.vsProjectItemKindPhysicalFolder);
                    testDataFolder.ProjectItems.AddFolder("expected_output", Constants.vsProjectItemKindPhysicalFolder);
                    testDataFolder.ProjectItems.AddFolder("rules", Constants.vsProjectItemKindPhysicalFolder);
                    testDataFolder.ProjectItems.AddFolder("input", Constants.vsProjectItemKindPhysicalFolder);
                }
            }

            // Add the references to all the DLLs we just put in /Lib
            AddToStatus("Adding project references to common project...");
            AddBinaryReferences(commonProject);
            AddToStatus("Adding project references to core project...");
            AddBinaryReferences(coreProject);

            // Add a reference from the core project to the common project
            AddProjectReference(coreProject, commonProject);

            // If we created the schema export project
            if (schemaExportProject != null)
            {
                VSProject proj = schemaExportProject.Object as VSProject;
                AddToStatus("Adding references to schema export project...");
                // Add the references to the DLLs
                AddBinaryReferences(schemaExportProject);

                // Add references to the core and common projects
                AddProjectReference(schemaExportProject, commonProject);
                AddProjectReference(schemaExportProject, coreProject);

                AddToStatus("Adding System.Configuration reference to schema export project...");
                try { proj.References.Add("System.Configuration"); } catch { }
            }

            // If we created the schema export project
            if (testProject != null)
            {
                AddToStatus("Adding references to testing project...");
                // Add the references to the DLLs
                AddBinaryReferences(testProject);

                // Add references to the core and common projects
                AddProjectReference(testProject, commonProject);
                AddProjectReference(testProject, coreProject);
            }


            if (webProject != null)
            {
                AddToStatus("Adding project references to web project...");

                VsWebSite.VSWebSite proj = webProject.Object as VsWebSite.VSWebSite;

                proj.References.AddFromFile(m_dstPath + "Lib\\AndroMDA.NHibernateSupport.dll");

                try { proj.References.AddFromProject(commonProject); } catch {}
                try { proj.References.AddFromProject(coreProject); } catch {}
                if (webCommonProject != null)
                {
                    try { proj.References.AddFromProject(webCommonProject); } catch { }
                }
                //m_applicationObject.Solution.Properties.Item("StartupProject").Value = webProject.Name;
            }

            if (webCommonProject != null)
            {
                VSProject proj = webCommonProject.Object as VSProject;
                AddToStatus("Adding common project reference to web common project...");
                try { proj.References.AddProject(commonProject); } catch { }
                AddToStatus("Adding core project reference to web common project...");
                try { proj.References.AddProject(coreProject); } catch { }
                AddToStatus("Adding System.Configuration reference to web common project...");
                try { proj.References.Add("System.Configuration"); } catch { }
                AddToStatus("Adding System.Web reference to web common project...");
                try { proj.References.Add("System.Web"); } catch { }
            }

            AddToStatus("Processing complete, cleaning up...");
        }