Ejemplo n.º 1
0
        public void CheckProjectContainsItself()
        {
            var folder = new SolutionFolder ();
            var project = new DotNetAssemblyProject { Name = "foo" };
            folder.AddItem (project);

            Assert.IsNotNull (folder.GetProjectContainingFile (project.FileName), "#1");
        }
        void CreateProject(Solution solution, SolutionFolder srcFolder, bool newSolution = true)
        {
            string     projectName = Parameters["UserDefinedProjectName"];
            DnxProject project     = CreateProject(solution, projectName);

            srcFolder.AddItem(project.Project);

            project.AddConfigurations();

            if (newSolution)
            {
                solution.StartupItem = project.Project;
                solution.GenerateDefaultDnxProjectConfigurations(project);
            }
            else
            {
                solution.EnsureConfigurationHasBuildEnabled(project);
            }

            project.CreateProjectDirectory();

            if (Parameters.GetBoolValue("CreateWebRoot"))
            {
                project.CreateWebRootDirectory();
            }

            RemoveProjectDirectoryCreatedByNewProjectDialog(solution.BaseDirectory, projectName);

            CreateFilesFromTemplate(project);

            OpenProjectFile(project);

            IdeApp.ProjectOperations.SaveAsync(solution)
            .ContinueWith(t => {
                Runtime.RunInMainThread(() => {
                    DnxServices.ProjectService.OnSolutionLoaded(solution);
                });
            });
        }
Ejemplo n.º 3
0
        void CreateProject(Solution solution, SolutionFolder srcFolder, bool newSolution = true)
        {
            string     projectName = Parameters["UserDefinedProjectName"];
            DnxProject project     = CreateProject(solution, projectName);

            srcFolder.AddItem(project);

            project.AddConfigurations();

            if (newSolution)
            {
                solution.GenerateDefaultDnxProjectConfigurations(project);
                solution.StartupItem = project;
            }
            else
            {
                solution.EnsureConfigurationHasBuildEnabled(project);
            }

            project.CreateProjectDirectory();

            if (Parameters.GetBoolean("CreateWebRoot"))
            {
                project.CreateWebRootDirectory();
            }

            RemoveProjectDirectoryCreatedByNewProjectDialog(solution.BaseDirectory, projectName);

            CreateFilesFromTemplate(project);

            solution.Save(new NullProgressMonitor());

            OpenProjectFile(project);

            DnxServices.ProjectService.LoadAspNetProjectSystem(solution);
        }
        async Task CreateProject(Solution solution, SolutionFolder srcFolder, bool newSolution = true)
        {
            string        projectName = Parameters["UserDefinedProjectName"];
            DotNetProject project     = await CreateProject(solution, projectName);

            srcFolder.AddItem(project);

            if (newSolution)
            {
                solution.StartupItem = project;
                solution.GenerateDefaultProjectConfigurations(project);
            }
            else
            {
                solution.EnsureConfigurationHasBuildEnabled(project);
            }

            UpdateDefaultRunConfiguration(project);

            if (Parameters.GetBoolValue("CreateWebRoot"))
            {
                FilePath webRootDirectory = project.BaseDirectory.Combine("wwwroot");
                Directory.CreateDirectory(webRootDirectory);
            }

            if (IsWebProject())
            {
                RemoveProjectDirectoryCreatedByNewProjectDialog(solution.BaseDirectory, projectName);
            }

            await IdeApp.ProjectOperations.SaveAsync(solution);

            OpenProjectFile(project);

            RestorePackages(project);
        }
Ejemplo n.º 5
0
		public SolutionItem AddSolutionItem (SolutionFolder folder, string entryFileName)
		{
			AddEntryEventArgs args = new AddEntryEventArgs (folder, entryFileName);
			if (AddingEntryToCombine != null)
				AddingEntryToCombine (this, args);
			if (args.Cancel)
				return null;
			using (IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetProjectLoadProgressMonitor (true)) {
				return folder.AddItem (monitor, args.FileName, true);
			}
		}
