Exemple #1
0
        public void RoundtripPropertyWithXmlCharacters()
        {
            Solution sol = TestProjectsChecks.CreateConsoleSolution("roundtrip-property-with-xml");

            sol.ConvertToFormat(Util.FileFormatMSBuild05, true);

            var value = "Hello<foo>&.exe";

            var p    = (DotNetProject)sol.GetAllProjects().First();
            var conf = ((DotNetProjectConfiguration)p.Configurations [0]);

            conf.OutputAssembly = value;
            sol.Save(Util.GetMonitor());

            sol  = (Solution)Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), sol.FileName);
            p    = (DotNetProject)sol.GetAllProjects().First();
            conf = ((DotNetProjectConfiguration)p.Configurations [0]);

            Assert.AreEqual(value, conf.OutputAssembly);
        }
Exemple #2
0
 static void AssertOutputFiles(Solution solution, string projectName, string configuration, string[] expectedFiles)
 {
     foreach (Project proj in solution.GetAllProjects())
     {
         if (proj.Name == projectName)
         {
             AssertOutputFiles(proj, configuration, expectedFiles);
             return;
         }
     }
     Assert.Fail("Did not find project '{0}'", projectName);
 }
        public void SaveReferenceWithCondition()
        {
            string   solFile = Util.GetSampleProject("console-project-conditional-reference", "ConsoleProject.sln");
            Solution sol     = Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), solFile) as Solution;

            string proj = sol.GetAllProjects().First().FileName;

            string projectXml1 = Util.GetXmlFileInfoset(proj);

            sol.Save(new NullProgressMonitor());

            string projectXml2 = Util.GetXmlFileInfoset(proj);

            Assert.AreEqual(projectXml1, projectXml2);
        }
Exemple #4
0
        public void ProjectWithCustomConfigPropertyGroupBug20554()
        {
            string   solFile = Util.GetSampleProject("console-project-custom-configs", "ConsoleProject.sln");
            Solution sol     = Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), solFile) as Solution;

            string proj = sol.GetAllProjects().First().FileName;

            string projectXml1 = Util.GetXmlFileInfoset(proj);

            sol.Save(new NullProgressMonitor());

            string projectXml2 = Util.GetXmlFileInfoset(proj);

            Assert.AreEqual(projectXml1, projectXml2);
        }
        public void BuildConsoleProject()
        {
            Solution sol = TestProjectsChecks.CreateConsoleSolution("console-project-msbuild");

            sol.Save(Util.GetMonitor());

            // Ensure the project is buildable
            var result = sol.Build(Util.GetMonitor(), "Debug");

            Assert.AreEqual(0, result.ErrorCount, "#1");

            // Ensure the project is still buildable with xbuild after a rename
            ProjectOptionsDialog.RenameItem(sol.GetAllProjects() [0], "Test");
            result = sol.Build(Util.GetMonitor(), "Release");
            Assert.AreEqual(0, result.ErrorCount, "#2");
        }
        async Task <DotNetProject> OpenProject(string solutionName = "DotNetCoreFileWatcherTests.sln")
        {
            string solutionFileName = Util.GetSampleProject("DotNetCoreFileWatcherTests", solutionName);

            solution = (Solution)await Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), solutionFileName);

            project = solution.GetAllProjects().Single() as DotNetProject;

            CreateNuGetConfigFile(solution.BaseDirectory);

            Assert.AreEqual(0, project.Files.Count);

            RunMSBuild($"/t:Restore /p:RestoreDisableParallel=true \"{solution.FileName}\"");

            return(project);
        }
        public async Task ProjItemsFileNameNotMatchingShproj_Bug20571()
        {
            string   solFile = Util.GetSampleProject("SharedProjectTestBug20571", "SharedProjectTest.sln");
            Solution sol     = (Solution)await Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), solFile);

            Assert.AreEqual(3, sol.GetAllProjects().Count());

            var pc1 = (DotNetProject)sol.FindProjectByName("Console1");

            Assert.IsNotNull(pc1);

            var pc2 = (DotNetProject)sol.FindProjectByName("Console2");

            Assert.IsNotNull(pc2);

            var pcs = (SharedAssetsProject)sol.FindProjectByName("Shared");

            Assert.IsNotNull(pcs);

            Assert.IsTrue(pc1.References.Any(r => r.Reference == "Shared"));

            var sharedFile = pcs.ItemDirectory.Combine("MyClass.cs");

            Assert.IsTrue(pc1.Files.GetFile(sharedFile) != null);
            Assert.IsTrue(pc2.Files.GetFile(sharedFile) == null);
            Assert.IsTrue(pcs.Files.GetFile(sharedFile) != null);

            pc2.References.Add(ProjectReference.CreateProjectReference(pcs));
            Assert.IsTrue(pc2.Files.GetFile(sharedFile) != null);

            await pc2.SaveAsync(Util.GetMonitor());

            Solution sol2 = (Solution)await Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), sol.FileName);

            sol.Dispose();

            pc2 = (DotNetProject)sol2.FindProjectByName("Console2");
            Assert.IsNotNull(pc2);

            Assert.IsTrue(pc2.References.Any(r => r.Reference == "Shared"));

            Assert.IsTrue(pc2.Files.GetFile(sharedFile) != null);

            sol2.Dispose();
        }
