Dispose() public method

public Dispose ( ) : void
return void
Ejemplo n.º 1
0
        public async Task TestConfigurationMergingChangeMergeToParent4()
        {
            string        projectFile = Util.GetSampleProject("test-configuration-merging", "TestConfigurationMerging9.csproj");
            DotNetProject p           = await Services.ProjectService.ReadSolutionItem(Util.GetMonitor(), projectFile) as DotNetProject;

            Assert.IsNotNull(p);

            DotNetProjectConfiguration conf = p.Configurations ["Debug|x86"] as DotNetProjectConfiguration;

            Assert.IsNotNull(conf);
            Assert.IsFalse(conf.SignAssembly);
            conf.SignAssembly = true;

            // Release config already has SignAssembly=true, so the property should be merged to main group

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

            Assert.AreEqual(Util.ToSystemEndings(File.ReadAllText(p.FileName + ".saved")), File.ReadAllText(p.FileName));

            conf.SignAssembly = false;

            // Release config still has SignAssembly=true, so the property should be removed from the main group and
            // assigned to true in Release configuration.

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

            Assert.AreEqual(Util.ToSystemEndings(File.ReadAllText(p.FileName + ".saved2")), File.ReadAllText(p.FileName));

            p.Dispose();
        }
Ejemplo n.º 2
0
        public async Task ProjectUsingMultipleSdk()
        {
            // A project that references two SDKs must be assigned an SDKs folder that contains both SDKs

            string sdkPath1 = Util.GetSampleProjectPath("msbuild-search-paths", "sdk-path");
            string sdkPath2 = Util.GetSampleProjectPath("msbuild-search-paths", "sdk-path-2");
            string sdkPath3 = Util.GetSampleProjectPath("msbuild-search-paths", "sdk-path-all");

            try {
                MonoDevelop.Projects.MSBuild.MSBuildProjectService.RegisterProjectImportSearchPath("MSBuildSDKsPath", sdkPath1);
                MonoDevelop.Projects.MSBuild.MSBuildProjectService.RegisterProjectImportSearchPath("MSBuildSDKsPath", sdkPath2);
                MonoDevelop.Projects.MSBuild.MSBuildProjectService.RegisterProjectImportSearchPath("MSBuildSDKsPath", sdkPath3);

                string        projectFile = Util.GetSampleProject("msbuild-search-paths", "ProjectUsingMultiSdk.csproj");
                DotNetProject p           = await Services.ProjectService.ReadSolutionItem(Util.GetMonitor(), projectFile) as DotNetProject;

                var res = await p.RunTarget(Util.GetMonitor(false), "SdkTarget", p.Configurations [0].Selector);

                Assert.AreEqual(1, res.BuildResult.WarningCount);
                Assert.AreEqual("Works!", res.BuildResult.Errors [0].ErrorText);
                Assert.AreEqual("Works!", p.MSBuildProject.EvaluatedProperties.GetValue("SdkProp"));

                res = await p.RunTarget(Util.GetMonitor(false), "BarTarget", p.Configurations [0].Selector);

                Assert.AreEqual(1, res.BuildResult.WarningCount);
                Assert.AreEqual("Works!", res.BuildResult.Errors [0].ErrorText);
                Assert.AreEqual("Works!", p.MSBuildProject.EvaluatedProperties.GetValue("BarProp"));
                p.Dispose();
            } finally {
                MonoDevelop.Projects.MSBuild.MSBuildProjectService.UnregisterProjectImportSearchPath("MSBuildSDKsPath", sdkPath1);
                MonoDevelop.Projects.MSBuild.MSBuildProjectService.UnregisterProjectImportSearchPath("MSBuildSDKsPath", sdkPath2);
                MonoDevelop.Projects.MSBuild.MSBuildProjectService.UnregisterProjectImportSearchPath("MSBuildSDKsPath", sdkPath3);
            }
        }
