protected override BuildResult OnClean(IProgressMonitor monitor, ConfigurationSelector configuration) { DotNetProject project = Project; DotNetProjectConfiguration conf = (DotNetProjectConfiguration)project.GetConfiguration(configuration); // Delete the generated debug info string file = project.GetOutputFileName(configuration); if (file != null) { string mdb = conf.TargetRuntime.GetAssemblyDebugInfoFile(file); if (File.Exists(mdb)) { FileService.DeleteFile(mdb); } } List <string> cultures = new List <string> (); monitor.Log.WriteLine(GettextCatalog.GetString("Removing all .resources files")); foreach (ProjectFile pfile in project.Files) { if (pfile.BuildAction == BuildAction.EmbeddedResource && Path.GetExtension(pfile.Name) == ".resx") { string resFilename = Path.ChangeExtension(pfile.Name, ".resources"); if (File.Exists(resFilename)) { FileService.DeleteFile(resFilename); } } string culture = GetCulture(pfile.Name); if (culture != null) { cultures.Add(culture); } } if (cultures.Count > 0 && conf != null && project.DefaultNamespace != null) { monitor.Log.WriteLine(GettextCatalog.GetString("Removing all satellite assemblies")); string outputDir = ((DotNetProjectConfiguration)conf).OutputDirectory; string satelliteAsmName = Path.GetFileNameWithoutExtension(((DotNetProjectConfiguration)conf).OutputAssembly) + ".resources.dll"; foreach (string culture in cultures) { string path = String.Format("{0}{3}{1}{3}{2}", outputDir, culture, satelliteAsmName, Path.DirectorySeparatorChar); if (File.Exists(path)) { FileService.DeleteFile(path); string dir = Path.GetDirectoryName(path); if (Directory.GetFiles(dir).Length == 0) { FileService.DeleteDirectory(dir); } } } } return(null); }
public string GetTypeAssemblyQualifiedName(object type) { IType t = (IType)type; DotNetProject p = (DotNetProject)t.SourceProjectDom.Project; DotNetProjectConfiguration conf = (DotNetProjectConfiguration)p.GetConfiguration(ConfigurationSelector.Default); return(t.FullName + ", " + conf.CompiledOutputName.FileNameWithoutExtension); }
public static string GetActivePlatform(this DotNetProject project) { var platform = project.GetConfiguration(IdeApp.Workspace.ActiveConfiguration)?.Platform; if (string.IsNullOrEmpty(platform)) { platform = "AnyCPU"; } return(platform); }
public override DeployFileCollection GetProjectDeployFiles(DeployContext ctx, Project project, ConfigurationSelector config) { DeployFileCollection col = base.GetProjectDeployFiles(ctx, project, config); LinuxDeployData data = LinuxDeployData.GetLinuxDeployData(project); if (ctx.Platform == "Linux") { DotNetProject netProject = project as DotNetProject; if (netProject != null) { DotNetProjectConfiguration conf = netProject.GetConfiguration(config) as DotNetProjectConfiguration; if (conf != null) { if (conf.CompileTarget == CompileTarget.Exe || conf.CompileTarget == CompileTarget.WinExe) { if (data.GenerateScript) { col.Add(GenerateLaunchScript(ctx, netProject, data, conf)); } } if (conf.CompileTarget == CompileTarget.Library || conf.CompiledOutputName.FileName.EndsWith(".dll")) { if (data.GeneratePcFile) { col.Add(GeneratePcFile(ctx, netProject, data, conf)); } } } } } // If the project is deploying an app.desktop file, rename it to the name of the project. foreach (DeployFile file in col) { if (Path.GetFileName(file.RelativeTargetPath) == "app.desktop") { string dir = Path.GetDirectoryName(file.RelativeTargetPath); file.RelativeTargetPath = Path.Combine(dir, data.PackageName + ".desktop"); } } return(col); }
public BuildResult RunTarget(MonoDevelop.Core.IProgressMonitor monitor, string target, ConfigurationSelector configuration) { if (target == ProjectService.BuildTarget) { target = "all"; } else if (target == ProjectService.CleanTarget) { target = "clean"; } DotNetProjectConfiguration conf = (DotNetProjectConfiguration)project.GetConfiguration(configuration); using (var output = new StringWriter()) { using (var tw = new LogTextWriter()) { tw.ChainWriter(output); tw.ChainWriter(monitor.Log); using (ProcessWrapper proc = Runtime.ProcessService.StartProcess("make", "PROFILE=" + conf.Id + " " + target, conf.OutputDirectory, monitor.Log, tw, null)) proc.WaitForOutput(); tw.UnchainWriter(output); tw.UnchainWriter(monitor.Log); var result = new BuildResult(output.ToString(), 1, 0); string[] lines = result.CompilerOutput.Split('\n'); foreach (string line in lines) { var err = CreateErrorFromString(line); if (err != null) { result.Append(err); } } return(result); } } }
public BuildResult RunTarget(MonoDevelop.Core.IProgressMonitor monitor, string target, ConfigurationSelector configuration) { if (target == ProjectService.BuildTarget) { target = "all"; } else if (target == ProjectService.CleanTarget) { target = "clean"; } DotNetProjectConfiguration conf = (DotNetProjectConfiguration)project.GetConfiguration(configuration); StringWriter output = new StringWriter(); LogTextWriter tw = new LogTextWriter(); tw.ChainWriter(output); tw.ChainWriter(monitor.Log); ProcessWrapper proc = Runtime.ProcessService.StartProcess("make", "PROFILE=" + conf.Id + " " + target, conf.OutputDirectory, monitor.Log, tw, null); proc.WaitForOutput(); CompilerResults cr = new CompilerResults(null); string[] lines = output.ToString().Split('\n'); foreach (string line in lines) { CompilerError err = CreateErrorFromString(line); if (err != null) { cr.Errors.Add(err); } } return(new BuildResult(cr, output.ToString())); }
protected override BuildResult OnBuild(IProgressMonitor monitor, ConfigurationSelector configuration) { if (!Project.InternalCheckNeedsBuild(configuration)) { monitor.Log.WriteLine(GettextCatalog.GetString("Skipping project since output files are up to date")); return(new BuildResult()); } DotNetProject project = Project; if (!project.TargetRuntime.IsInstalled(project.TargetFramework)) { BuildResult res = new BuildResult(); res.AddError(GettextCatalog.GetString("Framework '{0}' not installed.", project.TargetFramework.Name)); return(res); } bool hasBuildableFiles = false; foreach (ProjectFile pf in project.Files) { if (pf.BuildAction == BuildAction.Compile || pf.BuildAction == BuildAction.EmbeddedResource) { hasBuildableFiles = true; break; } } if (!hasBuildableFiles) { return(new BuildResult()); } if (project.LanguageBinding == null) { BuildResult langres = new BuildResult(); string msg = GettextCatalog.GetString("Unknown language '{0}'. You may need to install an additional add-in to support this language.", project.LanguageName); langres.AddError(msg); monitor.ReportError(msg, null); return(langres); } BuildResult refres = null; HashSet <ProjectItem> itemsToExclude = new HashSet <ProjectItem> (); foreach (ProjectReference pr in project.References) { if (pr.ReferenceType == ReferenceType.Project) { // Ignore non-dotnet projects Project p = project.ParentSolution != null?project.ParentSolution.FindProjectByName(pr.Reference) : null; if (p != null && !(p is DotNetProject)) { continue; } if (p == null || pr.GetReferencedFileNames(configuration).Length == 0) { if (refres == null) { refres = new BuildResult(); } string msg = GettextCatalog.GetString("Referenced project '{0}' not found in the solution.", pr.Reference); monitor.ReportWarning(msg); refres.AddWarning(msg); } } if (!pr.IsValid) { if (refres == null) { refres = new BuildResult(); } string msg; if (!pr.IsExactVersion && pr.SpecificVersion) { msg = GettextCatalog.GetString("Reference '{0}' not found on system. Using '{1}' instead.", pr.StoredReference, pr.Reference); monitor.ReportWarning(msg); refres.AddWarning(msg); } else { bool errorsFound = false; foreach (string asm in pr.GetReferencedFileNames(configuration)) { if (!File.Exists(asm)) { msg = GettextCatalog.GetString("Assembly '{0}' not found. Make sure that the assembly exists in disk. If the reference is required to build the project you may get compilation errors.", Path.GetFileName(asm)); refres.AddWarning(msg); monitor.ReportWarning(msg); errorsFound = true; itemsToExclude.Add(pr); } } msg = null; if (!errorsFound) { msg = GettextCatalog.GetString("The reference '{0}' is not valid for the target framework of the project.", pr.StoredReference, pr.Reference); monitor.ReportWarning(msg); refres.AddWarning(msg); itemsToExclude.Add(pr); } } } } DotNetProjectConfiguration conf = (DotNetProjectConfiguration)project.GetConfiguration(configuration); // Create a copy of the data needed to compile the project. // This data can be modified by extensions. // Also filter out items whose condition evaluates to false BuildData buildData = new BuildData(); ProjectParserContext ctx = new ProjectParserContext(project, conf); buildData.Items = new ProjectItemCollection(); foreach (ProjectItem item in project.Items) { if (!itemsToExclude.Contains(item) && (string.IsNullOrEmpty(item.Condition) || ConditionParser.ParseAndEvaluate(item.Condition, ctx))) { buildData.Items.Add(item); } } buildData.Configuration = (DotNetProjectConfiguration)conf.Clone(); buildData.Configuration.SetParentItem(project); buildData.ConfigurationSelector = configuration; return(ProjectExtensionUtil.Compile(monitor, project, buildData, delegate { ProjectItemCollection items = buildData.Items; BuildResult res = BuildResources(buildData.Configuration, ref items, monitor); if (res != null) { return res; } res = project.LanguageBinding.Compile(items, buildData.Configuration, buildData.ConfigurationSelector, monitor); if (refres != null) { refres.Append(res); return refres; } else { return res; } })); }
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; 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; }
public CompilerOptionsPanelWidget(DotNetProject project) { this.Build(); this.project = project; DotNetProjectConfiguration configuration = (DotNetProjectConfiguration)project.GetConfiguration(IdeApp.Workspace.ActiveConfiguration); CSharpCompilerParameters compilerParameters = (CSharpCompilerParameters)configuration.CompilationParameters; var csproject = (CSharpProject)project; compileTargetCombo.CompileTarget = 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 = csproject.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 == csproject.CodePage) { foundEncoding = e.Id; } codepageEntry.AppendText(e.Id); } if (foundEncoding != null) { codepageEntry.Entry.Text = foundEncoding; } else if (csproject.CodePage != 0) { codepageEntry.Entry.Text = csproject.CodePage.ToString(); } iconEntry.Path = csproject.Win32Icon; iconEntry.DefaultPath = project.BaseDirectory; allowUnsafeCodeCheckButton.Active = compilerParameters.UnsafeCode; noStdLibCheckButton.Active = compilerParameters.NoStdLib; langVersionWarningIcon.Visible = false; var langVerStore = new ListStore(typeof(string), typeof(LanguageVersion), typeof(bool)); var langVersions = CSharpLanguageVersionHelper.GetKnownLanguageVersions(); string badVersion = null; LanguageVersion?langVersion = null; try { langVersion = compilerParameters.LangVersion; } catch (Exception) { badVersion = configuration.Properties.GetProperty("LangVersion").Value; } foreach (var(text, version) in langVersions) { if (unsupportedLanguageVersions.Contains(version)) { if (langVersion == version) { if (badVersion == null) { badVersion = text; } } else { // Otherwise if it's an unsupported language but it's not the current project's // version then it must be an unsupported version of Mono. Let's not add that to // the list store. } } else { langVerStore.AppendValues(text, version, false); } } langVerCombo.Model = langVerStore; if (badVersion != null) { var badIter = langVerStore.AppendValues(GettextCatalog.GetString("{0} (Unknown Version)", badVersion), LanguageVersion.Default, true); langVerCombo.SetActiveIter(badIter); langVersionWarningIcon.Visible = true; } else { TreeIter iter; if (langVerStore.GetIterFirst(out iter)) { do { var val = (LanguageVersion)(int)langVerStore.GetValue(iter, 1); if (val == compilerParameters.LangVersion) { langVerCombo.SetActiveIter(iter); break; } } while (langVerStore.IterNext(ref iter)); } } SetupAccessibility(); }
public static string GetActiveConfiguration(this DotNetProject project) { return(project.GetConfiguration(IdeApp.Workspace.ActiveConfiguration)?.Name); }
public CompilerOptionsPanelWidget(DotNetProject project) { this.Build(); this.project = project; DotNetProjectConfiguration configuration = (DotNetProjectConfiguration)project.GetConfiguration(IdeApp.Workspace.ActiveConfiguration); CSharpCompilerParameters compilerParameters = (CSharpCompilerParameters)configuration.CompilationParameters; var csproject = (CSharpProject)project; compileTargetCombo.CompileTarget = 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 = csproject.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 == csproject.CodePage) { foundEncoding = e.Id; } codepageEntry.AppendText(e.Id); } if (foundEncoding != null) { codepageEntry.Entry.Text = foundEncoding; } else if (csproject.CodePage != 0) { codepageEntry.Entry.Text = csproject.CodePage.ToString(); } iconEntry.Path = csproject.Win32Icon; iconEntry.DefaultPath = project.BaseDirectory; allowUnsafeCodeCheckButton.Active = compilerParameters.UnsafeCode; noStdLibCheckButton.Active = compilerParameters.NoStdLib; var langVerStore = new ListStore(typeof(string), typeof(LanguageVersion)); foreach (var(text, version) in CSharpLanguageVersionHelper.GetKnownLanguageVersions()) { langVerStore.AppendValues(text, version); } langVerCombo.Model = langVerStore; TreeIter iter; if (langVerStore.GetIterFirst(out iter)) { do { var val = (LanguageVersion)(int)langVerStore.GetValue(iter, 1); if (val == compilerParameters.LangVersion) { langVerCombo.SetActiveIter(iter); break; } } while (langVerStore.IterNext(ref iter)); } SetupAccessibility(); }
public CompilerOptionsPanelWidget(DotNetProject project) { this.Build(); this.project = project; DotNetProjectConfiguration configuration = (DotNetProjectConfiguration)project.GetConfiguration(IdeApp.Workspace.ActiveConfiguration); CSharpCompilerParameters compilerParameters = (CSharpCompilerParameters)configuration.CompilationParameters; var csproject = (CSharpProject)project; 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 = csproject.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 == csproject.CodePage) { foundEncoding = e.Id; } codepageEntry.AppendText(e.Id); } if (foundEncoding != null) { codepageEntry.Entry.Text = foundEncoding; } else if (csproject.CodePage != 0) { codepageEntry.Entry.Text = csproject.CodePage.ToString(); } iconEntry.Path = csproject.Win32Icon; iconEntry.DefaultPath = project.BaseDirectory; allowUnsafeCodeCheckButton.Active = compilerParameters.UnsafeCode; noStdLibCheckButton.Active = compilerParameters.NoStdLib; var langVerStore = new ListStore(typeof(string), typeof(LanguageVersion)); langVerStore.AppendValues(GettextCatalog.GetString("Default"), LanguageVersion.Default); langVerStore.AppendValues("ISO-1", LanguageVersion.CSharp1); langVerStore.AppendValues("ISO-2", LanguageVersion.CSharp2); langVerStore.AppendValues(GettextCatalog.GetString("Version 3"), LanguageVersion.CSharp3); langVerStore.AppendValues(GettextCatalog.GetString("Version 4"), LanguageVersion.CSharp4); langVerStore.AppendValues(GettextCatalog.GetString("Version 5"), LanguageVersion.CSharp5); langVerStore.AppendValues(GettextCatalog.GetString("Version 6"), LanguageVersion.CSharp6); langVerStore.AppendValues(GettextCatalog.GetString("Version 7"), LanguageVersion.CSharp7); langVerStore.AppendValues(GettextCatalog.GetString("Latest"), LanguageVersion.Latest); langVerCombo.Model = langVerStore; TreeIter iter; if (langVerStore.GetIterFirst(out iter)) { do { var val = (LanguageVersion)(int)langVerStore.GetValue(iter, 1); if (val == compilerParameters.LangVersion) { langVerCombo.SetActiveIter(iter); break; } } while (langVerStore.IterNext(ref iter)); } SetupAccessibility(); }