static void CheckConfigurationMappings(DotNetProject project, string currentConfig)
        {
            var projConfig = (DotNetProjectConfiguration)project.GetConfiguration (IdeApp.Workspace.ActiveConfiguration);
            if (project.GetConfigurations ().Contains (currentConfig) && projConfig.Name != currentConfig)
                LogIssue (project, "configuration", currentConfig, projConfig.Name);

            if (currentConfig.IndexOf ("Debug", StringComparison.OrdinalIgnoreCase) != -1)
                return;

            // Fixup entries for release configs.
            var debugEntry = project.ParentSolution
                .GetConfiguration (new SolutionConfigurationSelector (currentConfig.Replace ("Release", "Debug")))
                .GetEntryForItem (project);
            if (debugEntry == null)
                return;

            IdeApp.Workspace.ActiveConfigurationId = currentConfig;

            var entry = project.ParentSolution.GetConfiguration (IdeApp.Workspace.ActiveConfiguration).GetEntryForItem (project);
            entry.Build = debugEntry.Build;
            entry.Deploy = debugEntry.Deploy;

            var newConfig = debugEntry.ItemConfiguration.Replace ("Debug", "Release");
            if (project.GetConfigurations ().Any (config => config == newConfig))
                entry.ItemConfiguration = newConfig;
            else {
                LogIssue (project, "configuration", newConfig, "Missing");
                entry.ItemConfiguration = debugEntry.ItemConfiguration;
            }
        }
		public CompilerOptionsPanelWidget (DotNetProject project)
		{
			this.Build();
			this.project = project;
			DotNetProjectConfiguration configuration = (DotNetProjectConfiguration) project.GetConfiguration (IdeApp.Workspace.ActiveConfiguration);
			CSharpCompilerParameters compilerParameters = (CSharpCompilerParameters) configuration.CompilationParameters;
			CSharpProjectParameters projectParameters = (CSharpProjectParameters) configuration.ProjectParameters;
			
			ListStore store = new ListStore (typeof (string));
			store.AppendValues (GettextCatalog.GetString ("Executable"));
			store.AppendValues (GettextCatalog.GetString ("Library"));
			store.AppendValues (GettextCatalog.GetString ("Executable with GUI"));
			store.AppendValues (GettextCatalog.GetString ("Module"));
			compileTargetCombo.Model = store;
			CellRendererText cr = new CellRendererText ();
			compileTargetCombo.PackStart (cr, true);
			compileTargetCombo.AddAttribute (cr, "text", 0);
			compileTargetCombo.Active = (int) configuration.CompileTarget;
			compileTargetCombo.Changed += new EventHandler (OnTargetChanged);
			
			if (project.IsLibraryBasedProjectType) {
				//fixme: should we totally hide these?
				compileTargetCombo.Sensitive = false;
				mainClassEntry.Sensitive = false;
			} else {
				classListStore = new ListStore (typeof(string));
				mainClassEntry.Model = classListStore;
				mainClassEntry.TextColumn = 0;
				((Entry)mainClassEntry.Child).Text = projectParameters.MainClass ?? string.Empty;
			
				UpdateTarget ();
			}
			
			// Load the codepage. If it matches any of the supported encodigs, use the encoding name 			
			string foundEncoding = null;
			foreach (TextEncoding e in TextEncoding.SupportedEncodings) {
				if (e.CodePage == -1)
					continue;
				if (e.CodePage == projectParameters.CodePage)
					foundEncoding = e.Id;
				codepageEntry.AppendText (e.Id);
			}
			if (foundEncoding != null)
				codepageEntry.Entry.Text = foundEncoding;
			else if (projectParameters.CodePage != 0)
				codepageEntry.Entry.Text = projectParameters.CodePage.ToString ();
			
			iconEntry.Path = projectParameters.Win32Icon;
			iconEntry.DefaultPath = project.BaseDirectory;
			allowUnsafeCodeCheckButton.Active = compilerParameters.UnsafeCode;
			noStdLibCheckButton.Active = compilerParameters.NoStdLib;

			ListStore langVerStore = new ListStore (typeof (string));
			langVerStore.AppendValues (GettextCatalog.GetString ("Default"));
			langVerStore.AppendValues ("ISO-1");
			langVerStore.AppendValues ("ISO-2");
			langVerCombo.Model = langVerStore;
			langVerCombo.Active = (int) compilerParameters.LangVersion;
		}
        static void CheckConfigurationProperties(DotNetProject project)
        {
            var projConfig = (DotNetProjectConfiguration)project.GetConfiguration (IdeApp.Workspace.ActiveConfiguration);
            bool isDebug = projConfig.Name.IndexOf ("Debug", StringComparison.OrdinalIgnoreCase) != -1;
            bool shouldHaveDebugSymbols = true; // isDebug; // This is for general case.
            bool shouldBeOptimized = !isDebug;
            string[] debugTypeValues = isDebug ? new[] { "full" } : new[] { "pdbonly" }; // Should be none for release, but MD is pdbonly.

            if (projConfig.DebugMode != shouldHaveDebugSymbols) {
                LogIssue (project, "DebugSymbols", shouldHaveDebugSymbols, projConfig.DebugMode);
                projConfig.DebugMode = shouldHaveDebugSymbols;
                shouldSave = true;
            }

            var args = projConfig.CompilationParameters as MonoDevelop.CSharp.Project.CSharpCompilerParameters;
            if (args == null)
                return;

            if (!debugTypeValues.Any (value => value.Equals (args.DebugType, StringComparison.OrdinalIgnoreCase))) {
                LogIssue (project, "DebugType", debugTypeValues.First (), args.DebugType);
                args.DebugType = debugTypeValues.First ();
                shouldSave = true;
            }

            if (args.Optimize != shouldBeOptimized) {
                LogIssue (project, "Optimize", shouldBeOptimized, args.Optimize);
                args.Optimize = shouldBeOptimized;
                shouldSave = true;
            }

            if (isDebug)
                return;

            // Fixup to release properties.
            var debugConfig = (DotNetProjectConfiguration)project.GetConfiguration (new ItemConfigurationSelector (projConfig.Name.Replace ("Release", "Debug")));
            projConfig.DelaySign = debugConfig.DelaySign;
            projConfig.OutputAssembly = debugConfig.OutputAssembly;
            projConfig.SignAssembly = debugConfig.SignAssembly;
            projConfig.CommandLineParameters = debugConfig.CommandLineParameters;
            projConfig.ExternalConsole = debugConfig.ExternalConsole;
            projConfig.OutputDirectory = debugConfig.OutputDirectory;
            projConfig.RunWithWarnings = debugConfig.RunWithWarnings;
            projConfig.PauseConsoleOutput = debugConfig.PauseConsoleOutput;

            var debugArgs = debugConfig.CompilationParameters as MonoDevelop.CSharp.Project.CSharpCompilerParameters;
            if (debugArgs == null)
                return;

            args.DefineSymbols = debugArgs.DefineSymbols.Replace ("DEBUG", "").Trim(',', ';').Replace(",,", ",").Replace(";;", ";");
            args.DocumentationFile = debugArgs.DocumentationFile;
            args.GenerateOverflowChecks = debugArgs.GenerateOverflowChecks;
            args.LangVersion = debugArgs.LangVersion;
            args.NoStdLib = debugArgs.NoStdLib;
            args.NoWarnings = debugArgs.NoWarnings;
            args.TreatWarningsAsErrors = debugArgs.TreatWarningsAsErrors;
            args.PlatformTarget = debugArgs.PlatformTarget;
            args.UnsafeCode = debugArgs.UnsafeCode;
            args.WarningLevel = debugArgs.WarningLevel;
            args.WarningsNotAsErrors = debugArgs.WarningsNotAsErrors;
        }
        static void CheckDefineSymbols(DotNetProject project)
        {
            var projConfig = (DotNetProjectConfiguration)project.GetConfiguration (IdeApp.Workspace.ActiveConfiguration);
            bool shouldContainDebug = projConfig.Name.IndexOf ("Debug", StringComparison.OrdinalIgnoreCase) != -1;
            bool shouldContainMac = projConfig.Name.IndexOf ("Mac", StringComparison.OrdinalIgnoreCase) != -1;
            bool shouldContainWin = projConfig.Name.IndexOf ("Win32", StringComparison.OrdinalIgnoreCase) != -1;

            if (projConfig.GetDefineSymbols ().Any (symbol => symbol.Equals ("DEBUG", StringComparison.OrdinalIgnoreCase)) != shouldContainDebug) {
                var expected = shouldContainDebug ? "DEBUG" : "";
                var actual = shouldContainDebug ? "" : "DEBUG";
                LogIssue (project, "symbols", expected, actual);
            }

            if (projConfig.GetDefineSymbols ().Any (symbol => symbol.Equals ("MAC", StringComparison.OrdinalIgnoreCase)) != shouldContainMac) {
                var expected = shouldContainMac ? "MAC" : "";
                var actual = shouldContainMac ? "" : "MAC";
                LogIssue (project, "symbols", expected, actual);
            }

            if (projConfig.GetDefineSymbols ().Any (symbol => symbol.Equals ("WIN32", StringComparison.OrdinalIgnoreCase)) != shouldContainWin) {
                var expected = shouldContainWin ? "WIN32" : "";
                var actual = shouldContainWin ? "" : "WIN32";
                LogIssue (project, "symbols", expected, actual);
            }
        }
