/// <inheritdoc />
        public Task <string> GetNuGetProjectSafeNameAsync(NuGetProject nuGetProject)
        {
            if (!(nuGetProject is NuGetPluginProject <TMeta> pluginProject))
            {
                throw new InvalidOperationException(
                          $"Invalid project type {nuGetProject.GetType().FullName}. Should be {typeof(NuGetPluginProject<TMeta>).FullName}.");
            }

            return(Task.FromResult(pluginProject.Plugin.Id));
        }
Ejemplo n.º 2
0
        private async Task <(InstalledPackageResultStatus, IReadOnlyCollection <NuGetInstalledPackage>)> GetInstalledPackagesAsync(NuGetProject project, CancellationToken cancellationToken)
        {
            // NuGetProject type that doesn't extend MSBuildNuGetProject or BuildIntegratedNuGetProject?
            // At the time of writing, this codepath is impossible to reach.

            NuGetInstalledPackage ToNuGetInstalledPackage(PackageReference package)
            {
                string id      = package.PackageIdentity.Id;
                string version = package.PackageIdentity.Version?.OriginalVersion
                                 ?? package.PackageIdentity.Version?.ToNormalizedString()
                                 ?? package.AllowedVersions?.MinVersion?.OriginalVersion
                                 ?? package.AllowedVersions?.MinVersion?.ToNormalizedString();
                string requestedRange   = package.AllowedVersions.OriginalString ?? version;
                string installPath      = null;
                bool   directDependency = true;

                return(NuGetContractsFactory.CreateNuGetInstalledPackage(id, requestedRange, version, installPath, directDependency));
            }

            var status = InstalledPackageResultStatus.Unknown;

            var notImplementedException = new NotImplementedException($"Project type {project.GetType().Name} is not implemented");
            await TelemetryUtility.PostFaultAsync(notImplementedException, nameof(NuGetProjectService));

            IEnumerable <PackageReference> projectPackages = await project.GetInstalledPackagesAsync(cancellationToken);

            List <NuGetInstalledPackage> installedPackages =
                projectPackages.Select(ToNuGetInstalledPackage).ToList();

            return(status, installedPackages);
        }
Ejemplo n.º 3
0
        public static IDotNetProject GetDotNetProject(this NuGetProject project)
        {
            var hasProject = project as IHasDotNetProject;

            if (hasProject != null)
            {
                return(hasProject.Project);
            }

            throw new ApplicationException(string.Format("Unsupported NuGetProject type: {0}", project.GetType().FullName));
        }
        public void SaveProject(NuGetProject nuGetProject)
        {
            var hasProject = nuGetProject as IHasDotNetProject;

            if (hasProject != null)
            {
                hasProject.SaveProject().Wait();
                return;
            }

            throw new ApplicationException(string.Format("Unsupported NuGetProject type: {0}", nuGetProject.GetType().FullName));
        }
Ejemplo n.º 5
0
        public void SaveProject(NuGetProject nuGetProject)
        {
            IHasDotNetProject hasProject = null;

            var msbuildProject = nuGetProject as MSBuildNuGetProject;

            if (msbuildProject != null)
            {
                hasProject = msbuildProject.MSBuildNuGetProjectSystem as IHasDotNetProject;
            }

            if (hasProject == null)
            {
                hasProject = nuGetProject as IHasDotNetProject;
            }

            if (hasProject != null)
            {
                hasProject.SaveProject().Wait();
                return;
            }

            throw new ApplicationException(string.Format("Unsupported NuGetProject type: {0}", nuGetProject.GetType().FullName));
        }
Ejemplo n.º 6
0
        public void SaveProject(NuGetProject nuGetProject)
        {
            var msbuildProject = nuGetProject as MSBuildNuGetProject;

            if (msbuildProject != null)
            {
                var projectSystem = msbuildProject.MSBuildNuGetProjectSystem as MonoDevelopMSBuildNuGetProjectSystem;
                projectSystem.SaveProject().Wait();

                return;
            }

            var buildIntegratedProject = nuGetProject as BuildIntegratedProjectSystem;

            if (buildIntegratedProject != null)
            {
                buildIntegratedProject.SaveProject().Wait();
                return;
            }

            throw new ApplicationException(string.Format("Unsupported NuGetProject type: {0}", nuGetProject.GetType().FullName));
        }
		public void SaveProject (NuGetProject nuGetProject)
		{
			var msbuildProject = nuGetProject as MSBuildNuGetProject;
			if (msbuildProject != null) {
				var projectSystem = msbuildProject.MSBuildNuGetProjectSystem as MonoDevelopMSBuildNuGetProjectSystem;
				projectSystem.SaveProject ().Wait ();

				return;
			}

			var buildIntegratedProject = nuGetProject as BuildIntegratedProjectSystem;
			if (buildIntegratedProject != null) {
				buildIntegratedProject.SaveProject ().Wait ();
				return;
			}

			var hasProject = nuGetProject as IHasDotNetProject;
			if (hasProject != null) {
				hasProject.SaveProject ().Wait ();
				return;
			}

			throw new ApplicationException (string.Format ("Unsupported NuGetProject type: {0}", nuGetProject.GetType ().FullName));
		}