本文整理汇总了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;
}
示例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;
}
}
}
示例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>();
}
示例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;
}
示例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;
}
}
}
示例6: Execute
public bool Execute(string installPath, string scriptFileName, IPackage package, Project project, ILogger logger)
{
return Execute(installPath, scriptFileName, package, project, project.GetTargetFrameworkName(), logger);
}
示例7: GetTargetFramework
private FrameworkName GetTargetFramework(Project project)
{
return project.GetTargetFrameworkName() ?? VersionUtility.DefaultTargetFramework;
}