Exemple #8
0
        public async Task BuildConsoleProjectAfterRename()
        {
            Solution sol = TestProjectsChecks.CreateConsoleSolution("console-project-msbuild");
            await sol.SaveAsync(Util.GetMonitor());

            // Ensure the project is still buildable with xbuild after a rename
            var      project = sol.GetAllProjects().First();
            FilePath newFile = project.FileName.ParentDirectory.Combine("Test" + project.FileName.Extension);

            FileService.RenameFile(project.FileName, newFile.FileName);
            project.Name = "Test";

            var result = await sol.Build(Util.GetMonitor(), "Release");

            Assert.AreEqual(0, result.ErrorCount, "#2");

            sol.Dispose();
        }
Exemple #9
0
        public async Task FirstBuildFlagNotRemovedAfterClean()
        {
            Solution sol     = TestProjectsChecks.CreateConsoleSolution("console-project-msbuild");
            var      project = sol.GetAllProjects().First();

            project.IsFirstBuild = true;
            Assert.IsTrue(project.UserProperties.GetValue <bool> ("FirstBuild"));

            await sol.SaveAsync(Util.GetMonitor());

            var result = await sol.Clean(Util.GetMonitor(), "Debug");

            Assert.IsTrue(project.UserProperties.HasValue("FirstBuild"));
            Assert.IsTrue(project.IsFirstBuild);
            Assert.IsFalse(result.HasErrors);

            sol.Dispose();
        }
Exemple #10
0
        public void AddNewImportWithConditionToProject()
        {
            Solution sol       = TestProjectsChecks.CreateConsoleSolution("console-project-msbuild");
            var      project   = sol.GetAllProjects().First() as DotNetProject;
            string   condition = @"Exists('packages\Xamarin.Forms\build\Xamarin.Forms.targets')";

            project.AddImportIfMissing(@"packages\Xamarin.Forms\build\Xamarin.Forms.targets", condition);
            sol.Save(Util.GetMonitor());

            var doc = new XmlDocument();

            doc.Load(project.FileName);
            var manager = new XmlNamespaceManager(doc.NameTable);

            manager.AddNamespace("ms", "http://schemas.microsoft.com/developer/msbuild/2003");
            XmlElement import = (XmlElement)doc.SelectSingleNode(@"//ms:Import[@Project='packages\Xamarin.Forms\build\Xamarin.Forms.targets']", manager);

            Assert.AreEqual(condition, import.GetAttribute("Condition"));
        }
Exemple #11
0
        public void BuildConsoleProject()
        {
            var current = PropertyService.Get("MonoDevelop.Ide.BuildWithMSBuild", false);

            try {
                PropertyService.Set("MonoDevelop.Ide.BuildWithMSBuild", true);

                Solution sol = TestProjectsChecks.CreateConsoleSolution("console-project-msbuild");
                sol.Save(Util.GetMonitor());

                // Ensure the project is buildable
                var result = sol.Build(Util.GetMonitor(), "Debug");
                Assert.AreEqual(0, result.ErrorCount, "#1");

                // Ensure the project is still buildable with xbuild after a rename
                ProjectOptionsDialog.RenameItem(sol.GetAllProjects() [0], "Test");
                result = sol.Build(Util.GetMonitor(), "Release");
                Assert.AreEqual(0, result.ErrorCount, "#2");
            } finally {
                PropertyService.Set("MonoDevelop.Ide.BuildWithMSBuild", current);
            }
        }