Ejemplo n.º 3
0
        public async Task TestConfigurationMergingKeepOldConfig()
        {
            string        projectFile = Util.GetSampleProject("test-configuration-merging", "TestConfigurationMerging4.csproj");
            DotNetProject p           = await Services.ProjectService.ReadSolutionItem(Util.GetMonitor(), projectFile) as DotNetProject;

            Assert.IsNotNull(p);

            DotNetProjectConfiguration conf = p.Configurations ["Debug|x86"] as DotNetProjectConfiguration;

            Assert.IsNotNull(conf);
            Assert.IsTrue(conf.DebugSymbols);
            dynamic cparams = conf.CompilationParameters;

            Assert.IsTrue(cparams.UnsafeCode);

            conf = p.Configurations ["Release|x86"] as DotNetProjectConfiguration;
            Assert.IsNotNull(conf);
            Assert.IsFalse(conf.DebugSymbols);
            conf.DebugSymbols = true;
            cparams           = conf.CompilationParameters;
            Assert.IsFalse(cparams.UnsafeCode);
            cparams.UnsafeCode = true;

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

            Assert.AreEqual(Util.ToSystemEndings(File.ReadAllText(p.FileName + ".saved")), File.ReadAllText(p.FileName));

            p.Dispose();
        }
Ejemplo n.º 4
0
        public async Task LoadRunConfigurationFromProjectProperties()
        {
            string        solFile = Util.GetSampleProject("run-configurations", "ConsoleProject", "ConsoleProject.default-console.csproj");
            DotNetProject p       = (DotNetProject)await Services.ProjectService.ReadSolutionItem(Util.GetMonitor(), solFile);

            Assert.AreEqual(1, p.RunConfigurations.Count);

            var es = p.RunConfigurations [0] as ProcessRunConfiguration;

            Assert.IsNotNull(es);
            Assert.IsTrue(es.ExternalConsole);

            var newConf = (ProcessRunConfiguration)p.CreateRunConfiguration("Extra");

            newConf.StartArguments = "a";
            p.RunConfigurations.Add(newConf);
            Assert.IsTrue(newConf.ExternalConsole);
            Assert.AreEqual("a", newConf.StartArguments);

            var newConf2 = (ProcessRunConfiguration)p.CreateRunConfiguration("Extra2");

            newConf2.ExternalConsole = false;
            p.RunConfigurations.Add(newConf2);
            Assert.IsFalse(newConf2.ExternalConsole);

            p.Dispose();
        }
Ejemplo n.º 5
0
        public async Task SaveLoadedRunConfigurationFromProjectProperties()
        {
            string        solFile = Util.GetSampleProject("run-configurations", "ConsoleProject", "ConsoleProject.default-console.csproj");
            DotNetProject p       = (DotNetProject)await Services.ProjectService.ReadSolutionItem(Util.GetMonitor(), solFile);

            Assert.AreEqual(1, p.RunConfigurations.Count);

            var es = p.RunConfigurations [0] as ProcessRunConfiguration;

            Assert.IsNotNull(es);
            Assert.IsTrue(es.ExternalConsole);

            var newConf = (ProcessRunConfiguration)p.CreateRunConfiguration("Extra");

            p.RunConfigurations.Add(newConf);
            Assert.IsTrue(newConf.ExternalConsole);

            string projectXml = File.ReadAllText(p.FileName);

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

            string newProjectXml = File.ReadAllText(p.FileName);

            Assert.AreEqual(newProjectXml, projectXml);

            Assert.IsTrue(File.Exists(p.FileName + ".user"));

            string projUserFile = Util.GetSampleProject("run-configurations", "ConsoleProject", "ConsoleProject.default-console-saved.csproj.user");

            projectXml    = File.ReadAllText(p.FileName + ".user");
            newProjectXml = File.ReadAllText(projUserFile);
            Assert.AreEqual(newProjectXml, projectXml);

            p.Dispose();
        }
