Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
0
        public void GetItemFiles()
        {
            Solution sol = TestProjectsChecks.CreateConsoleSolution("item-files");

            List <FilePath> files = sol.GetItemFiles(false).ToList();

            Assert.AreEqual(1, files.Count);
            Assert.AreEqual(sol.FileName, files [0]);

            DotNetProject p = (DotNetProject)sol.Items [0];

            files = p.GetItemFiles(false).ToList();
            Assert.AreEqual(1, files.Count);
            Assert.AreEqual(p.FileName, files [0]);

            files = p.GetItemFiles(true).ToList();
            Assert.AreEqual(6, files.Count);
            Assert.IsTrue(files.Contains(p.FileName));
            foreach (ProjectFile pf in p.Files)
            {
                Assert.IsTrue(files.Contains(pf.FilePath), "Contains " + pf.FilePath);
            }

            files = sol.GetItemFiles(true).ToList();
            Assert.AreEqual(7, files.Count);
            Assert.IsTrue(files.Contains(sol.FileName));
            Assert.IsTrue(files.Contains(p.FileName));
            foreach (ProjectFile pf in p.Files)
            {
                Assert.IsTrue(files.Contains(pf.FilePath), "Contains " + pf.FilePath);
            }

            sol.Dispose();
        }
Exemplo n.º 3
0
        public void LoadSaveBuildConsoleProject()
        {
            string solFile = Util.GetSampleProject("csharp-console-mdp", "csharp-console-mdp.mds");

            WorkspaceItem item = Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), solFile);

            Assert.IsTrue(item is Solution);

            Solution sol = (Solution)item;

            TestProjectsChecks.CheckBasicMdConsoleProject(sol);
            string projectFile = ((Project)sol.Items [0]).FileName;

            BuildResult cr = item.Build(Util.GetMonitor(), (SolutionConfigurationSelector)"Debug");

            Assert.IsNotNull(cr);
            Assert.AreEqual(0, cr.ErrorCount);
            Assert.AreEqual(0, cr.WarningCount);

            string solXml     = Util.GetXmlFileInfoset(solFile);
            string projectXml = Util.GetXmlFileInfoset(projectFile);

            sol.Save(Util.GetMonitor());

            Assert.AreEqual(solXml, Util.GetXmlFileInfoset(solFile), "Saved solution file");
            Assert.AreEqual(projectXml, Util.GetXmlFileInfoset(projectFile), "Saved project file");
        }
Exemplo n.º 4
0
        public void LoadSaveBuildConsoleProject()
        {
            string solFile = Util.GetSampleProject("console-project", "ConsoleProject.sln");

            WorkspaceItem item = Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), solFile);

            Assert.IsTrue(item is Solution);

            Solution sol = (Solution)item;

            TestProjectsChecks.CheckBasicVsConsoleProject(sol);
            string projectFile = ((Project)sol.Items [0]).FileName;

            BuildResult cr = item.Build(Util.GetMonitor(), "Debug");

            Assert.IsNotNull(cr);
            Assert.AreEqual(0, cr.ErrorCount);
            Assert.AreEqual(0, cr.WarningCount);

            string solXml     = File.ReadAllText(solFile);
            string projectXml = Util.GetXmlFileInfoset(projectFile);

            sol.Save(Util.GetMonitor());

            Assert.AreEqual(solXml, File.ReadAllText(solFile));
            Assert.AreEqual(projectXml, Util.GetXmlFileInfoset(projectFile));
        }
Exemplo n.º 5
0
        public void CreateConsoleProject()
        {
            Solution sol = TestProjectsChecks.CreateConsoleSolution("console-project-msbuild");

            sol.ConvertToFormat(Util.FileFormatMSBuild10, true);
            sol.Save(Util.GetMonitor());

            // msbuild format

            string solXml     = File.ReadAllText(sol.FileName);
            string projectXml = Util.GetXmlFileInfoset(((SolutionEntityItem)sol.Items [0]).FileName);

            // Make sure we compare using the same guid
            Project p    = sol.Items [0] as Project;
            string  guid = p.ItemId;

            solXml     = solXml.Replace(guid, "{969F05E2-0E79-4C5B-982C-8F3DD4D46311}");
            projectXml = projectXml.Replace(guid, "{969F05E2-0E79-4C5B-982C-8F3DD4D46311}");

            string solFile     = Util.GetSampleProjectPath("generated-console-project", "TestSolution.sln");
            string projectFile = Util.GetSampleProjectPath("generated-console-project", "TestProject.csproj");

            Assert.AreEqual(Util.ToWindowsEndings(File.ReadAllText(solFile)), solXml);
            Assert.AreEqual(Util.ToWindowsEndings(Util.GetXmlFileInfoset(projectFile)), projectXml);
        }
