当前位置: 首页>>代码示例>>C#>>正文


C# NuGetFramework.IsDesktop方法代码示例

本文整理汇总了C#中NuGet.Frameworks.NuGetFramework.IsDesktop方法的典型用法代码示例。如果您正苦于以下问题:C# NuGetFramework.IsDesktop方法的具体用法?C# NuGetFramework.IsDesktop怎么用?C# NuGetFramework.IsDesktop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NuGet.Frameworks.NuGetFramework的用法示例。


在下文中一共展示了NuGetFramework.IsDesktop方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetDescription

        public ProjectDescription GetDescription(NuGetFramework targetFramework, Project project, LockFileTargetLibrary targetLibrary)
        {
            // This never returns null
            var targetFrameworkInfo = project.GetTargetFramework(targetFramework);
            var dependencies = new List<LibraryRange>(targetFrameworkInfo.Dependencies);            

            // Add all of the project's dependencies
            dependencies.AddRange(project.Dependencies);

            if (targetFramework != null && targetFramework.IsDesktop())
            {
                dependencies.Add(new LibraryRange("mscorlib", LibraryType.ReferenceAssembly, LibraryDependencyType.Build));

                dependencies.Add(new LibraryRange("System", LibraryType.ReferenceAssembly, LibraryDependencyType.Build));

                if (targetFramework.Version >= new Version(3, 5))
                {
                    dependencies.Add(new LibraryRange("System.Core", LibraryType.ReferenceAssembly, LibraryDependencyType.Build));

                    if (targetFramework.Version >= new Version(4, 0))
                    {
                        if (!dependencies.Any(dep => string.Equals(dep.Name, "Microsoft.CSharp", StringComparison.OrdinalIgnoreCase)))
                        {
                            dependencies.Add(new LibraryRange("Microsoft.CSharp", LibraryType.ReferenceAssembly, LibraryDependencyType.Build));
                        }
                    }
                }
            }
            
            if (targetLibrary != null)
            {
                // The lock file entry might have a filtered set of dependencies
                var lockFileDependencies = targetLibrary.Dependencies.ToDictionary(d => d.Id);

                // Remove all non-framework dependencies that don't appear in the lock file entry
                dependencies.RemoveAll(m => !lockFileDependencies.ContainsKey(m.Name) && m.Target != LibraryType.ReferenceAssembly);
            }

            // Mark the library as unresolved if there were specified frameworks
            // and none of them resolved
            bool unresolved = targetFrameworkInfo.FrameworkName == null;

            return new ProjectDescription(
                new LibraryRange(project.Name, LibraryType.Unspecified),
                project,
                dependencies,
                targetFrameworkInfo,
                !unresolved);
        }
开发者ID:ericstj,项目名称:cli,代码行数:49,代码来源:ProjectDependencyProvider.cs

示例2: CompilationOutputFiles

        public CompilationOutputFiles(
            string basePath,
            Project project,
            string configuration,
            NuGetFramework framework)
        {
            BasePath = basePath;
            Project = project;
            Configuration = configuration;
            Framework = framework;
            OutputExtension = FileNameSuffixes.DotNet.DynamicLib;

            var compilationOptions = Project.GetCompilerOptions(framework, configuration);
            if (framework.IsDesktop() && compilationOptions.EmitEntryPoint.GetValueOrDefault())
            {
                OutputExtension = FileNameSuffixes.DotNet.Exe;
            }
        }
开发者ID:krytarowski,项目名称:cli,代码行数:18,代码来源:CompilationOutputFiles.cs

示例3: GetDescription

        public ProjectDescription GetDescription(NuGetFramework targetFramework, Project project)
        {
            // This never returns null
            var targetFrameworkInfo = project.GetTargetFramework(targetFramework);
            var targetFrameworkDependencies = new List<LibraryRange>(targetFrameworkInfo.Dependencies);

            if (targetFramework != null && targetFramework.IsDesktop())
            {
                targetFrameworkDependencies.Add(new LibraryRange("mscorlib", LibraryType.ReferenceAssembly, LibraryDependencyType.Build));

                targetFrameworkDependencies.Add(new LibraryRange("System", LibraryType.ReferenceAssembly, LibraryDependencyType.Build));

                if (targetFramework.Version >= new Version(3, 5))
                {
                    targetFrameworkDependencies.Add(new LibraryRange("System.Core", LibraryType.ReferenceAssembly, LibraryDependencyType.Build));

                    if (targetFramework.Version >= new Version(4, 0))
                    {
                        targetFrameworkDependencies.Add(new LibraryRange("Microsoft.CSharp", LibraryType.ReferenceAssembly, LibraryDependencyType.Build));
                    }
                }
            }

            var dependencies = project.Dependencies.Concat(targetFrameworkDependencies).ToList();

            // Mark the library as unresolved if there were specified frameworks
            // and none of them resolved
            bool unresolved = targetFrameworkInfo.FrameworkName == null;

            return new ProjectDescription(
                new LibraryRange(project.Name, LibraryType.Unspecified),
                project,
                dependencies,
                targetFrameworkInfo,
                !unresolved);
        }