Ejemplo n.º 6
0
        public async Task ResetDefaultRunConfiguration()
        {
            string        solFile = Util.GetSampleProject("run-configurations", "ConsoleProject", "ConsoleProject.default-modified.csproj");
            DotNetProject p       = (DotNetProject)await Services.ProjectService.ReadSolutionItem(Util.GetMonitor(), solFile);

            Assert.AreEqual(1, p.RunConfigurations.Count);

            var es = p.RunConfigurations [0];

            Assert.AreEqual("Default", es.Name);
            Assert.AreEqual("Time", es.Properties.GetValue("SomeValue"));
            es.Properties.RemoveProperty("SomeValue");

            string projectXml = File.ReadAllText(p.FileName);

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

            string newProjectXml = File.ReadAllText(p.FileName);

            Assert.AreEqual(newProjectXml, projectXml);

            Assert.IsFalse(File.Exists(p.FileName + ".user"));

            p.Dispose();
        }
Ejemplo n.º 7
0
        public async Task SwitchUserRunConfigurations()
        {
            string        projFile = Util.GetSampleProject("run-configurations", "ConsoleProject", "ConsoleProject.configs-user-added.csproj");
            DotNetProject p        = (DotNetProject)await Services.ProjectService.ReadSolutionItem(Util.GetMonitor(), projFile);

            Assert.AreEqual(3, p.RunConfigurations.Count);

            var es = p.RunConfigurations [1];

            es.StoreInUserFile = true;

            es = p.RunConfigurations [2];
            es.StoreInUserFile = false;

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

            string projectXml    = File.ReadAllText(p.FileName);
            string newProjectXml = File.ReadAllText(p.FileName.ChangeName("ConsoleProject.configs-user-switched"));

            Assert.AreEqual(newProjectXml, projectXml);

            Assert.IsTrue(File.Exists(p.FileName + ".user"));

            projectXml    = File.ReadAllText(p.FileName + ".user");
            newProjectXml = File.ReadAllText(p.FileName.ChangeName("ConsoleProject.configs-user-switched") + ".user");
            Assert.AreEqual(newProjectXml, projectXml);

            p.Dispose();
        }
Ejemplo n.º 8
0
        public void CustomCommands()
        {
            DotNetProject p = Services.ProjectService.CreateDotNetProject("C#");

            p.Name = "SomeProject";
            DotNetProjectConfiguration c = (DotNetProjectConfiguration)p.CreateConfiguration("First");

            CustomCommand cmd = new CustomCommand();

            cmd.Command = "aa bb cc";
            Assert.AreEqual("aa", cmd.GetCommandFile(p, c.Selector));
            Assert.AreEqual("bb cc", cmd.GetCommandArgs(p, c.Selector));

            cmd.Command = "\"aa bb\" cc dd";
            Assert.AreEqual("aa bb", cmd.GetCommandFile(p, c.Selector));
            Assert.AreEqual("cc dd", cmd.GetCommandArgs(p, c.Selector));

            cmd.Command = "\"aa ${ProjectName}\" cc ${ProjectName}";
            Assert.AreEqual("aa SomeProject", cmd.GetCommandFile(p, c.Selector));
            Assert.AreEqual("cc SomeProject", cmd.GetCommandArgs(p, c.Selector));

            cmd.WorkingDir = NormalizePath("/some/${ProjectName}/place");
            Assert.AreEqual(Path.GetFullPath(NormalizePath("/some/SomeProject/place")), (string)cmd.GetCommandWorkingDir(p, c.Selector));
            p.Dispose();
        }
Ejemplo n.º 9
0
        public void ProjectFilePaths()
        {
            DotNetProject project = Services.ProjectService.CreateDotNetProject("C#");
            string        dir     = Environment.CurrentDirectory;

            ProjectFile file1 = project.AddFile(Util.Combine(dir, "test1.cs"), BuildAction.Compile);

            Assert.AreEqual(Util.Combine(dir, "test1.cs"), file1.Name);

            ProjectFile file2 = project.AddFile(Util.Combine(dir, "aaa", "..", "bbb", "test2.cs"), BuildAction.Compile);

            Assert.AreEqual(Util.Combine(dir, "bbb", "test2.cs"), file2.Name);

            ProjectFile file = project.Files.GetFile(Util.Combine(dir, "test1.cs"));

            Assert.AreEqual(file1, file);

            file = project.Files.GetFile(Util.Combine(dir, "aaa", "..", "test1.cs"));
            Assert.AreEqual(file1, file);

            file = project.Files.GetFile(Util.Combine(dir, "bbb", "test2.cs"));
            Assert.AreEqual(file2, file);

            file = project.Files.GetFile(Util.Combine(dir, "aaa", "..", "bbb", "test2.cs"));
            Assert.AreEqual(file2, file);

            project.Dispose();
        }
