Beispiel #1
0
        public static void RenameProject(IProject project, string newName)
        {
            if (project.Name == newName)
            {
                return;
            }
            if (!FileService.CheckFileName(newName))
            {
                return;
            }
            // multiple projects with the same name shouldn't be a problem
//			foreach (IProject p in ProjectService.OpenSolution.Projects) {
//				if (string.Equals(p.Name, newName, StringComparison.OrdinalIgnoreCase)) {
//					MessageService.ShowMessage("There is already a project with this name.");
//					return;
//				}
//			}
            string newFileName = Path.Combine(project.Directory, newName + Path.GetExtension(project.FileName));

            // see issue #2 on http://community.sharpdevelop.net/forums/t/15800.aspx:
            // The name of the project and the file name might differ. So if the FileName is
            // already the same as the new project file name, just update the name in the solution.
            if (FileUtility.IsEqualFileName(newFileName, project.FileName))
            {
                project.Name = newName;
                ProjectService.SaveSolution();
                return;
            }

            if (!FileService.RenameFile(project.FileName, newFileName, false))
            {
                return;
            }
            if (project.AssemblyName == project.Name)
            {
                project.AssemblyName = newName;
            }
            if (File.Exists(project.FileName + ".user"))
            {
                FileService.RenameFile(project.FileName + ".user", newFileName + ".user", false);
            }
            foreach (IProject p in ProjectService.OpenSolution.Projects)
            {
                foreach (ProjectItem item in p.Items)
                {
                    if (item.ItemType == ItemType.ProjectReference)
                    {
                        ProjectReferenceProjectItem refItem = (ProjectReferenceProjectItem)item;
                        if (refItem.ReferencedProject == project)
                        {
                            refItem.ProjectName = newName;
                            refItem.Include     = FileUtility.GetRelativePath(p.Directory, newFileName);
                        }
                    }
                }
            }
            project.FileName = newFileName;
            project.Name     = newName;
            ProjectService.SaveSolution();
        }
Beispiel #2
0
            /// <summary>
            /// Adds a ProjectToBuild item for the project and it's project references.
            /// Returns the added item, or null if an error occured.
            /// </summary>
            ProjectToBuild ParseMSBuildProject(IProject project)
            {
                ProjectToBuild ptb;

                if (parseMSBuildProjectProjectsToBuildDict.TryGetValue(project, out ptb))
                {
                    // only add each project once, reuse existing ProjectToBuild
                    return(ptb);
                }
                ptb = new ProjectToBuild(project.FileName, options.Target.TargetName);
                ptb.configuration = parentEngine.Configuration;
                ptb.platform      = parentEngine.Platform;

                projectsToBuild.Add(ptb);
                parseMSBuildProjectProjectsToBuildDict[project] = ptb;

                foreach (ProjectItem item in project.GetItemsOfType(ItemType.ProjectReference))
                {
                    ProjectReferenceProjectItem prpi = item as ProjectReferenceProjectItem;
                    if (prpi != null && prpi.ReferencedProject != null)
                    {
                        ProjectToBuild referencedProject = ParseMSBuildProject(prpi.ReferencedProject);
                        if (referencedProject == null)
                        {
                            return(null);
                        }
                        ptb.dependencies.Add(referencedProject);
                    }
                }

                return(ptb);
            }
Beispiel #3
0
		public ProjectReferenceProjectItem AddProjectReference(IProject referencedProject)
		{
			var referenceProjectItem = new ProjectReferenceProjectItem(this, referencedProject);
			referenceProjectItem.FileName = referencedProject.FileName;
			ProjectService.AddProjectItem(this, referenceProjectItem);
			return referenceProjectItem;
		}