Exemplo n.º 6
0
        public async Task Reloading()
        {
            Solution sol = TestProjectsChecks.CreateConsoleSolution("reloading");
            await sol.SaveAsync(Util.GetMonitor());

            Assert.IsFalse(sol.NeedsReload);

            Project p = sol.Items [0] as Project;

            Assert.IsFalse(p.NeedsReload);

            // Changing format must reset the reload flag (it's like we just created a new solution in memory)
            sol.ConvertToFormat(MSBuildFileFormat.VS2010);
            Assert.IsFalse(sol.NeedsReload);
            Assert.IsFalse(p.NeedsReload);
            sol.ConvertToFormat(MSBuildFileFormat.VS2012);
            Assert.IsFalse(sol.NeedsReload);
            Assert.IsFalse(p.NeedsReload);

            sol.RootFolder.Items.Remove(p);
            Assert.IsFalse(p.NeedsReload);
            p.FileFormat = MSBuildFileFormat.VS2012;
            Assert.IsFalse(p.NeedsReload);
            sol.RootFolder.Items.Add(p);
            Assert.IsFalse(p.NeedsReload);
            sol.RootFolder.Items.Remove(p);
            Assert.IsFalse(p.NeedsReload);
            p.FileFormat = MSBuildFileFormat.VS2005;
            Assert.IsFalse(p.NeedsReload);
            sol.RootFolder.Items.Add(p);
            Assert.IsFalse(p.NeedsReload);

            string   solFile2 = Util.GetSampleProject("csharp-console", "csharp-console.sln");
            Solution sol2     = (Solution)await Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), solFile2);

            Project p2 = sol2.Items [0] as Project;

            Assert.IsFalse(sol2.NeedsReload);
            Assert.IsFalse(p2.NeedsReload);

            // Check reloading flag in another solution

            string   solFile = sol.FileName;
            Solution sol3    = (Solution)await Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), solFile);

            Assert.IsFalse(sol3.NeedsReload);

            Project p3 = sol3.Items [0] as Project;

            Assert.IsFalse(p3.NeedsReload);

            System.Threading.Thread.Sleep(1000);
            sol.Description = "Foo";             // Small change to force the solution file save
            await sol.SaveAsync(Util.GetMonitor());

            Assert.IsTrue(sol3.NeedsReload);

            sol.Dispose();
        }
Exemplo n.º 7
0
        public async Task FormatConversions()
        {
            Solution sol = TestProjectsChecks.CreateConsoleSolution("reloading");
            Project  p   = (Project)sol.Items [0];

            Assert.AreEqual(MSBuildFileFormat.DefaultFormat.Id, sol.FileFormat.Id);
            Assert.AreEqual(MSBuildFileFormat.DefaultFormat.Id, p.FileFormat.Id);
            Assert.AreEqual("4.0", p.ToolsVersion);

            // Change solution format of unsaved solution

            sol.ConvertToFormat(MSBuildFileFormat.VS2008);

            Assert.AreEqual("MSBuild08", sol.FileFormat.Id);
            Assert.AreEqual("MSBuild08", p.FileFormat.Id);
            Assert.AreEqual("3.5", p.ToolsVersion);

            sol.ConvertToFormat(MSBuildFileFormat.VS2010);

            Assert.AreEqual("MSBuild10", sol.FileFormat.Id);
            Assert.AreEqual("MSBuild10", p.FileFormat.Id);
            Assert.AreEqual("4.0", p.ToolsVersion);

            // Change solution format of saved solution

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

            sol.ConvertToFormat(MSBuildFileFormat.VS2005);

            Assert.AreEqual("MSBuild05", sol.FileFormat.Id);
            Assert.AreEqual("MSBuild05", p.FileFormat.Id);
            Assert.AreEqual("2.0", p.ToolsVersion);

            // Add new project

            Project newp = Services.ProjectService.CreateDotNetProject("C#");

            Assert.AreEqual("MSBuild12", newp.FileFormat.Id);
            Assert.AreEqual("4.0", newp.ToolsVersion);

            sol.RootFolder.Items.Add(newp);
            Assert.AreEqual("MSBuild05", newp.FileFormat.Id);
            Assert.AreEqual("2.0", newp.ToolsVersion);

            // Add saved project

            string   solFile = Util.GetSampleProject("console-project", "ConsoleProject.sln");
            Solution msol    = (Solution)await Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), solFile);

            Project mp = (Project)msol.Items [0];

            Assert.AreEqual("MSBuild05", mp.FileFormat.Id);

            sol.RootFolder.Items.Add(newp);
            Assert.AreEqual("MSBuild05", mp.FileFormat.Id);

            sol.Dispose();
        }
