示例#1
0
        public async Task NeedsBuilding()
        {
            string solFile = Util.GetSampleProject("console-with-libs", "console-with-libs.sln");

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

            DotNetProject p = (DotNetProject)sol.FindProjectByName("console-with-libs");

            Assert.IsNotNull(p);
            DotNetProject lib1 = (DotNetProject)sol.FindProjectByName("library1");

            Assert.IsNotNull(lib1);
            DotNetProject lib2 = (DotNetProject)sol.FindProjectByName("library2");

            Assert.IsNotNull(lib2);

            SolutionConfigurationSelector config = (SolutionConfigurationSelector)"Debug";

#pragma warning disable 618
            Assert.IsTrue(p.NeedsBuilding(config));
            Assert.IsTrue(lib1.NeedsBuilding(config));
            Assert.IsTrue(lib2.NeedsBuilding(config));
#pragma warning restore 618

            // Build the project and the references

            BuildResult res = await p.Build(Util.GetMonitor(), config, true);

            foreach (BuildError er in res.Errors)
            {
                Console.WriteLine(er);
            }
            Assert.AreEqual(0, res.ErrorCount);
            Assert.AreEqual(0, res.WarningCount);
            Assert.AreEqual(3, res.BuildCount);

            Assert.IsTrue(File.Exists(Util.Combine(p.BaseDirectory, "bin", "Debug", "console-with-libs.exe")));
            Assert.IsTrue(File.Exists(Util.Combine(p.BaseDirectory, "bin", "Debug", GetMdb(p, "console-with-libs.exe"))));
            Assert.IsTrue(File.Exists(Util.Combine(lib1.BaseDirectory, "bin", "Debug", "library1.dll")));
            Assert.IsTrue(File.Exists(Util.Combine(lib1.BaseDirectory, "bin", "Debug", GetMdb(lib1, "library1.dll"))));
            Assert.IsTrue(File.Exists(Util.Combine(lib2.BaseDirectory, "bin", "Debug", "library2.dll")));
            Assert.IsTrue(File.Exists(Util.Combine(lib2.BaseDirectory, "bin", "Debug", GetMdb(lib2, "library2.dll"))));

            // Build the project, but not the references

            res = await p.Build(Util.GetMonitor(), config, false);

            Assert.AreEqual(0, res.ErrorCount);
            Assert.AreEqual(0, res.WarningCount);
            Assert.AreEqual(1, res.BuildCount);

            sol.Dispose();
        }
示例#2
0
        async Task CheckProjectReferencesBuildClean(Solution sol, string configuration)
        {
            SolutionConfigurationSelector config = (SolutionConfigurationSelector)configuration;
            string        tag  = "CheckProjectReferencesBuildClean config=" + configuration;
            DotNetProject lib1 = (DotNetProject)sol.FindProjectByName("Lib1");
            DotNetProject lib2 = (DotNetProject)sol.FindProjectByName("Lib2");
            DotNetProject lib3 = (DotNetProject)sol.FindProjectByName("Lib3");
            DotNetProject lib4 = (DotNetProject)sol.FindProjectByName("Lib4");

            Assert.IsFalse(File.Exists(lib1.GetOutputFileName(config)), tag);
            Assert.IsFalse(File.Exists(lib2.GetOutputFileName(config)), tag);
            Assert.IsFalse(File.Exists(lib3.GetOutputFileName(config)), tag);
            Assert.IsFalse(File.Exists(lib4.GetOutputFileName(config)), tag);

            BuildResult res = await lib1.Build(Util.GetMonitor(), config, true);

            Assert.AreEqual(0, res.WarningCount, tag);
            Assert.AreEqual(0, res.ErrorCount, tag + " " + res.CompilerOutput);

            Assert.IsTrue(File.Exists(lib1.GetOutputFileName(config)), tag);
            Assert.IsTrue(File.Exists(lib2.GetOutputFileName(config)), tag);
            Assert.IsTrue(File.Exists(lib3.GetOutputFileName(config)), tag);
            Assert.IsTrue(File.Exists(lib4.GetOutputFileName(config)), tag);

            await sol.Clean(Util.GetMonitor(), config);
        }
		void CheckProjectBuildClean (DotNetProject lib, string configuration)
		{
			SolutionConfigurationSelector config = (SolutionConfigurationSelector) configuration;
			string tag = "CheckProjectBuildClean lib=" + lib.Name + " config=" + configuration;
			
			Assert.IsFalse (File.Exists (lib.GetOutputFileName (config)), tag);
			
			BuildResult res = lib.Build (Util.GetMonitor (), config, false);
			Assert.AreEqual (0, res.WarningCount, tag);
			Assert.AreEqual (0, res.ErrorCount, tag);
			
			Assert.IsTrue (File.Exists (lib.GetOutputFileName (config)), tag);
			
			lib.Clean (Util.GetMonitor (), config);
			Assert.IsFalse (File.Exists (lib.GetOutputFileName (config)), tag);
		}
示例#4
0
		void CheckProjectBuildClean (DotNetProject lib, string configuration)
		{
			SolutionConfigurationSelector config = (SolutionConfigurationSelector) configuration;
			string tag = "CheckProjectBuildClean lib=" + lib.Name + " config=" + configuration;
			
			Assert.IsFalse (File.Exists (lib.GetOutputFileName (config)), tag);
			
			BuildResult res = lib.Build (Util.GetMonitor (), config, false);
			Assert.AreEqual (0, res.WarningCount, tag);
			Assert.AreEqual (0, res.ErrorCount, tag);
			
			Assert.IsTrue (File.Exists (lib.GetOutputFileName (config)), tag);
			
			lib.Clean (Util.GetMonitor (), config);
			Assert.IsFalse (File.Exists (lib.GetOutputFileName (config)), tag);
		}