Beispiel #4
0
        public static void RenameProject(IProject project, string newName)
        {
            if (project.Name == newName)
            {
                return;
            }
            if (!FileService.CheckFileName(newName))
            {
                return;
            }
            // multiple projects with the same name shouldn't be a problem
//			foreach (IProject p in ProjectService.OpenSolution.Projects) {
//				if (string.Equals(p.Name, newName, StringComparison.OrdinalIgnoreCase)) {
//					MessageService.ShowMessage("There is already a project with this name.");
//					return;
//				}
//			}
            string newFileName = Path.Combine(project.Directory, newName + Path.GetExtension(project.FileName));

            if (!FileService.RenameFile(project.FileName, newFileName, false))
            {
                return;
            }
            if (project.AssemblyName == project.Name)
            {
                project.AssemblyName = newName;
            }
            if (File.Exists(project.FileName + ".user"))
            {
                FileService.RenameFile(project.FileName + ".user", newFileName + ".user", false);
            }
            foreach (IProject p in ProjectService.OpenSolution.Projects)
            {
                foreach (ProjectItem item in p.Items)
                {
                    if (item.ItemType == ItemType.ProjectReference)
                    {
                        ProjectReferenceProjectItem refItem = (ProjectReferenceProjectItem)item;
                        if (refItem.ReferencedProject == project)
                        {
                            refItem.ProjectName = newName;
                            refItem.Include     = FileUtility.GetRelativePath(p.Directory, newFileName);
                        }
                    }
                }
            }
            project.FileName = newFileName;
            project.Name     = newName;
            ProjectService.SaveSolution();
        }
		static void AddProjectReferenceToProject(IProject project, IProject referenceTo)
		{
			LoggingService.Warn("Adding project reference to project.");
			ProjectReferenceProjectItem reference = new ProjectReferenceProjectItem(project, referenceTo);
			ProjectService.AddProjectItem(project, reference);
			project.Save();
		}
		public void WriteTestsWritesDirectoriesForReferencedProjectsToSysPathCommandLineArguments()
		{
			MockCSharpProject referencedProject = new MockCSharpProject();
			referencedProject.FileName = @"c:\projects\pyproject\pyproject.pyproj";
			
			MockCSharpProject unitTestProject = new MockCSharpProject();
			ProjectReferenceProjectItem projectRef = new ProjectReferenceProjectItem(unitTestProject, referencedProject);
			projectRef.FileName = @"c:\projects\pyproject\pyproject.pyproj";
			ProjectService.AddProjectItem(unitTestProject, projectRef);
			
			MockMethod method = MockMethod.CreateMockMethodWithoutAnyAttributes();
			method.FullyQualifiedName = "MyNamespace.MyTests.MyTestMethod";
			
			SelectedTests tests = new SelectedTests(unitTestProject, null, null, method);
			responseFile.WriteTests(tests);
			
			string expectedText =
				"/p:\"c:\\projects\\pyproject\"\r\n" +
				"MyNamespace.MyTests.MyTestMethod\r\n";
			
			Assert.AreEqual(expectedText, responseFileText.ToString());
		}
		public void CreateProcessInfoReturnsCommandLineWithDirectoriesForReferencedProjects()
		{
			MockCSharpProject referencedProject = new MockCSharpProject();
			referencedProject.FileName = @"c:\projects\rbproject\rbproject.rbproj";
			
			MockCSharpProject unitTestProject = new MockCSharpProject();
			ProjectReferenceProjectItem projectRef = new ProjectReferenceProjectItem(unitTestProject, referencedProject);
			projectRef.FileName = @"c:\projects\rbproject\pyproject.rbproj";
			ProjectService.AddProjectItem(unitTestProject, projectRef);
			
			MockMethod method = MockMethod.CreateMockMethodWithoutAnyAttributes();
			method.CompilationUnit.FileName = @"d:\mytest.rb";
			FileProjectItem fileItem = new FileProjectItem(unitTestProject, ItemType.Compile);
			fileItem.FileName = @"d:\mytest.rb";
			ProjectService.AddProjectItem(unitTestProject, fileItem);
			
			SelectedTests tests = RubySelectedTestsHelper.CreateSelectedTests(unitTestProject);
			ProcessStartInfo processStartInfo = GetProcessStartInfoFromTestRunnerApp(tests);
						
			string expectedCommandLine = 
				"--disable-gems " +
				"\"-Ic:\\rubybinding\\TestRunner\" " +
				"\"-Ic:\\projects\\rbproject\" " +
				"\"c:\\rubybinding\\TestRunner\\sdtest.rb\" " +
				"-- " +
				"\"results.txt\" " +
				"\"temp.tmp\"";
			
			Assert.AreEqual(expectedCommandLine, processStartInfo.Arguments);
		}