开发者ID:robmen,项目名称:dotnetcli,代码行数:36,代码来源:ProjectDependencyProvider.cs

示例4: ToCompilationSettings

        private static CompilationSettings ToCompilationSettings(CommonCompilerOptions compilerOptions,
                                                                 NuGetFramework targetFramework,
                                                                 string projectDirectory)
        {
            var options = GetCompilationOptions(compilerOptions, projectDirectory);

            // Disable 1702 until roslyn turns this off by default
            options = options.WithSpecificDiagnosticOptions(new Dictionary<string, ReportDiagnostic>
            {
                { "CS1701", ReportDiagnostic.Suppress }, // Binding redirects
                { "CS1702", ReportDiagnostic.Suppress },
                { "CS1705", ReportDiagnostic.Suppress }
            });

            AssemblyIdentityComparer assemblyIdentityComparer =
                targetFramework.IsDesktop() ?
                DesktopAssemblyIdentityComparer.Default :
                null;

            options = options.WithAssemblyIdentityComparer(assemblyIdentityComparer);

            LanguageVersion languageVersion;
            if (!Enum.TryParse<LanguageVersion>(value: compilerOptions.LanguageVersion,
                                                ignoreCase: true,
                                                result: out languageVersion))
            {
                languageVersion = LanguageVersion.CSharp6;
            }

            var settings = new CompilationSettings
            {
                LanguageVersion = languageVersion,
                Defines = compilerOptions.Defines ?? Enumerable.Empty<string>(),
                CompilationOptions = options
            };

            return settings;
        }
开发者ID:yonglehou,项目名称:cli-1,代码行数:38,代码来源:ProjectJsonWorkspace.cs

示例5: ToCompilationSettings

        private static CompilationSettings ToCompilationSettings(CommonCompilerOptions compilerOptions,
                                                                 NuGetFramework targetFramework,
                                                                 string projectDirectory)
        {
            var options = GetCompilationOptions(compilerOptions, projectDirectory);

            options = options.WithSpecificDiagnosticOptions(compilerOptions.SuppressWarnings.ToDictionary(
                suppress => suppress, _ => ReportDiagnostic.Suppress));

            AssemblyIdentityComparer assemblyIdentityComparer =
                targetFramework.IsDesktop() ?
                DesktopAssemblyIdentityComparer.Default :
                null;

            options = options.WithAssemblyIdentityComparer(assemblyIdentityComparer);

            LanguageVersion languageVersion;
            if (!Enum.TryParse<LanguageVersion>(value: compilerOptions.LanguageVersion,
                                                ignoreCase: true,
                                                result: out languageVersion))
            {
                languageVersion = LanguageVersion.CSharp6;
            }

            var settings = new CompilationSettings
            {
                LanguageVersion = languageVersion,
                Defines = compilerOptions.Defines ?? Enumerable.Empty<string>(),
                CompilationOptions = options
            };

            return settings;
        }
开发者ID:noahfalk,项目名称:cli,代码行数:33,代码来源:ProjectJsonWorkspace.cs

示例6: GetProjectOutput

        private static string GetProjectOutput(Project project, NuGetFramework framework, string configuration, string outputPath)
        {
            var compilationOptions = project.GetCompilerOptions(framework, configuration);
            var outputExtension = ".dll";

            if (framework.IsDesktop() && compilationOptions.EmitEntryPoint.GetValueOrDefault())
            {
                outputExtension = ".exe";
            }

            return Path.Combine(outputPath, project.Name + outputExtension);
        }
开发者ID:shahid-pk,项目名称:cli,代码行数:12,代码来源:Program.cs