示例#5
0
        void PopulateSupportFileList(FileCopySet list, ConfigurationSelector configuration, int referenceDistance)
        {
            if (referenceDistance < 2)
            {
                base.PopulateSupportFileList(list, configuration);
            }

            //rename the app.config file
            FileCopySet.Item appConfig = list.Remove("app.config");
            if (appConfig == null)
            {
                appConfig = list.Remove("App.config");
            }
            if (appConfig != null)
            {
                string output = Path.GetFileName(GetOutputFileName(configuration));
                list.Add(appConfig.Src, appConfig.CopyOnlyIfNewer, output + ".config");
            }

            //collect all the "local copy" references and their attendant files
            foreach (ProjectReference projectReference in References)
            {
                if (!projectReference.LocalCopy || ParentSolution == null)
                {
                    continue;
                }

                if (projectReference.ReferenceType == ReferenceType.Project)
                {
                    DotNetProject p = ParentSolution.FindProjectByName(projectReference.Reference) as DotNetProject;

                    if (p == null)
                    {
                        LoggingService.LogWarning("Project '{0}' referenced from '{1}' could not be found", projectReference.Reference, this.Name);
                        continue;
                    }

                    string refOutput = p.GetOutputFileName(configuration);
                    if (string.IsNullOrEmpty(refOutput))
                    {
                        LoggingService.LogWarning("Project '{0}' referenced from '{1}' has an empty output filename", p.Name, this.Name);
                        continue;
                    }

                    list.Add(refOutput);

                    //VS COMPAT: recursively copy references's "local copy" files
                    //but only copy the "copy to output" files from the immediate references
                    p.PopulateSupportFileList(list, configuration, referenceDistance + 1);

                    DotNetProjectConfiguration refConfig = p.GetConfiguration(configuration) as DotNetProjectConfiguration;

                    if (refConfig != null && refConfig.DebugMode)
                    {
                        string mdbFile = TargetRuntime.GetAssemblyDebugInfoFile(refOutput);
                        if (File.Exists(mdbFile))
                        {
                            list.Add(mdbFile);
                        }
                    }
                }
                else if (projectReference.ReferenceType == ReferenceType.Assembly)
                {
                    // VS COMPAT: Copy the assembly, but also all other assemblies referenced by it
                    // that are located in the same folder
                    foreach (string file in GetAssemblyRefsRec(projectReference.Reference, new HashSet <string> ()))
                    {
                        list.Add(file);
                        if (File.Exists(file + ".config"))
                        {
                            list.Add(file + ".config");
                        }
                        string mdbFile = TargetRuntime.GetAssemblyDebugInfoFile(file);
                        if (File.Exists(mdbFile))
                        {
                            list.Add(mdbFile);
                        }
                    }
                }
                else if (projectReference.ReferenceType == ReferenceType.Custom)
                {
                    foreach (string refFile in projectReference.GetReferencedFileNames(configuration))
                    {
                        list.Add(refFile);
                    }
                }
            }
        }