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


C# Project.GetTargetFrameworkName方法代码示例

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


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

示例1: AddBindingRedirects

        private static IEnumerable<AssemblyBinding> AddBindingRedirects(
            Project project, 
            IFileSystemProvider fileSystemProvider, 
            AppDomain domain, 
            IDictionary<string, HashSet<string>> projectAssembliesCache, 
            IVsFrameworkMultiTargeting frameworkMultiTargeting)
        {
            var redirects = Enumerable.Empty<AssemblyBinding>();

            // Create a project system
            IFileSystem fileSystem = VsProjectSystemFactory.CreateProjectSystem(project, fileSystemProvider);

            // Run this on the UI thread since it enumerates all references
            IEnumerable<string> assemblies = ThreadHelper.Generic.Invoke(() => project.GetAssemblyClosure(fileSystemProvider, projectAssembliesCache));

            redirects = BindingRedirectResolver.GetBindingRedirects(assemblies, domain);

            if (frameworkMultiTargeting != null)
            {
                // filter out assemblies that already exist in the target framework (CodePlex issue #3072)
                FrameworkName targetFrameworkName = project.GetTargetFrameworkName();
                redirects = redirects.Where(p => !FrameworkAssemblyResolver.IsHigherAssemblyVersionInFramework(p.Name, p.AssemblyNewVersion, targetFrameworkName, fileSystemProvider));
            }

            // Create a binding redirect manager over the configuration
            var manager = new BindingRedirectManager(fileSystem, project.GetConfigurationFile());

            // Add the redirects
            manager.AddBindingRedirects(redirects);

            return redirects;
        }
开发者ID:Newtopian,项目名称:nuget,代码行数:32,代码来源:RuntimeHelpers.cs

示例2: InstallPackage

        internal void InstallPackage(IPackageRepository repository, Project project, string packageId, SemanticVersion version, bool ignoreDependencies, bool skipAssemblyReferences)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            using (_vsCommonOperations.SaveSolutionExplorerNodeStates(_solutionManager))
            {
                IVsPackageManager packageManager = _packageManagerFactory.CreatePackageManager(repository,
                                                                                               useFallbackForDependencies
                                                                                                   : false,
                                                                                               addToRecent: false);
                IProjectManager projectManager = packageManager.GetProjectManager(project);

                EventHandler<PackageOperationEventArgs> installedHandler = (sender, e) =>
                                                                               {
                                                                                   _scriptExecutor.ExecuteInitScript(
                                                                                       e.InstallPath, e.Package,
                                                                                       NullLogger.Instance);
                                                                               };

                EventHandler<PackageOperationEventArgs> addedHandler = (sender, e) =>
                                                                           {
                                                                               _scriptExecutor.ExecuteScript(
                                                                                   e.InstallPath,
                                                                                   PowerShellScripts.Install, 
                                                                                   e.Package,
                                                                                   project,
                                                                                   project.GetTargetFrameworkName(),
                                                                                   NullLogger.Instance);
                                                                           };

                bool oldBindingRedirectValue = packageManager.BindingRedirectEnabled;
                try
                {
                    projectManager.PackageReferenceAdded += addedHandler;
                    packageManager.PackageInstalled += installedHandler;
                    packageManager.BindingRedirectEnabled = false;
                    packageManager.InstallPackage(
                        projectManager, 
                        packageId, 
                        version, 
                        ignoreDependencies,
                        allowPrereleaseVersions: true, 
                        skipAssemblyReferences: skipAssemblyReferences, 
                        logger: NullLogger.Instance);
                }
                finally
                {
                    packageManager.BindingRedirectEnabled = oldBindingRedirectValue;
                    projectManager.PackageReferenceAdded -= addedHandler;
                    packageManager.PackageInstalled -= installedHandler;
                }
            }
        }
开发者ID:themotleyfool,项目名称:NuGet,代码行数:56,代码来源:VsPackageInstaller.cs

示例3: GetPackagesToBeReinstalled

        /// <summary>
        /// Gets the list of packages to be reinstalled based on the Project instance and the localRepository to find packages in
        /// </summary>
        /// <param name="project">Project for which packages to be reinstalled are determined</param>
        /// <param name="localRepository">Local Repository from which packages listed in project's packages.config are loaded</param>
        /// <returns></returns>
        internal static IList<IPackage> GetPackagesToBeReinstalled(Project project, IPackageRepository localRepository)
        {
            Debug.Assert(project != null);

            // First call to VsUtility.PackageConfigExists(project) checks if there is a packages.config file under the project folder, Otherwise, return emtpy list
            // If present, then call VsUtility.IsNuGetInUse to see if NuGet is used in the project. The second call might result in loading of NuGet.VisualStudio.dll
            if (localRepository != null && VsUtility.PackagesConfigExists(project) && project.IsNuGetInUse())
            {
                return GetPackagesToBeReinstalled(project.GetTargetFrameworkName(), GetPackageReferences(project), localRepository);
            }

            return new List<IPackage>();
        }