Ejemplo n.º 10
0
        public void NewConfigurationsHaveAnAssemblyName()
        {
            DotNetProject p = Services.ProjectService.CreateDotNetProject("C#");

            p.Name = "HiThere";
            DotNetProjectConfiguration c = (DotNetProjectConfiguration)p.CreateConfiguration("First");

            Assert.AreEqual("HiThere", c.OutputAssembly);
            p.Dispose();
        }
Ejemplo n.º 11
0
        public async Task CustomTarget()
        {
            try {
                RegisterSearchPath();
                string        projectFile = Util.GetSampleProject("msbuild-search-paths", "ConsoleProject.csproj");
                DotNetProject p           = await Services.ProjectService.ReadSolutionItem(Util.GetMonitor(), projectFile) as DotNetProject;

                Assert.AreEqual("Works!", p.MSBuildProject.EvaluatedProperties.GetValue("TestTarget"));
                p.Dispose();
            } finally {
                UnregisterSearchPath();
            }
        }
Ejemplo n.º 12
0
        public async Task TestConfigurationMergingChangeMergeToParent3()
        {
            string        projectFile = Util.GetSampleProject("test-configuration-merging", "TestConfigurationMerging8.csproj");
            DotNetProject p           = await Services.ProjectService.ReadSolutionItem(Util.GetMonitor(), projectFile) as DotNetProject;

            Assert.IsNotNull(p);

            var refXml = File.ReadAllText(p.FileName);
            await p.SaveAsync(Util.GetMonitor());

            Assert.AreEqual(refXml, File.ReadAllText(p.FileName));

            p.Dispose();
        }
Ejemplo n.º 13
0
        public async Task EnvVarsInConfigurationAreParsed()
        {
            string        solFile = Util.GetSampleProject("run-configurations", "ConsoleProject", "ConsoleProject.default-console.csproj");
            DotNetProject p       = (DotNetProject)await Services.ProjectService.ReadSolutionItem(Util.GetMonitor(), solFile);

            var rc   = (DotNetProjectRunConfiguration)p.RunConfigurations.FirstOrDefault();
            var conf = (DotNetProjectConfiguration)p.Configurations [0];

            rc.EnvironmentVariables.Add("abc", "${TargetDir}");
            var cmd = (DotNetExecutionCommand)p.CreateExecutionCommand(conf.Selector, conf, rc);

            Assert.AreEqual(conf.OutputDirectory.ToString(), cmd.EnvironmentVariables["abc"]);

            p.Dispose();
        }
