public TemplateConfigFolder(DotNetProject project) : this(project.GetTemplateConfigDirectory(), project) { }
/// <summary> /// Currently this project extension is enabled for all SDK style projects and /// not just for .NET Core and .NET Standard projects. SDK project support /// should be separated out from this extension so it can be enabled only for /// .NET Core and .NET Standard projects. /// </summary> bool IsSdkProject(DotNetProject project) { return(project.MSBuildProject.GetReferencedSDKs().Any()); }
public AddPlatformImplementationViewModel(DotNetProject project) { Project = project; ConfigureSettings(); }
public XcodeSyncBackContext GetChanges(IProgressMonitor monitor, NSObjectInfoService infoService, DotNetProject project) { var ctx = new XcodeSyncBackContext(projectDir, syncTimeCache, infoService, project); var needsSync = new List <XcodeSyncedItem> (items.Where(i => i.NeedsSyncBack(monitor, ctx))); var knownFiles = GetKnownFiles(); if (Directory.Exists(projectDir)) { monitor.BeginTask("Scanning for newly-added files in the Xcode project...", 0); ScanForAddedFiles(monitor, ctx, knownFiles, projectDir, null); monitor.EndTask(); } if (needsSync.Count > 0) { monitor.BeginStepTask(GettextCatalog.GetString("Synchronizing changes made to known files in Xcode back to MonoDevelop..."), needsSync.Count, 1); for (int i = 0; i < needsSync.Count; i++) { var item = needsSync [i]; item.SyncBack(monitor, ctx); monitor.Step(1); } monitor.EndTask(); } return(ctx); }
public MD1DotNetProjectHandler(DotNetProject entry) : base(entry) { }
public XibCodeBehind(DotNetProject project) { this.Project = project; project.FileChangedInProject += HandleProjectFileChangedInProject; project.FileAddedToProject += HandleProjectFileAddedToProject; }
public TemplateInformation(DotNetProject project) : this(project.BaseDirectory, new [] { project }) { }
public static bool NuGetAssetsFileExists(this DotNetProject project) { string assetsFile = project.GetNuGetAssetsFilePath(); return(File.Exists(assetsFile)); }
// Can add tags for substitution based on project, language or filename. // If overriding but still want base implementation's tags, should invoke base method. // We supply defaults whenever it is possible, to avoid having unsubstituted tags. However, // do not substitute blanks when a sensible default cannot be guessed, because they result //in less obvious errors. public virtual void ModifyTags(SolutionItem policyParent, Project project, string language, string identifier, string fileName, ref Dictionary <string, string> tags) { DotNetProject netProject = project as DotNetProject; string languageExtension = ""; ILanguageBinding binding = null; if (!string.IsNullOrEmpty(language)) { binding = GetLanguageBinding(language); if (binding != null) { languageExtension = Path.GetExtension(binding.GetFileName("Default")).Remove(0, 1); } } //need a default namespace or if there is no project, substitutions can get very messed up string ns = netProject != null?netProject.GetDefaultNamespace(fileName) : "Application"; //need an 'identifier' for tag substitution, e.g. class name or page name //if not given an identifier, use fileName if ((identifier == null) && (fileName != null)) { identifier = Path.GetFileName(fileName); } if (identifier != null) { //remove all extensions while (Path.GetExtension(identifier).Length > 0) { identifier = Path.GetFileNameWithoutExtension(identifier); } identifier = CreateIdentifierName(identifier); tags ["Name"] = identifier; tags ["FullName"] = ns.Length > 0 ? ns + "." + identifier : identifier; //some .NET languages may be able to use keywords as identifiers if they're escaped IDotNetLanguageBinding dnb = binding as IDotNetLanguageBinding; if (dnb != null) { System.CodeDom.Compiler.CodeDomProvider provider = dnb.GetCodeDomProvider(); if (provider != null) { tags ["EscapedIdentifier"] = provider.CreateEscapedIdentifier(identifier); } } } tags ["Namespace"] = ns; if (project != null) { tags ["ProjectName"] = project.Name; tags ["SafeProjectName"] = CreateIdentifierName(project.Name); var info = project.AuthorInformation ?? AuthorInformation.Default; tags ["AuthorCopyright"] = info.Copyright; tags ["AuthorCompany"] = info.Company; tags ["AuthorTrademark"] = info.Trademark; tags ["AuthorEmail"] = info.Email; tags ["AuthorName"] = info.Name; } if ((language != null) && (language.Length > 0)) { tags ["Language"] = language; } if (languageExtension.Length > 0) { tags ["LanguageExtension"] = languageExtension; } if (fileName != FilePath.Null) { FilePath fileDirectory = Path.GetDirectoryName(fileName); if (project != null && project.BaseDirectory != FilePath.Null && fileDirectory.IsChildPathOf(project.BaseDirectory)) { tags ["ProjectRelativeDirectory"] = fileDirectory.ToRelative(project.BaseDirectory); } else { tags ["ProjectRelativeDirectory"] = fileDirectory; } tags ["FileNameWithoutExtension"] = Path.GetFileNameWithoutExtension(fileName); tags ["Directory"] = fileDirectory; tags ["FileName"] = fileName; } }
public void RefreshReferenceStatus() { DotNetProject.RefreshReferenceStatus(); }
public IProjectSystem CreateProjectSystem(DotNetProject project) { return(FakeProjectSystem); }
public void Load(DotNetProject project, DotNetProjectConfiguration configuration) { pproject = project; pconfiguration = configuration; }
public static string GetPackagesConfigFilePath(this DotNetProject project) { return(GetPackagesConfigFilePath(project.BaseDirectory, project.Name)); }
public MD1DotNetProjectHandler (DotNetProject entry) { project = entry; }
public DependenciesNode(DotNetProject project) : this(project, PackageManagementServices.UpdatedPackagesInWorkspace) { }
public MD1DotNetProjectHandler (DotNetProject entry): base (entry) { }
public static NuGetProject Create(DotNetProject project) { return(Create(project, ConfigurationSelector.Default)); }
// Builds the EmbedAsResource files. If any localized resources are found then builds the satellite assemblies // and sets @projectItems to a cloned collection minus such resource files. private BuildResult BuildResources(DotNetProjectConfiguration configuration, ref ProjectItemCollection projectItems, IProgressMonitor monitor) { string resgen = configuration.TargetRuntime.GetToolPath(configuration.TargetFramework, "resgen"); ExecutionEnvironment env = configuration.TargetRuntime.GetToolsExecutionEnvironment(configuration.TargetFramework); bool cloned = false; Dictionary <string, string> resourcesByCulture = new Dictionary <string, string> (); foreach (ProjectFile finfo in projectItems.GetAll <ProjectFile> ()) { if (finfo.Subtype == Subtype.Directory || finfo.BuildAction != BuildAction.EmbeddedResource) { continue; } string fname = finfo.Name; string resourceId; CompilerError ce = GetResourceId(env, finfo, ref fname, resgen, out resourceId, monitor); if (ce != null) { CompilerResults cr = new CompilerResults(new TempFileCollection()); cr.Errors.Add(ce); return(new BuildResult(cr, String.Empty)); } string culture = DotNetProject.GetResourceCulture(finfo.Name); if (culture == null) { continue; } string cmd = String.Empty; if (resourcesByCulture.ContainsKey(culture)) { cmd = resourcesByCulture [culture]; } cmd = String.Format("{0} \"/embed:{1},{2}\"", cmd, fname, resourceId); resourcesByCulture [culture] = cmd; if (!cloned) { // Clone only if required ProjectItemCollection items = new ProjectItemCollection(); items.AddRange(projectItems); projectItems = items; cloned = true; } projectItems.Remove(finfo); } string al = configuration.TargetFramework.ClrVersion == ClrVersion.Net_2_0 ? "al2" : "al"; CompilerError err = GenerateSatelliteAssemblies(resourcesByCulture, configuration.OutputDirectory, al, Path.GetFileName(configuration.OutputAssembly), monitor); if (err != null) { CompilerResults cr = new CompilerResults(new TempFileCollection()); cr.Errors.Add(err); return(new BuildResult(cr, String.Empty)); } return(null); }
public DotNetCoreNuGetProject(DotNetProject project) : this(project, ConfigurationSelector.Default) { }
protected override BuildResult OnBuild(IProgressMonitor monitor, ConfigurationSelector configuration) { 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 DotNetCoreNuGetProject(DotNetProject project, ConfigurationSelector configuration) : this(project, project.GetDotNetCoreTargetFrameworks(), configuration) { }
void AddProjectReference(DotNetProject project, Project projectToBeReferenced) { project.References.Add(ProjectReference.CreateProjectReference(projectToBeReferenced)); }
public void RefreshProjectBuilder() { DotNetProject.RefreshProjectBuilder(); }
public static IEnumerable <string> GuessDependencies(DotNetProject proj, ProjectFile file, IEnumerable <string> groupedExtensions) { //only change the grouping if it's not already been set if (!string.IsNullOrEmpty(file.DependsOn) || proj.LanguageBinding == null) { return(null); } //we only handle names that end with the language extension string langExt = proj.LanguageBinding.GetFileName("a"); langExt = langExt.Substring(1, langExt.Length - 1); //if filename ends with lang extension, it could be a child file if (file.Name.EndsWith(langExt, StringComparison.OrdinalIgnoreCase)) { //get the parent's name, amputating ".designer" if encountered string parentName = Path.GetFileName(file.Name); parentName = parentName.Substring(0, parentName.Length - langExt.Length); if (parentName.EndsWith(".designer", StringComparison.OrdinalIgnoreCase)) { parentName = parentName.Substring(0, parentName.Length - 9); } //for each ASP.NET extension that allows codebehind, check whether the filename matches this extension foreach (string ext in groupedExtensions) { if (!parentName.EndsWith(ext, StringComparison.OrdinalIgnoreCase)) { continue; } //if the file exists, set the dependency string path = Path.Combine(Path.GetDirectoryName(file.FilePath), parentName); if (File.Exists(path)) { file.DependsOn = parentName; return(new string[] { path }); } } } //else, it may be a parent else { //check whether its extension matches known parent extensions foreach (string ext in groupedExtensions) { if (!file.FilePath.ToString().EndsWith(ext, StringComparison.OrdinalIgnoreCase)) { continue; } //check for codebehind files string codebehind = file.FilePath + langExt; if (!File.Exists(codebehind)) { codebehind = null; } string designer = file.FilePath + ".designer" + langExt; if (!File.Exists(designer)) { designer = file.FilePath + ".Designer" + langExt; if (!File.Exists(designer)) { designer = null; } } //return any found files that match if (designer != null) { return(codebehind != null ? new string[] { designer, codebehind } : new string[] { designer }); } else { return(codebehind != null? new string[] { codebehind } : null); } } } return(null); }
public void DisposeProjectBuilder() { DotNetProject.ReloadProjectBuilder(); }
/// <summary> /// Returns the closure of all project to project references below this project. /// The code is a port of src/NuGet.Clients/PackageManagement.VisualStudio/IDE/VSProjectReferenceUtility.cs /// </summary> static IReadOnlyList <ProjectRestoreReference> GetDirectProjectReferences( DotNetProject project, ILogger log) { var results = new List <ProjectRestoreReference>(); // Verify ReferenceOutputAssembly var excludedProjects = GetExcludedReferences(project); bool hasMissingReferences = false; // find all references in the project foreach (var childReference in project.References) { try { if (!childReference.IsValid) { // Skip missing references and show a warning hasMissingReferences = true; continue; } // Skip missing references DotNetProject sourceProject = null; if (childReference.ReferenceType == ReferenceType.Project) { sourceProject = childReference.ResolveProject(project.ParentSolution) as DotNetProject; } // Skip missing references if (sourceProject != null) { if (sourceProject.IsShared) { // Skip this shared project continue; } string childProjectPath = sourceProject.FileName; // Skip projects which have ReferenceOutputAssembly=false if (!string.IsNullOrEmpty(childProjectPath) && !excludedProjects.Contains(childProjectPath, StringComparer.OrdinalIgnoreCase)) { var restoreReference = new ProjectRestoreReference() { ProjectPath = childProjectPath, ProjectUniqueName = childProjectPath }; results.Add(restoreReference); } } } catch (Exception ex) { // Exceptions are expected in some scenarios for native projects, // ignore them and show a warning hasMissingReferences = true; log.LogDebug(ex.ToString()); LoggingService.LogError("Unable to find project dependencies.", ex); } } if (hasMissingReferences) { // Log a warning message once per project // This warning contains only the names of the root project and the project with the // broken reference. Attempting to display more details on the actual reference // that has the problem may lead to another exception being thrown. var warning = string.Format( "Failed to resolve all project references. The package restore result for '{0}' or a dependant project may be incomplete.", project.Name); log.LogWarning(warning); } return(results); }
public DotNetProjectProxy(DotNetProject project) : base(project) { this.project = project; }
public TemplateConfigFolder(FilePath directory, DotNetProject project) : base(directory, project) { BaseDirectory = directory; DotNetProject = project; }
public void Reset() { store.Clear(); bool isPcl = configureProject is PortableDotNetProject; foreach (SystemAssembly systemAssembly in targetContext.GetAssemblies(targetVersion)) { if (systemAssembly.Package.IsFrameworkPackage && (isPcl || systemAssembly.Name == "mscorlib")) { continue; } bool selected = IsSelected(ReferenceType.Package, systemAssembly.FullName, systemAssembly.Package.Name); int matchRank = 0; string name, version; if (stringMatcher != null) { string txt = systemAssembly.Name + " " + systemAssembly.Version; if (!stringMatcher.CalcMatchRank(txt, out matchRank)) { continue; } int[] match = stringMatcher.GetMatch(txt); name = GetMatchMarkup(treeView, systemAssembly.Name, match, 0); version = GetMatchMarkup(treeView, systemAssembly.Version, match, systemAssembly.Name.Length + 1); } else { name = GLib.Markup.EscapeText(systemAssembly.Name); version = GLib.Markup.EscapeText(systemAssembly.Version); } string pkg = systemAssembly.Package.GetDisplayName(); if (systemAssembly.Package.IsInternalPackage) { pkg += " " + GettextCatalog.GetString("(Provided by {0})", BrandingService.ApplicationName); } store.AppendValues(name, version, systemAssembly, selected, systemAssembly.FullName, pkg, MonoDevelop.Ide.Gui.Stock.Package, matchRank, ReferenceType.Package); } if (showAll) { Solution openSolution = configureProject.ParentSolution; if (openSolution == null) { return; } Dictionary <DotNetProject, bool> references = new Dictionary <DotNetProject, bool> (); foreach (Project projectEntry in openSolution.GetAllSolutionItems <Project>()) { if (projectEntry == configureProject) { continue; } bool selected = IsSelected(ReferenceType.Project, projectEntry.Name, ""); int matchRank = 0; string name; if (stringMatcher != null) { if (!stringMatcher.CalcMatchRank(projectEntry.Name, out matchRank)) { continue; } int[] match = stringMatcher.GetMatch(projectEntry.Name); name = GetMatchMarkup(treeView, projectEntry.Name, match, 0); } else { name = GLib.Markup.EscapeText(projectEntry.Name); } DotNetProject netProject = projectEntry as DotNetProject; if (netProject != null) { if (ProjectReferencePanel.ProjectReferencesProject(references, null, netProject, configureProject.Name)) { continue; } string reason; if (!configureProject.CanReferenceProject(netProject, out reason)) { continue; } } store.AppendValues(name, "", null, selected, projectEntry.Name, "", projectEntry.StockIcon, matchRank, ReferenceType.Project); } foreach (FilePath file in selectDialog.GetRecentFileReferences()) { bool selected = IsSelected(ReferenceType.Assembly, file, ""); int matchRank = 0; string fname = file.FileName; string name; string version = string.Empty; try { string sname = SystemAssemblyService.GetAssemblyName(file); var aname = SystemAssemblyService.ParseAssemblyName(sname); version = aname.Version.ToString(); } catch { continue; } if (stringMatcher != null) { if (!stringMatcher.CalcMatchRank(fname, out matchRank)) { continue; } int[] match = stringMatcher.GetMatch(fname); name = GetMatchMarkup(treeView, fname, match, 0); } else { name = GLib.Markup.EscapeText(fname); } store.AppendValues(name, version, null, selected, (string)file, GLib.Markup.EscapeText(file), MonoDevelop.Ide.Gui.Stock.OpenFolder, matchRank, ReferenceType.Assembly); } } }
internal static Task<BuildResult> Compile (ProgressMonitor monitor, DotNetProject project, BuildData buildData) { return Task<BuildResult>.Run (delegate { ProjectItemCollection items = buildData.Items; BuildResult br = BuildResources (buildData.Configuration, ref items, monitor); if (br != null) return br; return project.OnCompileSources (items, buildData.Configuration, buildData.ConfigurationSelector, monitor); }); }
public async override void OnNodeDrop(object dataObject, DragOperation operation) { // It allows dropping either project references or projects. // Dropping a project creates a new project reference to that project DotNetProject project = dataObject as DotNetProject; if (project != null) { ProjectReference pr = ProjectReference.CreateProjectReference(project); DotNetProject p = CurrentNode.GetParentDataItem(typeof(DotNetProject), false) as DotNetProject; // Circular dependencies are not allowed. if (HasCircularReference(project, p.Name)) { return; } // If the reference already exists, bail out if (ProjectReferencesProject(p, project.Name)) { return; } p.References.Add(pr); await IdeApp.ProjectOperations.SaveAsync(p); return; } // It's dropping a ProjectReference object. ProjectReference pref = dataObject as ProjectReference; ITreeNavigator nav = CurrentNode; if (operation == DragOperation.Move) { NodePosition pos = nav.CurrentPosition; nav.MoveToObject(dataObject); DotNetProject p = nav.GetParentDataItem(typeof(DotNetProject), true) as DotNetProject; nav.MoveToPosition(pos); DotNetProject p2 = nav.GetParentDataItem(typeof(DotNetProject), true) as DotNetProject; p.References.Remove(pref); // Check if there is a cyclic reference after removing from the source project if (pref.ReferenceType == ReferenceType.Project) { DotNetProject pdest = pref.ResolveProject(p.ParentSolution) as DotNetProject; if (pdest == null || ProjectReferencesProject(pdest, p2.Name)) { // Restore the dep p.References.Add(pref); return; } } p2.References.Add(pref); await IdeApp.ProjectOperations.SaveAsync(p); await IdeApp.ProjectOperations.SaveAsync(p2); } else { nav.MoveToParent(typeof(DotNetProject)); DotNetProject p = nav.DataItem as DotNetProject; // Check for cyclic referencies if (pref.ReferenceType == ReferenceType.Project) { DotNetProject pdest = pref.ResolveProject(p.ParentSolution) as DotNetProject; if (pdest == null) { return; } if (HasCircularReference(pdest, p.Name)) { return; } // The reference is already there if (ProjectReferencesProject(p, pdest.Name)) { return; } } p.References.Add((ProjectReference)pref.Clone()); await IdeApp.ProjectOperations.SaveAsync(p); } }
void ProcessProject (DotNetProject p) { foreach (var pref in p.References.Where (r => r.ReferenceType == ReferenceType.Project && r.Reference == Name)) ProcessNewReference (pref); }
public abstract IEnumerable <WebReferenceItem> GetReferenceItems(DotNetProject project);
void ProcessProject (DotNetProject p) { // When the projitems file name doesn't match the shproj file name, the reference we add to the referencing projects // uses the projitems name, not the shproj name. Here we detect such case and re-add the references using the correct name var referencesToFix = p.References.Where (r => r.GetItemsProjectPath () == ProjItemsPath && r.Reference != Name).ToList (); foreach (var r in referencesToFix) { p.References.Remove (r); p.References.Add (new ProjectReference (this)); } foreach (var pref in p.References.Where (r => r.ReferenceType == ReferenceType.Project && r.Reference == Name)) ProcessNewReference (pref); }
public static FilePath GetNuGetAssetsFilePath(this DotNetProject project) { return(project.BaseIntermediateOutputPath.Combine(LockFileFormat.AssetsFileName)); }