Exemplo n.º 8
0
        public void FormatConversions()
        {
            Solution sol = TestProjectsChecks.CreateConsoleSolution("reloading");
            Project  p   = (Project)sol.Items [0];

            Assert.AreEqual(Services.ProjectService.DefaultFileFormat.Id, sol.FileFormat.Id);
            Assert.AreEqual(Services.ProjectService.DefaultFileFormat.Id, p.FileFormat.Id);
            Assert.AreEqual("4.0", MSBuildProjectService.GetHandler(p).ToolsVersion);

            // Change solution format of unsaved solution

            sol.ConvertToFormat(Util.FileFormatMSBuild08, true);

            Assert.AreEqual("MSBuild08", sol.FileFormat.Id);
            Assert.AreEqual("MSBuild08", p.FileFormat.Id);
            Assert.AreEqual("3.5", MSBuildProjectService.GetHandler(p).ToolsVersion);

            sol.ConvertToFormat(Util.FileFormatMSBuild10, true);

            Assert.AreEqual("MSBuild10", sol.FileFormat.Id);
            Assert.AreEqual("MSBuild10", p.FileFormat.Id);
            Assert.AreEqual("4.0", MSBuildProjectService.GetHandler(p).ToolsVersion);

            // Change solution format of saved solution

            sol.Save(Util.GetMonitor());

            sol.ConvertToFormat(Util.FileFormatMSBuild05, false);

            Assert.AreEqual("MSBuild05", sol.FileFormat.Id);
            Assert.AreEqual("MSBuild05", p.FileFormat.Id);
            Assert.AreEqual("2.0", MSBuildProjectService.GetHandler(p).ToolsVersion);

            // Add new project

            Project newp = new DotNetAssemblyProject("C#");

            Assert.AreEqual("MSBuild12", newp.FileFormat.Id);
            Assert.AreEqual("4.0", MSBuildProjectService.GetHandler(newp).ToolsVersion);

            sol.RootFolder.Items.Add(newp);
            Assert.AreEqual("MSBuild05", newp.FileFormat.Id);
            Assert.AreEqual("2.0", MSBuildProjectService.GetHandler(newp).ToolsVersion);

            // Add saved project

            string   solFile = Util.GetSampleProject("console-project", "ConsoleProject.sln");
            Solution msol    = (Solution)Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), solFile);

            Project mp = (Project)msol.Items [0];

            Assert.AreEqual("MSBuild05", mp.FileFormat.Id);

            sol.RootFolder.Items.Add(newp);
            Assert.AreEqual("MSBuild05", mp.FileFormat.Id);
        }