示例7: GetLibrary

        private static Library GetLibrary(LibraryExport export,
            NuGetFramework target,
            string configuration,
            bool runtime,
            IDictionary<string, Dependency> dependencyLookup)
        {
            var type = export.Library.Identity.Type.Value.ToLowerInvariant();

            var serviceable = (export.Library as PackageDescription)?.Library.IsServiceable ?? false;
            var libraryDependencies = new List<Dependency>();

            var libraryAssets = runtime ? export.RuntimeAssemblies : export.CompilationAssemblies;

            foreach (var libraryDependency in export.Library.Dependencies)
            {
                Dependency dependency;
                if (dependencyLookup.TryGetValue(libraryDependency.Name, out dependency))
                {
                    libraryDependencies.Add(dependency);
                }
            }

            string[] assemblies;
            if (type == "project")
            {
                var isExe = ((ProjectDescription) export.Library)
                    .Project
                    .GetCompilerOptions(target, configuration)
                    .EmitEntryPoint
                    .GetValueOrDefault(false);

                isExe &= target.IsDesktop();

                assemblies = new[] { export.Library.Identity.Name + (isExe ? ".exe": ".dll") };
            }
            else
            {
                assemblies = libraryAssets.Select(libraryAsset => libraryAsset.RelativePath).ToArray();
            }

            if (runtime)
            {
                return new RuntimeLibrary(
                    type,
                    export.Library.Identity.Name,
                    export.Library.Identity.Version.ToString(),
                    export.Library.Hash,
                    assemblies,
                    libraryDependencies.ToArray(),
                    serviceable
                    );
            }
            else
            {
                return new CompilationLibrary(
                    type,
                    export.Library.Identity.Name,
                    export.Library.Identity.Version.ToString(),
                    export.Library.Hash,
                    assemblies,
                    libraryDependencies.ToArray(),
                    serviceable
                   );
            }
        }
开发者ID:kyulee1,项目名称:cli,代码行数:65,代码来源:DependencyContextBuilder.cs

示例8: GetFrameworkInformation

        private static FrameworkInformation GetFrameworkInformation(NuGetFramework targetFramework, string referenceAssembliesPath)
        {
            // Check for legacy frameworks
            if (targetFramework.IsDesktop() && targetFramework.Version <= new Version(3, 5))
            {
                return GetLegacyFrameworkInformation(targetFramework, referenceAssembliesPath);
            }

            var basePath = Path.Combine(referenceAssembliesPath,
                                        targetFramework.Framework,
                                        "v" + GetDisplayVersion(targetFramework));

            if (!string.IsNullOrEmpty(targetFramework.Profile))
            {
                basePath = Path.Combine(basePath, "Profile", targetFramework.Profile);
            }

            var version = new DirectoryInfo(basePath);
            if (!version.Exists)
            {
                return null;
            }

            return GetFrameworkInformation(version, targetFramework);
        }
开发者ID:swgillespie,项目名称:cli,代码行数:25,代码来源:FrameworkReferenceResolver.cs

示例9: GetProjectOutputName

        private string GetProjectOutputName(NuGetFramework framework)
        {
            var compilationOptions = Project.GetCompilerOptions(framework, Configuration);
            var outputExtension = ".dll";

            if (framework.IsDesktop() && compilationOptions.EmitEntryPoint.GetValueOrDefault())
            {
                outputExtension = ".exe";
            }

            return Project.Name + outputExtension;
        }                
开发者ID:xier2012,项目名称:cli,代码行数:12,代码来源:PackageGenerator.cs