Ejemplo n.º 14
0
        public async Task MultipleProjectsUsingSdk()
        {
            string sdkPath1 = Util.GetSampleProjectPath("msbuild-search-paths", "sdk-path");
            string sdkPath2 = Util.GetSampleProjectPath("msbuild-search-paths", "sdk-path-2");

            try {
                MonoDevelop.Projects.MSBuild.MSBuildProjectService.RegisterProjectImportSearchPath("MSBuildSDKsPath", sdkPath1);
                MonoDevelop.Projects.MSBuild.MSBuildProjectService.RegisterProjectImportSearchPath("MSBuildSDKsPath", sdkPath2);

                // Load and run the first project

                string        projectFile = Util.GetSampleProject("msbuild-search-paths", "ProjectUsingSdk.csproj");
                DotNetProject p1          = await Services.ProjectService.ReadSolutionItem(Util.GetMonitor(), projectFile) as DotNetProject;

                Assert.AreEqual("Works!", p1.MSBuildProject.EvaluatedProperties.GetValue("SdkProp"));

                var res = await p1.RunTarget(Util.GetMonitor(false), "SdkTarget", p1.Configurations [0].Selector);

                Assert.AreEqual(0, res.BuildResult.ErrorCount, res.BuildResult.Errors.FirstOrDefault()?.ToString());
                Assert.AreEqual(1, res.BuildResult.WarningCount);
                Assert.AreEqual("Works!", res.BuildResult.Errors [0].ErrorText);

                // Load and run the second project

                projectFile = Util.GetSampleProject("msbuild-search-paths", "ProjectUsingSdk2.csproj");
                DotNetProject p2 = await Services.ProjectService.ReadSolutionItem(Util.GetMonitor(), projectFile) as DotNetProject;

                Assert.AreEqual("Works!", p2.MSBuildProject.EvaluatedProperties.GetValue("BarProp"));

                res = await p2.RunTarget(Util.GetMonitor(false), "BarTarget", p2.Configurations [0].Selector);

                Assert.AreEqual(1, res.BuildResult.WarningCount);
                Assert.AreEqual("Works!", res.BuildResult.Errors [0].ErrorText);

                // Try building again the first project

                res = await p1.RunTarget(Util.GetMonitor(false), "SdkTarget", p1.Configurations [0].Selector);

                Assert.AreEqual(1, res.BuildResult.WarningCount);
                Assert.AreEqual("Works!", res.BuildResult.Errors [0].ErrorText);

                p1.Dispose();
                p2.Dispose();
            } finally {
                MonoDevelop.Projects.MSBuild.MSBuildProjectService.UnregisterProjectImportSearchPath("MSBuildSDKsPath", sdkPath1);
                MonoDevelop.Projects.MSBuild.MSBuildProjectService.UnregisterProjectImportSearchPath("MSBuildSDKsPath", sdkPath2);
            }
        }
Ejemplo n.º 15
0
        public async Task LoadRunConfigurations()
        {
            string        projFile = Util.GetSampleProject("run-configurations", "ConsoleProject", "ConsoleProject.configs-added.csproj");
            DotNetProject p        = (DotNetProject)await Services.ProjectService.ReadSolutionItem(Util.GetMonitor(), projFile);

            Assert.AreEqual(3, p.RunConfigurations.Count);

            var es = p.RunConfigurations [1];

            Assert.AreEqual(es.Name, "Test1");
            Assert.AreEqual(es.Properties.GetValue("SomeValue"), "Foo");

            es = p.RunConfigurations [2];
            Assert.AreEqual(es.Name, "Test2");
            Assert.AreEqual(es.Properties.GetValue("SomeValue"), "Bar");

            p.Dispose();
        }
Ejemplo n.º 16
0
        public async Task RemoveRunConfigurations()
        {
            string        solFile = Util.GetSampleProject("run-configurations", "ConsoleProject", "ConsoleProject.configs-added.csproj");
            DotNetProject p       = (DotNetProject)await Services.ProjectService.ReadSolutionItem(Util.GetMonitor(), solFile);

            Assert.AreEqual(3, p.RunConfigurations.Count);

            p.RunConfigurations.Clear();

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

            string projectXml    = File.ReadAllText(p.FileName);
            string newProjectXml = File.ReadAllText(p.FileName.ChangeName("ConsoleProject"));

            Assert.AreEqual(newProjectXml, projectXml);

            p.Dispose();
        }
