protected override async Task <PackageBase> DoResolve(ObservableCollection <PackageBase> packages, string packageId, int depth, CancellationToken token, FrameworkName targetFramework = null, IVersionSpec versionSpec = null) { var result = packages.FirstOrDefault(pack => pack.PackageId == packageId); if (result != null) { return(result); } result = new SolutionPackage(packageId, new SemanticVersion(new Version())) { Depth = depth }; packages.Add(result); if (token.IsCancellationRequested) { return(null); } using (var solutionFileReader = new SolutionFileReader(packageId)) { var readSolutionFile = solutionFileReader.ReadSolutionFile(); var basePath = Path.GetDirectoryName(packageId); if (string.IsNullOrEmpty(basePath)) { return(null); } foreach (var project in readSolutionFile.Projects) { var projectPath = Path.Combine(basePath, project.RelativePath); var resolutionEngine = m_ResolutionFactory.GetResolutionEngine(projectPath); if (resolutionEngine == null) { continue; } var dependingPackage = await resolutionEngine.Resolve(packages, projectPath, depth + 1, token, targetFramework, versionSpec); result.Dependencies.Add(dependingPackage); if (token.IsCancellationRequested) { break; } } } return(result); }
public void WriteNewSlnFile(Sln slnObject) { _sln = slnObject; _slnFile = new SlnFile(); // or you can read sln file like below using (SolutionFileReader reader = new SolutionFileReader(_sln.ObjectFullPath)) _slnFile = reader.ReadSolutionFile(); AddHeaders(); AddGlobalSections(); // add projects List <SolutionNode> sns = _sln.GetAllSubItemsOf(typeof(SolutionFolder), typeof(ProjectNode)); foreach (SolutionNode sn in sns) { _slnFile.Projects.Add(CreateProject(sn)); } using (SolutionFileWriter writer = new SolutionFileWriter(_sln.ObjectFullPath)) writer.WriteSolutionFile(_slnFile); }