开发者ID:Newtopian,项目名称:nuget,代码行数:19,代码来源:ProjectRetargetingUtility.cs

示例4: InstalledProvider

        public InstalledProvider(
            IVsPackageManager packageManager,
            Project project,
            IPackageRepository localRepository,
            ResourceDictionary resources,
            ProviderServices providerServices,
            IProgressProvider progressProvider,
            ISolutionManager solutionManager,
            IPackageRestoreManager packageRestoreManager)
            : base(localRepository, resources, providerServices, progressProvider, solutionManager)
        {
            if (packageManager == null)
            {
                throw new ArgumentNullException("packageManager");
            }

            _packageManager = packageManager;
            _project = project;
            _targetFramework = _project.GetTargetFrameworkName();
            _userNotifierServices = providerServices.UserNotifierServices;
            _packageRestoreManager = packageRestoreManager;
            _packageRestoreManager.PackagesMissingStatusChanged += OnMissPackagesChanged;
        }
开发者ID:Mailaender,项目名称:xamarin-nuget,代码行数:23,代码来源:InstalledProvider.cs

示例5: InstallPackage

        internal void InstallPackage(IPackageRepository repository, Project project, string packageId, SemanticVersion version, bool ignoreDependencies, bool skipAssemblyReferences)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            if (repository == null)
            {
                throw new ArgumentNullException("repository");
            }

            using (_vsCommonOperations.SaveSolutionExplorerNodeStates(_solutionManager))
            {
                IVsPackageManager packageManager = _packageManagerFactory.CreatePackageManager(repository,
                                                                                               useFallbackForDependencies: false);
                IProjectManager projectManager = packageManager.GetProjectManager(project);

                EventHandler<PackageOperationEventArgs> installedHandler = (sender, e) =>
                                                                               {
                                                                                   _scriptExecutor.ExecuteInitScript(
                                                                                       e.InstallPath, e.Package,
                                                                                       NullLogger.Instance);
                                                                               };

                EventHandler<PackageOperationEventArgs> addedHandler = (sender, e) =>
                                                                           {
                                                                               _scriptExecutor.ExecuteScript(
                                                                                   e.InstallPath,
                                                                                   PowerShellScripts.Install,
                                                                                   e.Package,
                                                                                   project,
                                                                                   project.GetTargetFrameworkName(),
                                                                                   NullLogger.Instance);
                                                                           };

                bool oldBindingRedirectValue = packageManager.BindingRedirectEnabled;
                try
                {
                    projectManager.PackageReferenceAdded += addedHandler;
                    packageManager.PackageInstalled += installedHandler;
                    // if skipping assembly references, disable binding redirects too.
                    packageManager.BindingRedirectEnabled = !skipAssemblyReferences;

                    // locate the package to install
                    IPackage package = PackageRepositoryHelper.ResolvePackage(
                        packageManager.SourceRepository,
                        packageManager.LocalRepository,
                        packageId,
                        version,
                        allowPrereleaseVersions: true);

                    if (skipAssemblyReferences)
                    {
                        package = new SkipAssemblyReferencesPackage(package);
                    }

                    // resolve actions
                    var resolver = new ActionResolver()
                    {
                        Logger = NullLogger.Instance,
                        DependencyVersion = packageManager.DependencyVersion,
                        IgnoreDependencies = ignoreDependencies,
                        AllowPrereleaseVersions = true
                    };
                    resolver.AddOperation(PackageAction.Install, package, projectManager);
                    var actions = resolver.ResolveActions();

                    // execute actions
                    var actionExecutor = new ActionExecutor();
                    actionExecutor.Execute(actions);
                }
                finally
                {
                    packageManager.BindingRedirectEnabled = oldBindingRedirectValue;
                    projectManager.PackageReferenceAdded -= addedHandler;
                    packageManager.PackageInstalled -= installedHandler;
                }
            }
        }
开发者ID:rikoe,项目名称:nuget,代码行数:80,代码来源:VsPackageInstaller.cs

示例6: Execute

 public bool Execute(string installPath, string scriptFileName, IPackage package, Project project, ILogger logger)
 {
     return Execute(installPath, scriptFileName, package, project, project.GetTargetFrameworkName(), logger);
 }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:4,代码来源:PSScriptExecutor.cs

示例7: GetTargetFramework

 private FrameworkName GetTargetFramework(Project project)
 {
     return project.GetTargetFrameworkName() ?? VersionUtility.DefaultTargetFramework;
 }
开发者ID:themotleyfool,项目名称:NuGet,代码行数:4,代码来源:VsWebsiteHandler.cs


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