Ejemplo n.º 17
0
        public async Task TestConfigurationMergingChangeMergeToParent5()
        {
            // Test for VSTS bug 518933 - Serialization issue with ItemProperty and MergeToProject

            string        projectFile = Util.GetSampleProject("test-configuration-merging", "TestConfigurationMerging11.csproj");
            DotNetProject p           = await Services.ProjectService.ReadSolutionItem(Util.GetMonitor(), projectFile) as DotNetProject;

            Assert.IsNotNull(p);

            DotNetProjectConfiguration debugConf   = p.Configurations ["Debug|x86"] as DotNetProjectConfiguration;
            DotNetProjectConfiguration releaseConf = p.Configurations ["Release|x86"] as DotNetProjectConfiguration;

            Assert.IsNotNull(debugConf);

            debugConf.Properties.SetValue("AndroidUseSharedRuntime", false, defaultValue: true, mergeToMainGroup: true);
            releaseConf.Properties.SetValue("AndroidUseSharedRuntime", false, defaultValue: true, mergeToMainGroup: true);

            // Release config already has SignAssembly=true, so the property should be merged to main group

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

            Assert.AreEqual(Util.ToSystemEndings(File.ReadAllText(p.FileName + ".saved")), File.ReadAllText(p.FileName));

            debugConf.Properties.SetValue("AndroidUseSharedRuntime", true, defaultValue: true, mergeToMainGroup: true);
            releaseConf.Properties.SetValue("AndroidUseSharedRuntime", false, defaultValue: true, mergeToMainGroup: true);

            // Release config still has SignAssembly=true, so the property should be removed from the main group and
            // assigned to true in Release configuration.

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

            Assert.AreEqual(Util.ToSystemEndings(File.ReadAllText(p.FileName + ".saved2")), File.ReadAllText(p.FileName));

            debugConf.Properties.SetValue("AndroidUseSharedRuntime", false, defaultValue: true, mergeToMainGroup: true);
            releaseConf.Properties.SetValue("AndroidUseSharedRuntime", false, defaultValue: true, mergeToMainGroup: true);

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

            Assert.AreEqual(Util.ToSystemEndings(File.ReadAllText(p.FileName + ".saved")), File.ReadAllText(p.FileName));

            p.Dispose();
        }
Ejemplo n.º 18
0
        public async Task SaveLoadedRunConfigurationFromProjectProperties2()
        {
            // Same as SaveLoadedRunConfigurationFromProjectProperties, but ExternalConsole is changed to False
            // In this case, even if ExternalConsole has the default value, it should be saved since its evaluated
            // value is True.
            // Also, an extra configuration should take the ExternalConsole value from the Default configuration

            string        solFile = Util.GetSampleProject("run-configurations", "ConsoleProject", "ConsoleProject.default-console.csproj");
            DotNetProject p       = (DotNetProject)await Services.ProjectService.ReadSolutionItem(Util.GetMonitor(), solFile);

            Assert.AreEqual(1, p.RunConfigurations.Count);

            var es = p.RunConfigurations [0] as ProcessRunConfiguration;

            Assert.IsNotNull(es);
            Assert.IsTrue(es.ExternalConsole);
            es.ExternalConsole = false;

            var newConf = (ProcessRunConfiguration)p.CreateRunConfiguration("Extra");

            p.RunConfigurations.Add(newConf);
            Assert.IsFalse(newConf.ExternalConsole);

            string projectXml = File.ReadAllText(p.FileName);

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

            string newProjectXml = File.ReadAllText(p.FileName);

            Assert.AreEqual(newProjectXml, projectXml);

            Assert.IsTrue(File.Exists(p.FileName + ".user"));

            string projUserFile = Util.GetSampleProject("run-configurations", "ConsoleProject", "ConsoleProject.default-console-saved2.csproj.user");

            projectXml    = File.ReadAllText(p.FileName + ".user");
            newProjectXml = File.ReadAllText(projUserFile);
            Assert.AreEqual(newProjectXml, projectXml);

            p.Dispose();
        }
Ejemplo n.º 19
0
        public async Task UpdateRunConfigurations()
        {
            string        solFile = Util.GetSampleProject("run-configurations", "ConsoleProject", "ConsoleProject.configs-added.csproj");
            DotNetProject p       = (DotNetProject)await Services.ProjectService.ReadSolutionItem(Util.GetMonitor(), solFile);

            Assert.AreEqual(3, p.RunConfigurations.Count);

            var es = p.RunConfigurations [2];

            es.Properties.SetValue("SomeValue", "Time");
            es.Properties.SetValue("SomeValue2", "Time2");

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

            string projectXml    = File.ReadAllText(p.FileName);
            string newProjectXml = File.ReadAllText(p.FileName.ChangeName("ConsoleProject.configs-modified"));

            Assert.AreEqual(newProjectXml, projectXml);

            p.Dispose();
        }