Exemplo n.º 9
0
        public void Reloading()
        {
            Solution sol = TestProjectsChecks.CreateConsoleSolution("reloading");

            sol.Save(Util.GetMonitor());
            Assert.IsFalse(sol.NeedsReload);

            Project p = sol.Items [0] as Project;

            Assert.IsFalse(p.NeedsReload);

            // Changing format must reset the reload flag (it's like we just created a new solution in memory)
            sol.ConvertToFormat(Util.FileFormatMD1, true);
            Assert.IsFalse(sol.NeedsReload);
            Assert.IsFalse(p.NeedsReload);
            sol.ConvertToFormat(Util.FileFormatMSBuild05, true);
            Assert.IsFalse(sol.NeedsReload);
            Assert.IsFalse(p.NeedsReload);

            sol.RootFolder.Items.Remove(p);
            Assert.IsFalse(p.NeedsReload);
            p.FileFormat = Util.FileFormatMD1;
            Assert.IsFalse(p.NeedsReload);
            sol.RootFolder.Items.Add(p);
            Assert.IsFalse(p.NeedsReload);
            sol.RootFolder.Items.Remove(p);
            Assert.IsFalse(p.NeedsReload);
            p.FileFormat = Util.FileFormatMSBuild05;
            Assert.IsFalse(p.NeedsReload);
            sol.RootFolder.Items.Add(p);
            Assert.IsFalse(p.NeedsReload);

            string   mdsSolFile = Util.GetSampleProject("csharp-console-mdp", "csharp-console-mdp.mds");
            Solution mdsSol     = (Solution)Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), mdsSolFile);
            Project  pmds       = mdsSol.Items [0] as Project;

            Assert.IsFalse(mdsSol.NeedsReload);
            Assert.IsFalse(pmds.NeedsReload);

            // Check reloading flag in another solution

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

            Assert.IsFalse(sol2.NeedsReload);

            Project p2 = sol2.Items [0] as Project;

            Assert.IsFalse(p2.NeedsReload);

            System.Threading.Thread.Sleep(1000);
            sol.Save(Util.GetMonitor());

            Assert.IsTrue(sol2.NeedsReload);
        }
Exemplo n.º 10
0
        public async Task BuildConsoleProject()
        {
            Solution sol = TestProjectsChecks.CreateConsoleSolution("console-project-msbuild");
            await sol.SaveAsync(Util.GetMonitor());

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

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

            sol.Dispose();
        }
Exemplo n.º 11
0
        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");
        }
Exemplo n.º 12
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();
        }
Exemplo n.º 13
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();
        }
Exemplo n.º 14
0
        public void CreateNestedSolutions()
        {
            Solution sol = TestProjectsChecks.CreateProjectWithFolders("nested-solutions-md1");

            sol.ConvertToFormat(Util.FileFormatMD1, true);

            sol.Save(Util.GetMonitor());

            string solFile  = Util.GetSampleProjectPath("nested-solutions-mdp", "nested-solutions-mdp.mds");
            string dir      = Path.GetDirectoryName(solFile);
            string solXml   = Util.GetXmlFileInfoset(solFile);
            string p1Xml    = Util.GetXmlFileInfoset(dir, "console-project", "console-project.mdp");
            string s1Xml    = Util.GetXmlFileInfoset(dir, "nested-solution1", "nested-solution1.mds");
            string s2Xml    = Util.GetXmlFileInfoset(dir, "nested-solution2", "nested-solution2.mds");
            string plib1Xml = Util.GetXmlFileInfoset(dir, "nested-solution1", "library1", "library1.mdp");
            string plib2Xml = Util.GetXmlFileInfoset(dir, "nested-solution1", "library2", "library2.mdp");
            string p2Xml    = Util.GetXmlFileInfoset(dir, "nested-solution2", "console-project2", "console-project2.mdp");
            string s3Xml    = Util.GetXmlFileInfoset(dir, "nested-solution2", "nested-solution3", "nested-solution3.mds");
            string plib3Xml = Util.GetXmlFileInfoset(dir, "nested-solution2", "nested-solution3", "library3", "library3.mdp");
            string plib4Xml = Util.GetXmlFileInfoset(dir, "nested-solution2", "nested-solution3", "library4", "library4.mdp");

            dir = Path.GetDirectoryName(sol.FileName);
            string solXml2   = Util.GetXmlFileInfoset(solFile);
            string p1Xml2    = Util.GetXmlFileInfoset(dir, "console-project", "console-project.mdp");
            string s1Xml2    = Util.GetXmlFileInfoset(dir, "nested-solution1", "nested-solution1.mds");
            string s2Xml2    = Util.GetXmlFileInfoset(dir, "nested-solution2", "nested-solution2.mds");
            string plib1Xml2 = Util.GetXmlFileInfoset(dir, "nested-solution1", "library1", "library1.mdp");
            string plib2Xml2 = Util.GetXmlFileInfoset(dir, "nested-solution1", "library2", "library2.mdp");
            string p2Xml2    = Util.GetXmlFileInfoset(dir, "nested-solution2", "console-project2", "console-project2.mdp");
            string s3Xml2    = Util.GetXmlFileInfoset(dir, "nested-solution2", "nested-solution3", "nested-solution3.mds");
            string plib3Xml2 = Util.GetXmlFileInfoset(dir, "nested-solution2", "nested-solution3", "library3", "library3.mdp");
            string plib4Xml2 = Util.GetXmlFileInfoset(dir, "nested-solution2", "nested-solution3", "library4", "library4.mdp");

            Assert.AreEqual(solXml, solXml2, "solXml");
            Assert.AreEqual(p1Xml, p1Xml2, "p1Xml");
            Assert.AreEqual(s1Xml, s1Xml2, "s1Xml");
            Assert.AreEqual(s2Xml, s2Xml2, "s2Xml");
            Assert.AreEqual(plib1Xml, plib1Xml2, "plib1Xml");
            Assert.AreEqual(plib2Xml, plib2Xml2, "plib2Xml");
            Assert.AreEqual(p2Xml, p2Xml2, "p2Xml");
            Assert.AreEqual(s3Xml, s3Xml2, "s3Xml");
            Assert.AreEqual(plib3Xml, plib3Xml2, "plib3Xml");
            Assert.AreEqual(plib4Xml, plib4Xml2, "plib4Xml");
        }
