GetProjectReferences() public method

Returns all project references from current project.
public GetProjectReferences ( ) : List
return List
		private void ConvertProjectReferences(ProjectDocument project)
		{
			if (Path.GetExtension(Args.ProjectFile) == ".sfproj")
				return;

			Console.Write("Resolving project references... ");

			foreach (var reference in project.GetProjectReferences())
			{
				string name = null;
				foreach (var check in Util.LocalNameToProjectNames(reference.Name))
				{
					if (m_log.ContainsKey(check))
					{
						name = check;
						break;
					}
				}

				if (name == null)
				{
					throw new InvalidOperationException(
						$@"Referenced project '{reference.Name}' was not found in 'packages.config'.
Please add it as a NuGet reference first, and only after that you can convert it into project reference.");
				}

				m_log[name].ProjectReference = true;

				var framework = m_checker.TargetFramework(name);
				reference.ConvertToBinary(framework, name);
			}

			Console.WriteLine("OK");
		}
Example #2
0
		private static void SetupRelatedProjects()
		{
			string path;
			switch (Args.ProjectType)
			{
				case ProjectType.CloudService:
					path = Paths.CloudProjectFile;
					break;

				case ProjectType.FabricApplication:
					path = Paths.FabricProjectFile;
					break;

				default:
					return;
			}

			if (String.IsNullOrEmpty(Args.RelatedPath))
				throw new InvalidOperationException("Configuration argument 'RelatedPath' is not set.");

			if (String.IsNullOrEmpty(Args.ReferencesPath))
				throw new InvalidOperationException("Configuration argument 'ReferencesPath' is not set.");

			Args.RelatedPath.CreateDirectoryIfNotExists();
			Args.ReferencesPath.CreateDirectoryIfNotExists();

			Console.Write("Converting paths for related projects... ");

			var project = new ProjectDocument(path);

			var references = project.GetProjectReferences();
			if (references.Count == 0)
				throw new InvalidOperationException("It is strange that cloud service or fabric application does not have any referenced projects.");

			var log = new LogPackages();
			foreach (var reference in references)
			{
				SetupRelatedProject(reference, log);
			}

			project.Save();
			Console.WriteLine("OK");

			log.Report();

			Console.Write("Saving local references... ");
			log.SaveReferences(Args.ReferencesPath);
			Console.WriteLine("OK");

			Console.Write("Saving packages summary... ");
			log.SaveSummary(Args.TempPath);
			Console.WriteLine("OK");
		}
		private void SetupRelatedProjects(ProjectDocument project)
		{
			if (Path.GetExtension(Args.ProjectFile) != ".sfproj")
				return;

			Console.WriteLine("Converting paths for related projects...");

			if (String.IsNullOrEmpty(Args.RelatedPath))
				throw new InvalidOperationException("Related path is not set.");

			var references = project.GetProjectReferences();
			if (references.Count == 0)
				throw new InvalidOperationException("Cannot find any related projects from a project file.");

			foreach (var reference in references)
			{
				SetupRelatedProject(reference);
			}

			Console.WriteLine("OK");
		}