Ejemplo n.º 20
0
        public async Task ProjectUsingSdk()
        {
            string sdkPath = Util.GetSampleProjectPath("msbuild-search-paths", "sdk-path");

            try {
                MonoDevelop.Projects.MSBuild.MSBuildProjectService.RegisterProjectImportSearchPath("MSBuildSDKsPath", sdkPath);

                string        projectFile = Util.GetSampleProject("msbuild-search-paths", "ProjectUsingSdk.csproj");
                DotNetProject p           = await Services.ProjectService.ReadSolutionItem(Util.GetMonitor(), projectFile) as DotNetProject;

                Assert.AreEqual("Works!", p.MSBuildProject.EvaluatedProperties.GetValue("SdkProp"));

                var res = await p.RunTarget(Util.GetMonitor(false), "SdkTarget", p.Configurations [0].Selector);

                Assert.AreEqual(1, res.BuildResult.WarningCount);
                Assert.AreEqual("Works!", res.BuildResult.Errors [0].ErrorText);
                p.Dispose();
            } finally {
                MonoDevelop.Projects.MSBuild.MSBuildProjectService.UnregisterProjectImportSearchPath("MSBuildSDKsPath", sdkPath);
            }
        }
Ejemplo n.º 21
0
        public void ProjectNameWithDots()
        {
            // Test case for bug #437392

            ProjectCreateInformation info = new ProjectCreateInformation();

            info.ProjectName     = "Some.Test";
            info.ProjectBasePath = "/tmp/test";
            var doc            = new XmlDocument();
            var projectOptions = doc.CreateElement("Options");

            projectOptions.SetAttribute("language", "C#");
            DotNetProject p = (DotNetProject)Services.ProjectService.CreateProject("C#", info, projectOptions);

            Assert.AreEqual(2, p.Configurations.Count);
            Assert.AreEqual("Debug", p.Configurations [0].Name);
            Assert.AreEqual("Release", p.Configurations [1].Name);

            Assert.AreEqual("Some.Test", ((DotNetProjectConfiguration)p.Configurations [0]).OutputAssembly);
            Assert.AreEqual("Some.Test", ((DotNetProjectConfiguration)p.Configurations [1]).OutputAssembly);

            p.Dispose();
        }
Ejemplo n.º 22
0
        public async Task TestConfigurationMergingDefaultValues()
        {
            string        projectFile = Util.GetSampleProject("test-configuration-merging", "TestConfigurationMerging3.csproj");
            DotNetProject p           = await Services.ProjectService.ReadSolutionItem(Util.GetMonitor(), projectFile) as DotNetProject;

            Assert.IsNotNull(p);

            DotNetProjectConfiguration conf = p.Configurations["Release|x86"] as DotNetProjectConfiguration;

            Assert.IsNotNull(conf);
            dynamic cparams = conf.CompilationParameters;

            Assert.AreEqual(Microsoft.CodeAnalysis.CSharp.LanguageVersion.Default, cparams.LangVersion);
            cparams.LangVersion = Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp5;
            Assert.IsTrue(cparams.UnsafeCode);
            cparams.UnsafeCode = false;

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

            Assert.AreEqual(Util.ToSystemEndings(File.ReadAllText(p.FileName + ".saved")), File.ReadAllText(p.FileName));

            p.Dispose();
        }
Ejemplo n.º 23
0
        public async Task TestConfigurationMergingChangeNoMergeToParent()
        {
            string        projectFile = Util.GetSampleProject("test-configuration-merging", "TestConfigurationMerging5.csproj");
            DotNetProject p           = await Services.ProjectService.ReadSolutionItem(Util.GetMonitor(), projectFile) as DotNetProject;

            Assert.IsNotNull(p);

            DotNetProjectConfiguration conf = p.Configurations["Debug|x86"] as DotNetProjectConfiguration;

            Assert.IsNotNull(conf);
            Assert.IsTrue(conf.SignAssembly);

            conf = p.Configurations["Release|x86"] as DotNetProjectConfiguration;
            Assert.IsNotNull(conf);
            Assert.IsTrue(conf.SignAssembly);
            conf.SignAssembly = false;

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

            Assert.AreEqual(Util.ToSystemEndings(File.ReadAllText(p.FileName + ".saved")), File.ReadAllText(p.FileName));

            p.Dispose();
        }