Exemplo n.º 15
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"));
        }
Exemplo n.º 16
0
        public void CreateConsoleProject()
        {
            Solution sol = TestProjectsChecks.CreateConsoleSolution("console-project-msbuild");

            sol.ConvertToFormat(Util.FileFormatMSBuild05, true);
            sol.Save(Util.GetMonitor());

            // msbuild format

            string solXml     = File.ReadAllText(sol.FileName);
            string projectXml = Util.GetXmlFileInfoset(((SolutionEntityItem)sol.Items [0]).FileName);

            // Make sure we compare using the same guid
            Project p    = sol.Items [0] as Project;
            string  guid = p.ItemId;

            solXml     = solXml.Replace(guid, "{DC577202-654B-4FDB-95C7-8CC5DDF6D32D}");
            projectXml = projectXml.Replace(guid, "{DC577202-654B-4FDB-95C7-8CC5DDF6D32D}");

            string solFile     = Util.GetSampleProjectPath("generated-console-project", "TestSolution.sln");
            string projectFile = Util.GetSampleProjectPath("generated-console-project", "TestProject.csproj");

            Assert.AreEqual(File.ReadAllText(solFile), solXml);
            Assert.AreEqual(Util.GetXmlFileInfoset(projectFile), projectXml);

            // MD1 format

            sol.ConvertToFormat(Util.FileFormatMD1, true);
            sol.Save(Util.GetMonitor());

            solXml     = Util.GetXmlFileInfoset(sol.FileName);
            projectXml = Util.GetXmlFileInfoset(((SolutionEntityItem)sol.Items [0]).FileName);

            solFile     = Util.GetSampleProjectPath("generated-console-project", "TestSolution.mds");
            projectFile = Util.GetSampleProjectPath("generated-console-project", "TestProject.mdp");

            Assert.AreEqual(Util.GetXmlFileInfoset(solFile), solXml, "solXml: " + sol.FileName);
            Assert.AreEqual(Util.GetXmlFileInfoset(projectFile), projectXml, "projectXml: " + ((SolutionEntityItem)sol.Items [0]).FileName);

//			sol.FileFormat = Services.ProjectService.FileFormats.GetFileFormat ("MSBuild08");
//			sol.Save (Util.GetMonitor ());
        }
Exemplo n.º 17
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);
        }
Exemplo n.º 18
0
 public void TestLoadSaveResources()
 {
     TestProjectsChecks.TestLoadSaveResources("MD1");
 }
Exemplo n.º 19
0
 public void TestLoadSaveResources()
 {
     TestProjectsChecks.TestLoadSaveResources("MSBuild05");
 }