示例10: GetDependencies

        private static IList<LibraryDependency> GetDependencies(NuGetFramework targetFramework,
            PackageDependencyGroup dependencies,
            FrameworkSpecificGroup frameworkAssemblies)
        {
            var libraryDependencies = new List<LibraryDependency>();

            if (dependencies != null)
            {
                foreach (var d in dependencies.Packages)
                {
                    libraryDependencies.Add(new LibraryDependency
                        {
                            LibraryRange = new LibraryRange
                                {
                                    Name = d.Id,
                                    VersionRange = d.VersionRange
                                }
                        });
                }
            }

            if (frameworkAssemblies == null)
            {
                return libraryDependencies;
            }

            if (!targetFramework.IsDesktop())
            {
                // REVIEW: This isn't 100% correct since none *can* mean 
                // any in theory, but in practice it means .NET full reference assembly
                // If there's no supported target frameworks and we're not targeting
                // the desktop framework then skip it.

                // To do this properly we'll need all reference assemblies supported
                // by each supported target framework which isn't always available.
                return libraryDependencies;
            }

            foreach (var name in frameworkAssemblies.Items)
            {
                libraryDependencies.Add(new LibraryDependency
                    {
                        LibraryRange = new LibraryRange
                            {
                                Name = name,
                                TypeConstraint = LibraryTypes.Reference
                            }
                    });
            }

            return libraryDependencies;
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:52,代码来源:SourceRepositoryDependencyProvider.cs

示例11: GetLibrary

        public Library GetLibrary(LibraryRange libraryRange, NuGetFramework targetFramework)
        {
            var name = libraryRange.Name;

            PackageSpec packageSpec;

            // Can't find a project file with the name so bail
            if (!_resolver.TryResolvePackageSpec(name, out packageSpec))
            {
                return null;
            }

            // This never returns null
            var targetFrameworkInfo = packageSpec.GetTargetFramework(targetFramework);
            var targetFrameworkDependencies = targetFrameworkInfo.Dependencies;

            if (targetFramework.IsDesktop())
            {
                targetFrameworkDependencies.Add(new LibraryDependency
                {
                    LibraryRange = new LibraryRange
                    {
                        Name = "mscorlib",
                        TypeConstraint = LibraryTypes.Reference
                    }
                });

                targetFrameworkDependencies.Add(new LibraryDependency
                {
                    LibraryRange = new LibraryRange
                    {
                        Name = "System",
                        TypeConstraint = LibraryTypes.Reference
                    }
                });

                targetFrameworkDependencies.Add(new LibraryDependency
                {
                    LibraryRange = new LibraryRange
                    {
                        Name = "System.Core",
                        TypeConstraint = LibraryTypes.Reference
                    }
                });

                targetFrameworkDependencies.Add(new LibraryDependency
                {
                    LibraryRange = new LibraryRange
                    {
                        Name = "Microsoft.CSharp",
                        TypeConstraint = LibraryTypes.Reference
                    }
                });
            }

            var dependencies = packageSpec.Dependencies.Concat(targetFrameworkDependencies).ToList();

            if (string.Equals(_projectReference?.Name, libraryRange.Name, StringComparison.OrdinalIgnoreCase))
            {
                dependencies.AddRange(_projectReference.ExternalProjectReferences
                    .Select(reference => new LibraryDependency
                    {
                        LibraryRange = new LibraryRange
                        {
                            Name = reference,
                            VersionRange = VersionRange.All,
                            TypeConstraint = LibraryTypes.ExternalProject
                        }
                    }));
            }

            // Mark the library as unresolved if there were specified frameworks
            // and none of them resolved
            var unresolved = targetFrameworkInfo.FrameworkName == null &&
                             packageSpec.TargetFrameworks.Any();

            var library = new Library
            {
                LibraryRange = libraryRange,
                Identity = new LibraryIdentity
                {
                    Name = packageSpec.Name,
                    Version = packageSpec.Version,
                    Type = LibraryTypes.Project,
                },
                Path = packageSpec.FilePath,
                Dependencies = dependencies,
                Resolved = !unresolved,
                [KnownLibraryProperties.PackageSpec] = packageSpec
            };

            return library;
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:93,代码来源:PackageSpecReferenceDependencyProvider.cs

示例12: GetProjectDependenciesCommandResolver

        private ICommandResolver GetProjectDependenciesCommandResolver(NuGetFramework framework)
        {
            var environment = new EnvironmentProvider();

            if (framework.IsDesktop())
            {
                IPlatformCommandSpecFactory platformCommandSpecFactory = null;
                if (RuntimeEnvironment.OperatingSystemPlatform == Platform.Windows)
                {
                    platformCommandSpecFactory = new WindowsExePreferredCommandSpecFactory();
                }
                else
                {
                    platformCommandSpecFactory = new GenericPlatformCommandSpecFactory();
                }

                return new OutputPathCommandResolver(environment, platformCommandSpecFactory);
            }
            else
            {
                var packagedCommandSpecFactory = new PackagedCommandSpecFactory();
                return new ProjectDependenciesCommandResolver(environment, packagedCommandSpecFactory);
            }
        }
开发者ID:akrisiun,项目名称:dotnet-cli,代码行数:24,代码来源:ProjectDependenciesCommandFactory.cs


注:本文中的NuGet.Frameworks.NuGetFramework.IsDesktop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。