本文整理汇总了C#中Project.GetTargetFramework方法的典型用法代码示例。如果您正苦于以下问题:C# Project.GetTargetFramework方法的具体用法?C# Project.GetTargetFramework怎么用?C# Project.GetTargetFramework使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Project
的用法示例。
在下文中一共展示了Project.GetTargetFramework方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例2: 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);
}
示例3: AddBindingRedirects
private static IEnumerable<AssemblyBinding> AddBindingRedirects(
Project project,
IFileSystemProvider fileSystemProvider,
AppDomain domain,
IDictionary<string, HashSet<string>> projectAssembliesCache,
IVsFrameworkMultiTargeting frameworkMultiTargeting,
bool checkProjectType = true)
{
var redirects = Enumerable.Empty<AssemblyBinding>();
// Only add binding redirects to projects that aren't class libraries
if (!checkProjectType || project.SupportsConfig())
{
// 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)
string targetFramework = project.GetTargetFramework();
redirects = redirects.Where(p => !IsAssemblyAvaialbleInFramework(p.Name, targetFramework, frameworkMultiTargeting));
}
// Create a binding redirect manager over the configuration
var manager = new BindingRedirectManager(fileSystem, project.GetConfigurationFile());
// Add the redirects
manager.AddBindingRedirects(redirects);
}
return redirects;
}
示例4: GetTargetFramework
protected static string GetTargetFramework(Project project)
{
if (project == null)
{
return null;
}
return project.GetTargetFramework();
}