Exemplo n.º 20
0
 public void TestLoadSaveSolutionFolders()
 {
     TestProjectsChecks.TestLoadSaveSolutionFolders("MSBuild05");
 }
Exemplo n.º 21
0
 public void GenericProject()
 {
     TestProjectsChecks.CheckGenericItemProject("MSBuild05");
 }
Exemplo n.º 22
0
 public void TestCreateLoadSaveConsoleProject()
 {
     TestProjectsChecks.TestCreateLoadSaveConsoleProject("MSBuild05");
 }
Exemplo n.º 23
0
        public async Task Reloading()
        {
            using (Solution sol = TestProjectsChecks.CreateConsoleSolution("reloading")) {
                await sol.SaveAsync(Util.GetMonitor());

                Assert.IsFalse(sol.NeedsReload);
                await FileWatcherService.Add(sol);

                Project p = sol.Items [0] as Project;
                Assert.IsFalse(p.NeedsReload);

                // Changing format must reset the reload flag (it's like we just created a new solution in memory)
                sol.ConvertToFormat(MSBuildFileFormat.VS2010);
                Assert.IsFalse(sol.NeedsReload);
                Assert.IsFalse(p.NeedsReload);
                sol.ConvertToFormat(MSBuildFileFormat.VS2012);
                Assert.IsFalse(sol.NeedsReload);
                Assert.IsFalse(p.NeedsReload);

                sol.RootFolder.Items.Remove(p);
                Assert.IsFalse(p.NeedsReload);
                p.FileFormat = MSBuildFileFormat.VS2012;
                Assert.IsFalse(p.NeedsReload);
                sol.RootFolder.Items.Add(p);
                Assert.IsFalse(p.NeedsReload);
                sol.RootFolder.Items.Remove(p);
                Assert.IsFalse(p.NeedsReload);
                p.FileFormat = MSBuildFileFormat.VS2005;
                Assert.IsFalse(p.NeedsReload);
                sol.RootFolder.Items.Add(p);
                Assert.IsFalse(p.NeedsReload);

                string solFile2 = Util.GetSampleProject("csharp-console", "csharp-console.sln");
                using (Solution sol2 = (Solution)await Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), solFile2)) {
                    Project p2 = sol2.Items [0] as Project;
                    Assert.IsFalse(sol2.NeedsReload);
                    Assert.IsFalse(p2.NeedsReload);
                    await FileWatcherService.Add(sol2);

                    // Check reloading flag in another solution

                    string solFile = sol.FileName;
                    using (Solution sol3 = (Solution)await Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), solFile)) {
                        Assert.IsFalse(sol3.NeedsReload);
                        await FileWatcherService.Add(sol3);

                        Project p3 = sol3.Items [0] as Project;
                        Assert.IsFalse(p3.NeedsReload);

                        System.Threading.Thread.Sleep(1000);
                        try {
                            fileChangeNotification   = new TaskCompletionSource <bool> ();
                            waitForFileChange        = sol.FileName;
                            FileService.FileChanged += OnFileChanged;
                            sol.Description          = "Foo";                    // Small change to force the solution file save
                            await sol.SaveAsync(Util.GetMonitor());

                            // we need to wait for the file notification to be posted
                            await Task.Run(() => {
                                fileChangeNotification.Task.Wait(TimeSpan.FromMilliseconds(10000));
                            });

                            Assert.IsTrue(fileChangeNotification.Task.IsCompleted);
                        } finally {
                            FileService.FileChanged -= OnFileChanged;
                        }

                        Assert.IsTrue(sol3.NeedsReload);
                    }
                }
            }
        }
Exemplo n.º 24
0
 public void GenericProject()
 {
     TestProjectsChecks.CheckGenericItemProject("MD1");
 }