Ejemplo n.º 6
0
		public bool AddFilesToSolutionFolder (SolutionFolder folder, string[] files)
		{
			QuestionMessage msg = new QuestionMessage ();
			AlertButton keepButton = new AlertButton (GettextCatalog.GetString ("Keep file path"));
			msg.Buttons.Add (keepButton);
			msg.Buttons.Add (AlertButton.Copy);
			msg.Buttons.Add (AlertButton.Move);
			msg.Buttons.Add (AlertButton.Cancel);
			msg.AllowApplyToAll = true;
			
			bool someAdded = false;
			
			foreach (string file in files) {
				FilePath fp = file;
				FilePath dest = folder.BaseDirectory.Combine (fp.FileName);
				
				if (folder.IsRoot) {
					// Don't allow adding files to the root folder. VS doesn't allow it
					// If there is no existing folder, create one
					var itemsFolder = (SolutionFolder) folder.Items.Where (item => item.Name == "Solution Items").FirstOrDefault ();
					if (itemsFolder == null) {
						itemsFolder = new SolutionFolder ();
						itemsFolder.Name = "Solution Items";
						folder.AddItem (itemsFolder);
					}
					folder = itemsFolder;
				}
				
				if (!fp.IsChildPathOf (folder.BaseDirectory)) {
					msg.Text = GettextCatalog.GetString ("The file {0} is outside the folder directory. What do you want to do?", fp.FileName);
					AlertButton res = MessageService.AskQuestion (msg);
					if (res == AlertButton.Cancel)
						return someAdded;
					if (res == AlertButton.Copy) {
						FileService.CopyFile (file, dest);
						fp = dest;
					} else if (res == AlertButton.Move) {
						FileService.MoveFile (file, dest);
						fp = dest;
					}
				}
				folder.Files.Add (fp);
				someAdded = true;
			}
			return someAdded;
		}
        void CreateProject(Solution solution, SolutionFolder srcFolder, bool newSolution = true)
        {
            string projectName = Parameters["UserDefinedProjectName"];
            DnxProject project = CreateProject (solution, projectName);
            srcFolder.AddItem (project);

            project.AddConfigurations ();

            if (newSolution) {
                solution.GenerateDefaultDnxProjectConfigurations (project);
                solution.StartupItem = project;
            } else {
                solution.EnsureConfigurationHasBuildEnabled (project);
            }

            project.CreateProjectDirectory ();

            if (Parameters.GetBoolean ("CreateWebRoot")) {
                project.CreateWebRootDirectory ();
            }

            RemoveProjectDirectoryCreatedByNewProjectDialog (solution.BaseDirectory, projectName);

            CreateFilesFromTemplate (project);

            solution.Save (new NullProgressMonitor ());

            OpenProjectFile (project);

            DnxServices.ProjectService.LoadAspNetProjectSystem (solution);
        }
Ejemplo n.º 8
0
        public void SolutionBoundUnbound()
        {
            Solution sol = new Solution ();

            var e = new SomeItem ();
            Assert.AreEqual (0, e.BoundEvents);
            Assert.AreEqual (0, e.UnboundEvents);

            sol.RootFolder.AddItem (e);
            Assert.AreEqual (1, e.BoundEvents);
            Assert.AreEqual (0, e.UnboundEvents);
            Assert.AreEqual (1, e.InternalItem.BoundEvents);
            Assert.AreEqual (0, e.InternalItem.UnboundEvents);

            e.Reset ();
            sol.RootFolder.Items.Remove (e);
            Assert.AreEqual (0, e.BoundEvents);
            Assert.AreEqual (1, e.UnboundEvents);
            Assert.AreEqual (0, e.InternalItem.BoundEvents);
            Assert.AreEqual (1, e.InternalItem.UnboundEvents);

            e.Reset ();
            sol.RootFolder.AddItem (e);
            Assert.AreEqual (1, e.BoundEvents);
            Assert.AreEqual (0, e.UnboundEvents);
            Assert.AreEqual (1, e.InternalItem.BoundEvents);
            Assert.AreEqual (0, e.InternalItem.UnboundEvents);

            e.Reset ();
            sol.RootFolder.Items.Remove (e);
            Assert.AreEqual (0, e.BoundEvents);
            Assert.AreEqual (1, e.UnboundEvents);
            Assert.AreEqual (0, e.InternalItem.BoundEvents);
            Assert.AreEqual (1, e.InternalItem.UnboundEvents);

            e.Reset ();
            var f = new SolutionFolder ();
            f.AddItem (e);
            Assert.AreEqual (0, e.BoundEvents);
            Assert.AreEqual (0, e.UnboundEvents);
            Assert.AreEqual (0, e.InternalItem.BoundEvents);
            Assert.AreEqual (0, e.InternalItem.UnboundEvents);

            sol.RootFolder.AddItem (f);
            Assert.AreEqual (1, e.BoundEvents);
            Assert.AreEqual (0, e.UnboundEvents);
            Assert.AreEqual (1, e.InternalItem.BoundEvents);
            Assert.AreEqual (0, e.InternalItem.UnboundEvents);

            e.Reset ();
            sol.RootFolder.Items.Remove (f);
            Assert.AreEqual (0, e.BoundEvents);
            Assert.AreEqual (1, e.UnboundEvents);
            Assert.AreEqual (0, e.InternalItem.BoundEvents);
            Assert.AreEqual (1, e.InternalItem.UnboundEvents);

            f.Dispose ();
            sol.Dispose ();
        }