public void FromCrAssembly(Prj prj, ProjectAssembly asm) { this.path = asm.Path; this.asmDef = asm.Resolve(prj.GetBasePath()); this.IsExecutable = this.asmDef.MainModule.EntryPoint != null; this.isMain = asm.IsMain; }
private void AddAssemblyReference(ProjectAssembly projectAssembly) { Assembly assembly = projectAssembly.ReferenceAssembly ?? projectAssembly.RuntimeAssembly; if (!(assembly != (Assembly)null)) { return; } try { if (assembly != (Assembly)null) { this.projectResolver.AddExternalReference(assembly); if (CodeProject.HasProjectAssemblyChangedLocation(projectAssembly.FullName, assembly)) { this.asyncManager.RefreshAssembly(projectAssembly); } } } catch (ApplicationException ex) { return; } this.activeReferences.Add(projectAssembly); if (!(assembly != (Assembly)null) || assembly.IsDynamic) { return; } CodeProject.assemblyToLocationMap[projectAssembly.FullName] = assembly.Location; }
protected virtual AssemblySetting MarkAssembly(ProjectAssembly asm, Marking mark) { AssemblySetting ret = new AssemblySetting(asm.Resolve(cr.param.Project.BasePath)); ret.IsMain = asm.IsMain; ApplyRules(ret.Assembly, mark); return(ret); }
public ProjectAssembly ToCrAssembly() { ProjectAssembly ret = new ProjectAssembly(); ret.Path = path; ret.IsMain = isMain; return(ret); }
private void RefreshAssemblyReference(ProjectAssembly assembly) { Assembly assembly1 = assembly.ReferenceAssembly ?? assembly.RuntimeAssembly; if (!assembly1.IsDynamic) { CodeProject.assemblyToLocationMap[assembly.FullName] = assembly1.Location; } AssemblyCodeRepository.Refresh(assembly1, this.projectResolver); }
protected override bool CreateProjectItem() { IProject project = this.targetedProject != null ? this.targetedProject : ProjectCommandExtensions.SelectedProjectOrNull((IProjectCommand)this); if (project == null) { return(false); } bool flag = false; string[] filesToImport = this.GetFilesToImport(this.importedPathFilter != null ? this.importedPathFilter : this.GetImportFolder()); if (filesToImport != null && filesToImport.Length > 0) { foreach (string str in filesToImport) { string withoutExtension = Path.GetFileNameWithoutExtension(str); ProjectAssembly projectAssembly = project.ReferencedAssemblies.Find(withoutExtension); if (projectAssembly != null && !projectAssembly.IsImplicitlyResolved) { ProjectCommandExtensions.DisplayCommandFailedMessage((IProjectCommand)this, string.Format((IFormatProvider)CultureInfo.CurrentUICulture, StringTable.ReferenceExistsErrorDialogMessage, new object[2] { (object)str, (object)withoutExtension })); } else { IProjectItem projectItem = project.AddAssemblyReference(str, true); if (projectItem != null) { ProjectCommandExtensions.ProjectManager((IProjectCommand)this).DefaultImportPath = Path.GetDirectoryName(str); ProjectCommandExtensions.ProjectManager((IProjectCommand)this).ItemSelectionSet.Clear(); ProjectCommandExtensions.ProjectManager((IProjectCommand)this).ItemSelectionSet.ToggleSelection((IDocumentItem)projectItem); } ProjectXamlContext projectContext = ProjectXamlContext.GetProjectContext(project); if (projectContext != null) { projectContext.EnsureAssemblyReferenced(str); } if (projectItem != null) { flag = true; } } } } return(flag); }
public static void Start(Shell cont) { _instance = cont; string path = Path.Combine(AppRootPath, "Logs"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } Logger.Set(ProjectAssembly.GetName().Name, path); ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return(true); }; ServicePointManager.Expect100Continue = true; }
private AssemblySetting _MarkAssembly(ProjectAssembly asm, Marking mark) { AssemblySetting ret = MarkAssembly(asm, mark); ret.GlobalParameters = mark.CurrentConfusions; using (mark.Level()) { List <ModuleSetting> modSettings = new List <ModuleSetting>(); foreach (var m in ret.Assembly.Modules) { using (mark.Level()) MarkModule(ret, m, mark, modSettings); } ret.Modules = modSettings.ToArray(); return(ret); } }
public static string AssemblyLocation(IType type, IProject project) { ProjectAssembly projectAssembly = project.ReferencedAssemblies.Find(type.RuntimeAssembly.Name); if (projectAssembly != null && projectAssembly.ProjectItem != null) { return(projectAssembly.ProjectItem.DocumentReference.Path); } if (projectAssembly == project.TargetAssembly) { return(project.FullTargetPath); } IUnreferencedType unreferencedType; if ((unreferencedType = type as IUnreferencedType) != null) { return(unreferencedType.AssemblyLocation); } return(type.RuntimeType.Assembly.Location); }
public static void Start(Shell cont) { App = cont; Logger.Set(ProjectAssembly.GetName().Name); AppDomain.CurrentDomain.ProcessExit += (e, s) => { App.Dispose(); }; string envName = EnvironmentName == null ? "" : "-" + EnvironmentName; Console.Title = ProjectAssembly.GetName().Name + "-v" + ProjectAssembly.GetVersionString() + envName; if (App.useTransporter) { Transporter.Start(); } if (App.useTimedJobs) { App.StartJobs(); } cont.OnReady(); }
internal static string GetAssemblyOutputFilePath(ProjectAssembly projectAssembly) { string filePath = projectAssembly.FilePath; string fileName; if (!string.IsNullOrEmpty(projectAssembly.Name)) { fileName = projectAssembly.Name + Path.GetExtension(filePath); } else { fileName = Path.GetFileName(filePath); } if (!string.IsNullOrEmpty(projectAssembly.OutputPath)) { return(Path.Combine(projectAssembly.OutputPath, fileName)); } else { return(Path.Combine(Path.GetDirectoryName(filePath), fileName)); } }
public override bool Execute() { var filesToRemove = new List <ITaskItem>(); var assetCandidates = new List <ITaskItem>(); try { if (ProjectAssembly.Length != 1) { Log.LogError("Invalid number of project assemblies '{0}'", string.Join("," + Environment.NewLine, ProjectAssembly.Select(a => a.ItemSpec))); return(true); } if (ProjectDebugSymbols.Length > 1) { Log.LogError("Invalid number of symbol assemblies '{0}'", string.Join("," + Environment.NewLine, ProjectDebugSymbols.Select(a => a.ItemSpec))); return(true); } for (int i = 0; i < Candidates.Length; i++) { var candidate = Candidates[i]; if (ShouldFilterCandidate(candidate, TimeZoneSupport, InvariantGlobalization, CopySymbols, out var reason)) { Log.LogMessage("Skipping asset '{0}' because '{1}'", candidate.ItemSpec, reason); filesToRemove.Add(candidate); continue; } var satelliteAssembly = SatelliteAssemblies.FirstOrDefault(s => s.ItemSpec == candidate.ItemSpec); if (satelliteAssembly != null) { var inferredCulture = satelliteAssembly.GetMetadata("DestinationSubDirectory").Trim('\\', '/'); Log.LogMessage("Found satellite assembly '{0}' asset for candidate '{1}' with inferred culture '{2}'", satelliteAssembly.ItemSpec, candidate.ItemSpec, inferredCulture); var assetCandidate = new TaskItem(satelliteAssembly); assetCandidate.SetMetadata("AssetKind", "Build"); assetCandidate.SetMetadata("AssetRole", "Related"); assetCandidate.SetMetadata("AssetTraitName", "Culture"); assetCandidate.SetMetadata("AssetTraitValue", inferredCulture); assetCandidate.SetMetadata("RelativePath", $"_framework/{inferredCulture}/{satelliteAssembly.GetMetadata("FileName")}{satelliteAssembly.GetMetadata("Extension")}"); assetCandidate.SetMetadata("RelatedAsset", Path.GetFullPath(Path.Combine(OutputPath, "wwwroot", "_framework", Path.GetFileName(assetCandidate.GetMetadata("ResolvedFrom"))))); assetCandidates.Add(assetCandidate); continue; } var destinationSubPath = candidate.GetMetadata("DestinationSubPath"); if (candidate.GetMetadata("FileName") == "dotnet" && candidate.GetMetadata("Extension") == ".js") { var itemHash = FileHasher.GetFileHash(candidate.ItemSpec); var cacheBustedDotNetJSFileName = $"dotnet.{BundledNETCoreAppPackageVersion}.{itemHash}.js"; var originalFileFullPath = Path.GetFullPath(candidate.ItemSpec); var originalFileDirectory = Path.GetDirectoryName(originalFileFullPath); var cacheBustedDotNetJSFullPath = Path.Combine(originalFileDirectory, cacheBustedDotNetJSFileName); var newDotNetJs = new TaskItem(cacheBustedDotNetJSFullPath, candidate.CloneCustomMetadata()); newDotNetJs.SetMetadata("OriginalItemSpec", candidate.ItemSpec); var newRelativePath = $"_framework/{cacheBustedDotNetJSFileName}"; newDotNetJs.SetMetadata("RelativePath", newRelativePath); newDotNetJs.SetMetadata("AssetTraitName", "BlazorWebAssemblyResource"); newDotNetJs.SetMetadata("AssetTraitValue", "native"); assetCandidates.Add(newDotNetJs); continue; } else if (string.IsNullOrEmpty(destinationSubPath)) { var relativePath = candidate.GetMetadata("FileName") + candidate.GetMetadata("Extension"); candidate.SetMetadata("RelativePath", $"_framework/{relativePath}"); } else { candidate.SetMetadata("RelativePath", $"_framework/{destinationSubPath}"); } var culture = candidate.GetMetadata("Culture"); if (!string.IsNullOrEmpty(culture)) { candidate.SetMetadata("AssetKind", "Build"); candidate.SetMetadata("AssetRole", "Related"); candidate.SetMetadata("AssetTraitName", "Culture"); candidate.SetMetadata("AssetTraitValue", culture); var fileName = candidate.GetMetadata("FileName"); var suffixIndex = fileName.Length - ".resources".Length; var relatedAssetPath = Path.GetFullPath(Path.Combine( OutputPath, "wwwroot", "_framework", fileName.Substring(0, suffixIndex) + ProjectAssembly[0].GetMetadata("Extension"))); candidate.SetMetadata("RelatedAsset", relatedAssetPath); Log.LogMessage("Found satellite assembly '{0}' asset for inferred candidate '{1}' with culture '{2}'", candidate.ItemSpec, relatedAssetPath, culture); } assetCandidates.Add(candidate); } var intermediateAssembly = new TaskItem(ProjectAssembly[0]); intermediateAssembly.SetMetadata("RelativePath", $"_framework/{intermediateAssembly.GetMetadata("FileName")}{intermediateAssembly.GetMetadata("Extension")}"); assetCandidates.Add(intermediateAssembly); if (ProjectDebugSymbols.Length > 0) { var debugSymbols = new TaskItem(ProjectDebugSymbols[0]); debugSymbols.SetMetadata("RelativePath", $"_framework/{debugSymbols.GetMetadata("FileName")}{debugSymbols.GetMetadata("Extension")}"); assetCandidates.Add(debugSymbols); } for (int i = 0; i < ProjectSatelliteAssemblies.Length; i++) { var projectSatelliteAssembly = ProjectSatelliteAssemblies[i]; var candidateCulture = projectSatelliteAssembly.GetMetadata("Culture"); Log.LogMessage( "Found satellite assembly '{0}' asset for project '{1}' with culture '{2}'", projectSatelliteAssembly.ItemSpec, intermediateAssembly.ItemSpec, candidateCulture); var assetCandidate = new TaskItem(Path.GetFullPath(projectSatelliteAssembly.ItemSpec), projectSatelliteAssembly.CloneCustomMetadata()); var projectAssemblyAssetPath = Path.GetFullPath(Path.Combine( OutputPath, "wwwroot", "_framework", ProjectAssembly[0].GetMetadata("FileName") + ProjectAssembly[0].GetMetadata("Extension"))); var normalizedPath = assetCandidate.GetMetadata("TargetPath").Replace('\\', '/'); assetCandidate.SetMetadata("AssetKind", "Build"); assetCandidate.SetMetadata("AssetRole", "Related"); assetCandidate.SetMetadata("AssetTraitName", "Culture"); assetCandidate.SetMetadata("AssetTraitValue", candidateCulture); assetCandidate.SetMetadata("RelativePath", Path.Combine("_framework", normalizedPath)); assetCandidate.SetMetadata("RelatedAsset", projectAssemblyAssetPath); assetCandidates.Add(assetCandidate); } for (var i = 0; i < assetCandidates.Count; i++) { var candidate = assetCandidates[i]; ApplyUniqueMetadataProperties(candidate); } } catch (Exception ex) { Log.LogError(ex.ToString()); return(false); } FilesToRemove = filesToRemove.ToArray(); AssetCandidates = assetCandidates.ToArray(); return(!Log.HasLoggedErrors); }
public void RefreshAssembly(ProjectAssembly assembly) { this.actions.Add((AsyncProcess) new DelegateAsyncProcess((Action <object, DoWorkEventArgs>)((sender, args) => this.codeProject.RefreshAssemblyReference(assembly))), this.startProcessing); }
private void RemoveAssemblyReference(ProjectAssembly assembly) { this.activeReferences.Remove(assembly); this.projectResolver.RemoveExternalReference(assembly.FullName); }
public Shell() { ProjectAssembly = GetType().Assembly; SolutionFolder = AppDomain.CurrentDomain.BaseDirectory.GetBeforeFirst("\\" + ProjectAssembly.GetName().Name); EnvironmentName = GetEnvironmentName(); }
public void Initialize(IEnumerable <ProjectAssembly> tracking) { try { var pas = tracking as ProjectAssembly[] ?? tracking.ToArray(); var opas = pas.OrderBy(a => a.FullPath).ThenBy(a => a.RelativePath).ToArray(); var projFolder = ToolboxApp.Project.State.ProjectFolder; if (string.IsNullOrWhiteSpace(projFolder)) { return; } Assemblies.Clear(); // Assemblies.AddRange() causes exception? foreach (var pa in opas) { Assemblies.Add(pa); } // find assemblies in project folder var comparer = new ProjectAssemblyComparer(); var allFiles = Directory.GetFiles(projFolder, $"*{SupportedFileTypes.AssemblyExtension}", SearchOption.AllDirectories); var found = new List <ProjectAssembly>(); foreach (var file in allFiles) { var rp = file.Replace(projFolder, string.Empty); var assembly = new ProjectAssembly { FullPath = file, RelativePath = rp, FileName = Path.GetFileName(file), Directory = Path.GetDirectoryName(rp) }; found.Add(assembly); } var orderedFound = found.OrderBy(a => a.FullPath).ThenBy(a => a.RelativePath); // add assemblies in project folder foreach (var assembly in orderedFound) { if (!Assemblies.Contains(assembly, comparer)) { Assemblies.Add(assembly); } } // check if project file exists and include assemblies if (_fs.FileExist(ToolboxApp.Project.State.XenProjectFilePath)) { var proj = new XenProjectFile(_fs); var loaded = proj.Load(ToolboxApp.Project.State.XenProjectFilePath); if (!loaded) { ToolboxApp.Log.Warn($"Unable to load project file: {ToolboxApp.Project.State.XenProjectFilePath}."); } if (proj.Assemblies != null) { foreach (var pa in proj.Assemblies) { var fp = $"{ToolboxApp.Project.State.XenProjectFilePath}{pa.RelativePath}"; if (string.IsNullOrWhiteSpace(fp)) { continue; } var match = Assemblies.FirstOrDefault(a => a.FullPath == fp); if (match != null) { match.Include = true; } } } } else { ToolboxApp.Log.Info($"{ToolboxApp.Project.State.XenProjectFilePath} doesn't exist."); } } catch (Exception ex) { ToolboxApp.Log.Error(ex, "Error retrieving project assemblies."); } }