Exemplo n.º 25
0
        public async Task SaveSharedProject()
        {
            Solution sol = TestProjectsChecks.CreateConsoleSolution("shared-project");

            sol.ConvertToFormat(MSBuildFileFormat.VS2012);
            await sol.SaveAsync(Util.GetMonitor());

            var pc = (DotNetProject)sol.Items [0];

            // Add shared project

            var sp = new SharedAssetsProject()
            {
                LanguageName     = "C#",
                DefaultNamespace = "TestNamespace"
            };

            sp.AddFile(sol.ItemDirectory.Combine("Test.cs"));
            await sp.SaveAsync(Util.GetMonitor(), sol.ItemDirectory.Combine("Shared"));

            sol.RootFolder.AddItem(sp);
            await sol.SaveAsync(Util.GetMonitor());

            // Make sure we compare using the same guid

            string solXml                = File.ReadAllText(sol.FileName).Replace(pc.ItemId, "{7DE4B613-BAB6-49DE-83FA-707D4E120306}").Replace(sp.ItemId, "{8DD793BE-42C3-4D66-8359-460CEE75980D}");
            string projectXml            = Util.GetXmlFileInfoset(pc.FileName).Replace(pc.ItemId, "{7DE4B613-BAB6-49DE-83FA-707D4E120306}");
            string sharedProjectXml      = Util.GetXmlFileInfoset(sp.FileName).Replace(sp.ItemId, "{8DD793BE-42C3-4D66-8359-460CEE75980D}");
            string sharedProjectItemsXml = Util.GetXmlFileInfoset(sp.FileName.ChangeExtension(".projitems")).Replace(sp.ItemId, "{8DD793BE-42C3-4D66-8359-460CEE75980D}");

            string refSolXml                = Util.ToWindowsEndings(File.ReadAllText(Util.GetSampleProjectPath("generated-shared-project", "TestSolution.sln")));
            string refProjectXml            = Util.ToWindowsEndings(Util.GetXmlFileInfoset(Util.GetSampleProjectPath("generated-shared-project", "TestProject.csproj")));
            string refSharedProjectXml      = Util.ToWindowsEndings(Util.GetXmlFileInfoset(Util.GetSampleProjectPath("generated-shared-project", "Shared.shproj")));
            string refSharedProjectItemsXml = Util.ToWindowsEndings(Util.GetXmlFileInfoset(Util.GetSampleProjectPath("generated-shared-project", "Shared.projitems")));

            Assert.AreEqual(refSolXml, solXml);
            Assert.AreEqual(refProjectXml, projectXml);
            Assert.AreEqual(refSharedProjectXml, sharedProjectXml);
            Assert.AreEqual(refSharedProjectItemsXml, sharedProjectItemsXml);

            // Add a reference

            var r = ProjectReference.CreateProjectReference(sp);

            pc.References.Add(r);
            await sol.SaveAsync(Util.GetMonitor());

            solXml                = File.ReadAllText(sol.FileName).Replace(pc.ItemId, "{7DE4B613-BAB6-49DE-83FA-707D4E120306}").Replace(sp.ItemId, "{8DD793BE-42C3-4D66-8359-460CEE75980D}");
            projectXml            = Util.GetXmlFileInfoset(pc.FileName).Replace(pc.ItemId, "{7DE4B613-BAB6-49DE-83FA-707D4E120306}");
            sharedProjectXml      = Util.GetXmlFileInfoset(sp.FileName).Replace(sp.ItemId, "{8DD793BE-42C3-4D66-8359-460CEE75980D}");
            sharedProjectItemsXml = Util.GetXmlFileInfoset(sp.FileName.ChangeExtension(".projitems")).Replace(sp.ItemId, "{8DD793BE-42C3-4D66-8359-460CEE75980D}");

            refProjectXml = Util.ToWindowsEndings(Util.GetXmlFileInfoset(Util.GetSampleProjectPath("generated-shared-project", "TestProject.csproj.saved1")));

            Assert.AreEqual(refSolXml, solXml);
            Assert.AreEqual(refProjectXml, projectXml);
            Assert.AreEqual(refSharedProjectXml, sharedProjectXml);
            Assert.AreEqual(refSharedProjectItemsXml, sharedProjectItemsXml);

            // Add a file and change the default namespace

            sp.DefaultNamespace = "TestNamespace2";
            var file = sp.AddFile(sol.ItemDirectory.Combine("Test2.cs"));
            await sol.SaveAsync(Util.GetMonitor());

            solXml                = File.ReadAllText(sol.FileName).Replace(pc.ItemId, "{7DE4B613-BAB6-49DE-83FA-707D4E120306}").Replace(sp.ItemId, "{8DD793BE-42C3-4D66-8359-460CEE75980D}");
            projectXml            = Util.GetXmlFileInfoset(pc.FileName).Replace(pc.ItemId, "{7DE4B613-BAB6-49DE-83FA-707D4E120306}");
            sharedProjectXml      = Util.GetXmlFileInfoset(sp.FileName).Replace(sp.ItemId, "{8DD793BE-42C3-4D66-8359-460CEE75980D}");
            sharedProjectItemsXml = Util.GetXmlFileInfoset(sp.FileName.ChangeExtension(".projitems")).Replace(sp.ItemId, "{8DD793BE-42C3-4D66-8359-460CEE75980D}");

            refSharedProjectItemsXml = Util.ToWindowsEndings(Util.GetXmlFileInfoset(Util.GetSampleProjectPath("generated-shared-project", "Shared.projitems.saved1")));

            Assert.AreEqual(refSolXml, solXml);
            Assert.AreEqual(refProjectXml, projectXml);
            Assert.AreEqual(refSharedProjectXml, sharedProjectXml);
            Assert.AreEqual(refSharedProjectItemsXml, sharedProjectItemsXml);

            // Remove a file and restore the namespace

            sp.DefaultNamespace = "TestNamespace";
            sp.Files.Remove(file);
            await sol.SaveAsync(Util.GetMonitor());

            solXml                = File.ReadAllText(sol.FileName).Replace(pc.ItemId, "{7DE4B613-BAB6-49DE-83FA-707D4E120306}").Replace(sp.ItemId, "{8DD793BE-42C3-4D66-8359-460CEE75980D}");
            projectXml            = Util.GetXmlFileInfoset(pc.FileName).Replace(pc.ItemId, "{7DE4B613-BAB6-49DE-83FA-707D4E120306}");
            sharedProjectXml      = Util.GetXmlFileInfoset(sp.FileName).Replace(sp.ItemId, "{8DD793BE-42C3-4D66-8359-460CEE75980D}");
            sharedProjectItemsXml = Util.GetXmlFileInfoset(sp.FileName.ChangeExtension(".projitems")).Replace(sp.ItemId, "{8DD793BE-42C3-4D66-8359-460CEE75980D}");

            refSharedProjectItemsXml = Util.ToWindowsEndings(Util.GetXmlFileInfoset(Util.GetSampleProjectPath("generated-shared-project", "Shared.projitems")));

            Assert.AreEqual(refSolXml, solXml);
            Assert.AreEqual(refProjectXml, projectXml);
            Assert.AreEqual(refSharedProjectXml, sharedProjectXml);
            Assert.AreEqual(refSharedProjectItemsXml, sharedProjectItemsXml);

            // Remove reference

            pc.References.Remove(r);
            await sol.SaveAsync(Util.GetMonitor());

            solXml                = File.ReadAllText(sol.FileName).Replace(pc.ItemId, "{7DE4B613-BAB6-49DE-83FA-707D4E120306}").Replace(sp.ItemId, "{8DD793BE-42C3-4D66-8359-460CEE75980D}");
            projectXml            = Util.GetXmlFileInfoset(pc.FileName).Replace(pc.ItemId, "{7DE4B613-BAB6-49DE-83FA-707D4E120306}");
            sharedProjectXml      = Util.GetXmlFileInfoset(sp.FileName).Replace(sp.ItemId, "{8DD793BE-42C3-4D66-8359-460CEE75980D}");
            sharedProjectItemsXml = Util.GetXmlFileInfoset(sp.FileName.ChangeExtension(".projitems")).Replace(sp.ItemId, "{8DD793BE-42C3-4D66-8359-460CEE75980D}");

            refProjectXml = Util.ToWindowsEndings(Util.GetXmlFileInfoset(Util.GetSampleProjectPath("generated-shared-project", "TestProject.csproj")));

            Assert.AreEqual(refSolXml, solXml);
            Assert.AreEqual(refProjectXml, projectXml);
            Assert.AreEqual(refSharedProjectXml, sharedProjectXml);
            Assert.AreEqual(refSharedProjectItemsXml, sharedProjectItemsXml);

            sol.Dispose();
        }