void 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 = 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); sol.Clean(Util.GetMonitor(), config); }
async Task CheckSolutionBuildClean(Solution sol, string configuration) { SolutionConfigurationSelector config = (SolutionConfigurationSelector)configuration; string tag = "CheckSolutionBuildClean 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 sol.Build(Util.GetMonitor(), config); Assert.AreEqual(0, res.WarningCount, tag); Assert.AreEqual(0, res.ErrorCount, tag); 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); 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); }
public async Task Resources() { string solFile = Util.GetSampleProject("resources-tester", "ResourcesTester.sln"); Solution sol = (Solution)await Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), solFile); CheckResourcesSolution(sol); BuildResult res = await sol.Build(Util.GetMonitor(), "Debug"); Assert.AreEqual(0, res.ErrorCount); Assert.AreEqual(0, res.WarningCount); Assert.AreEqual(1, res.BuildCount); string spath = Util.Combine(sol.BaseDirectory, "ResourcesTester", "bin", "Debug", "ca", "ResourcesTesterApp.resources.dll"); Assert.IsTrue(File.Exists(spath), "Satellite assembly not generated"); await sol.Clean(Util.GetMonitor(), "Debug"); Assert.IsFalse(File.Exists(spath), "Satellite assembly not removed"); // msbuild doesn't delete this directory // Assert.IsFalse (Directory.Exists (Path.GetDirectoryName (spath)), "Satellite assembly directory not removed"); sol.Dispose(); }
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(); }
public async Task BuildingAndCleaning() { 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"); DotNetProject lib1 = (DotNetProject)sol.FindProjectByName("library1"); DotNetProject lib2 = (DotNetProject)sol.FindProjectByName("library2"); SolutionFolder folder = new SolutionFolder(); folder.Name = "subfolder"; sol.RootFolder.Items.Add(folder); sol.RootFolder.Items.Remove(lib2); folder.Items.Add(lib2); Workspace ws = new Workspace(); ws.FileName = Path.Combine(sol.BaseDirectory, "workspace"); ws.Items.Add(sol); await ws.SaveAsync(Util.GetMonitor()); // Build the project and the references BuildResult res = await ws.Build(Util.GetMonitor(), ConfigurationSelector.Default); 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")))); // Clean the workspace await ws.Clean(Util.GetMonitor(), ConfigurationSelector.Default); Assert.IsFalse(File.Exists(Util.Combine(p.BaseDirectory, "bin", "Debug", "console-with-libs.exe"))); Assert.IsFalse(File.Exists(Util.Combine(p.BaseDirectory, "bin", "Debug", GetMdb(p, "console-with-libs.exe")))); Assert.IsFalse(File.Exists(Util.Combine(lib1.BaseDirectory, "bin", "Debug", "library1.dll"))); Assert.IsFalse(File.Exists(Util.Combine(lib1.BaseDirectory, "bin", "Debug", GetMdb(lib1, "library1.dll")))); Assert.IsFalse(File.Exists(Util.Combine(lib2.BaseDirectory, "bin", "Debug", "library2.dll"))); Assert.IsFalse(File.Exists(Util.Combine(lib2.BaseDirectory, "bin", "Debug", GetMdb(lib2, "library2.dll")))); // Build the solution res = await ws.Build(Util.GetMonitor(), ConfigurationSelector.Default); 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")))); // Clean the solution await sol.Clean(Util.GetMonitor(), "Debug"); Assert.IsFalse(File.Exists(Util.Combine(p.BaseDirectory, "bin", "Debug", "console-with-libs.exe"))); Assert.IsFalse(File.Exists(Util.Combine(p.BaseDirectory, "bin", "Debug", GetMdb(p, "console-with-libs.exe")))); Assert.IsFalse(File.Exists(Util.Combine(lib1.BaseDirectory, "bin", "Debug", "library1.dll"))); Assert.IsFalse(File.Exists(Util.Combine(lib1.BaseDirectory, "bin", "Debug", GetMdb(lib1, "library1.dll")))); Assert.IsFalse(File.Exists(Util.Combine(lib2.BaseDirectory, "bin", "Debug", "library2.dll"))); Assert.IsFalse(File.Exists(Util.Combine(lib2.BaseDirectory, "bin", "Debug", GetMdb(lib2, "library2.dll")))); // Build the solution folder res = await folder.Build(Util.GetMonitor(), (SolutionConfigurationSelector)"Debug"); Assert.AreEqual(0, res.ErrorCount); Assert.AreEqual(0, res.WarningCount); Assert.AreEqual(1, res.BuildCount); Assert.IsFalse(File.Exists(Util.Combine(p.BaseDirectory, "bin", "Debug", "console-with-libs.exe"))); Assert.IsFalse(File.Exists(Util.Combine(p.BaseDirectory, "bin", "Debug", GetMdb(p, "console-with-libs.exe")))); Assert.IsFalse(File.Exists(Util.Combine(lib1.BaseDirectory, "bin", "Debug", "library1.dll"))); Assert.IsFalse(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")))); // Clean the solution folder await folder.Clean(Util.GetMonitor(), (SolutionConfigurationSelector)"Debug"); Assert.IsFalse(File.Exists(Util.Combine(lib2.BaseDirectory, "bin", "Debug", "library2.dll"))); Assert.IsFalse(File.Exists(Util.Combine(lib2.BaseDirectory, "bin", "Debug", GetMdb(lib2, "library2.dll")))); sol.Dispose(); }