本文整理汇总了C#中NuGet.Frameworks.NuGetFramework类的典型用法代码示例。如果您正苦于以下问题:C# NuGetFramework类的具体用法?C# NuGetFramework怎么用?C# NuGetFramework使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NuGetFramework类属于NuGet.Frameworks命名空间,在下文中一共展示了NuGetFramework类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDependencies
private IList<LibraryDependency> GetDependencies(LockFileTargetLibrary library, NuGetFramework targetFramework)
{
var libraryDependencies = new List<LibraryDependency>();
foreach (var d in library.Dependencies)
{
libraryDependencies.Add(new LibraryDependency
{
LibraryRange = new LibraryRange
{
Name = d.Id,
VersionRange = d.VersionRange
}
});
}
foreach (var name in library.FrameworkAssemblies)
{
libraryDependencies.Add(new LibraryDependency
{
LibraryRange = new LibraryRange
{
Name = name,
TypeConstraint = LibraryTypes.Reference
}
});
}
return libraryDependencies;
}
示例2: GetProjectContextFromDirectory
private ProjectContext GetProjectContextFromDirectory(string directory, NuGetFramework framework)
{
if (directory == null || framework == null)
{
return null;
}
var projectRootPath = directory;
if (!File.Exists(Path.Combine(projectRootPath, Project.FileName)))
{
return null;
}
var projectContext = ProjectContext.Create(
projectRootPath,
framework,
PlatformServices.Default.Runtime.GetAllCandidateRuntimeIdentifiers());
if (projectContext.RuntimeIdentifier == null)
{
return null;
}
return projectContext;
}
示例3: Create
public static ICommand Create(
string project,
string configuration,
NuGetFramework framework,
string buildBasePath,
string output)
{
var args = new List<string>()
{
project,
"--configuration", configuration,
"--framework", framework.GetShortFolderName()
};
if (buildBasePath != null)
{
args.Add("--build-base-path");
args.Add(buildBasePath);
}
if (output != null)
{
args.Add("--output");
args.Add(output);
}
return Command.CreateDotNet(
"build",
args,
framework,
configuration);
}
示例4: GetDescription
public LibraryDescription GetDescription(LibraryRange libraryRange, NuGetFramework targetFramework)
{
if (!LibraryType.ReferenceAssembly.CanSatisfyConstraint(libraryRange.Target))
{
return null;
}
var name = libraryRange.Name;
var version = libraryRange.VersionRange?.MinVersion;
string path;
Version assemblyVersion;
if (!FrameworkResolver.TryGetAssembly(name, targetFramework, out path, out assemblyVersion))
{
return null;
}
return new LibraryDescription(
new LibraryIdentity(libraryRange.Name, new NuGetVersion(assemblyVersion), LibraryType.ReferenceAssembly),
string.Empty, // Framework assemblies don't have hashes
path,
Enumerable.Empty<LibraryRange>(),
targetFramework,
resolved: true,
compatible: true);
}
示例5: PackageAssemblyLoader
public PackageAssemblyLoader(NuGetFramework runtimeFramework, IAssemblyLoadContextAccessor loadContextAccessor, IEnumerable<Library> libraries, PackagePathResolver pathResolver)
{
Log = RuntimeLogging.Logger<PackageAssemblyLoader>();
_loadContextAccessor = loadContextAccessor;
_assemblyLookupTable = InitializeAssemblyLookupTable(libraries, runtimeFramework, pathResolver);
}
示例6: GetNearest
/// <summary>
/// Gives the smallest set of frameworks from the table that cover everything the given framework would cover.
/// </summary>
public IEnumerable<NuGetFramework> GetNearest(NuGetFramework framework)
{
// start with everything compatible with the framework
var allCompatible = _table.Keys.Where(f => _compat.IsCompatible(framework, f));
return _reducer.ReduceUpwards(allCompatible);
}
示例7: LibraryExporter
public LibraryExporter(
NuGetFramework targetFramework,
PackagePathResolver packagePathResolver)
{
_targetFramework = targetFramework;
_packagePathResolver = packagePathResolver;
}
示例8: FindProjectDependencyCommands
private CommandSpec FindProjectDependencyCommands(
string commandName,
IEnumerable<string> commandArgs,
string configuration,
NuGetFramework framework,
string outputPath,
string buildBasePath,
string projectDirectory)
{
var commandResolverArguments = new CommandResolverArguments
{
CommandName = commandName,
CommandArguments = commandArgs,
Framework = framework,
Configuration = configuration,
OutputPath = outputPath,
BuildBasePath = buildBasePath,
ProjectDirectory = projectDirectory
};
var commandResolver = GetProjectDependenciesCommandResolver();
var commandSpec = commandResolver.Resolve(commandResolverArguments);
if (commandSpec == null)
{
throw new CommandUnknownException(commandName);
}
return commandSpec;
}
示例9: GetDescription
public PackageDescription GetDescription(NuGetFramework targetFramework, LockFilePackageLibrary package, LockFileTargetLibrary targetLibrary)
{
// If a NuGet dependency is supposed to provide assemblies but there is no assembly compatible with
// current target framework, we should mark this dependency as unresolved
var containsAssembly = package.Files
.Any(x => x.StartsWith($"ref{Path.DirectorySeparatorChar}") ||
x.StartsWith($"lib{Path.DirectorySeparatorChar}"));
var compatible = targetLibrary.FrameworkAssemblies.Any() ||
targetLibrary.CompileTimeAssemblies.Any() ||
targetLibrary.RuntimeAssemblies.Any() ||
!containsAssembly;
var dependencies = new List<LibraryRange>(targetLibrary.Dependencies.Count + targetLibrary.FrameworkAssemblies.Count);
PopulateDependencies(dependencies, targetLibrary, targetFramework);
var path = _packagePathResolver.GetInstallPath(package.Name, package.Version);
// If the package's compile time assemblies is for a portable profile then, read the assembly metadata
// and turn System.* references into reference assembly dependencies
PopulateLegacyPortableDependencies(targetFramework, dependencies, path, targetLibrary);
var packageDescription = new PackageDescription(
path,
package,
targetLibrary,
dependencies,
compatible);
return packageDescription;
}
示例10: Build
public DependencyContext Build(CommonCompilerOptions compilerOptions,
IEnumerable<LibraryExport> compilationExports,
IEnumerable<LibraryExport> runtimeExports,
bool portable,
NuGetFramework target,
string runtime)
{
if (compilationExports == null)
{
compilationExports = Enumerable.Empty<LibraryExport>();
}
var dependencyLookup = compilationExports
.Concat(runtimeExports)
.Select(export => export.Library.Identity)
.Distinct()
.Select(identity => new Dependency(identity.Name, identity.Version.ToString()))
.ToDictionary(dependency => dependency.Name);
var compilationOptions = compilerOptions != null
? GetCompilationOptions(compilerOptions)
: CompilationOptions.Default;
var runtimeSignature = GenerateRuntimeSignature(runtimeExports);
return new DependencyContext(
new TargetInfo(target.DotNetFrameworkName, runtime, runtimeSignature, portable),
compilationOptions,
GetLibraries(compilationExports, dependencyLookup, runtime: false).Cast<CompilationLibrary>(),
GetLibraries(runtimeExports, dependencyLookup, runtime: true).Cast<RuntimeLibrary>(),
new RuntimeFallbacks[] {});
}
示例11: Create
public ICommand Create(
string commandName,
IEnumerable<string> args,
NuGetFramework framework = null,
string configuration = Constants.DefaultConfiguration)
{
if (string.IsNullOrEmpty(configuration))
{
configuration = _configuration;
}
if (framework == null)
{
framework = _nugetFramework;
}
var commandSpec = FindProjectDependencyCommands(
commandName,
args,
configuration,
framework,
_outputPath,
_buildBasePath,
_projectDirectory);
return Command.Create(commandSpec);
}
示例12: Package
public Package(NuGetFramework currentFramework, string packageId, IReadOnlyList<SourceRepository> sourceRepositories,
string versionRange, bool getLatest, bool allowPrereleaseVersions, bool allowUnlisted, bool exclusive)
{
if (packageId == null)
{
throw new ArgumentNullException(nameof(packageId));
}
if (string.IsNullOrWhiteSpace(packageId))
{
throw new ArgumentException(nameof(packageId));
}
if (getLatest && !string.IsNullOrEmpty(versionRange))
{
throw new ArgumentException("Can not specify both a version and the latest package");
}
_currentFramework = currentFramework;
_packageId = packageId;
_sourceRepositories = sourceRepositories;
if (!string.IsNullOrEmpty(versionRange) && !VersionRange.TryParse(versionRange, out _versionRange))
{
throw new ArgumentException(nameof(versionRange));
}
_getLatest = getLatest;
_allowPrereleaseVersions = allowPrereleaseVersions;
_allowUnlisted = allowUnlisted;
_exclusive = exclusive;
}
示例13: PopulateDependencies
private void PopulateDependencies(
List<LibraryRange> dependencies,
LockFileTargetLibrary targetLibrary,
NuGetFramework targetFramework)
{
foreach (var dependency in targetLibrary.Dependencies)
{
dependencies.Add(new LibraryRange(
dependency.Id,
dependency.VersionRange,
LibraryType.Unspecified,
LibraryDependencyType.Default));
}
if (!targetFramework.IsPackageBased)
{
// Only add framework assemblies for non-package based frameworks.
foreach (var frameworkAssembly in targetLibrary.FrameworkAssemblies)
{
dependencies.Add(new LibraryRange(
frameworkAssembly,
LibraryType.ReferenceAssembly,
LibraryDependencyType.Default));
}
}
}
示例14: GetDescription
public MSBuildProjectDescription GetDescription(NuGetFramework targetFramework, LockFileProjectLibrary projectLibrary, LockFileTargetLibrary targetLibrary)
{
var compatible = targetLibrary.FrameworkAssemblies.Any() ||
targetLibrary.CompileTimeAssemblies.Any() ||
targetLibrary.RuntimeAssemblies.Any();
var dependencies = new List<LibraryRange>(targetLibrary.Dependencies.Count + targetLibrary.FrameworkAssemblies.Count);
PopulateDependencies(dependencies, targetLibrary, targetFramework);
var msbuildProjectFilePath = GetMSBuildProjectFilePath(projectLibrary);
var msbuildProjectDirectoryPath = Path.GetDirectoryName(msbuildProjectFilePath);
var exists = Directory.Exists(msbuildProjectDirectoryPath);
var projectFile = projectLibrary.Path == null ? null : _projectResolver(projectLibrary.Path);
var msbuildPackageDescription = new MSBuildProjectDescription(
msbuildProjectDirectoryPath,
msbuildProjectFilePath,
projectLibrary,
targetLibrary,
projectFile,
dependencies,
compatible,
resolved: compatible && exists);
return msbuildPackageDescription;
}
示例15: Generations_MatchesInbox
public void Generations_MatchesInbox()
{
FrameworkSet fxs = FrameworkSet.Load("FrameworkLists");
Version maxVersion = new Version(int.MaxValue, int.MaxValue, int.MaxValue, int.MaxValue);
foreach (var fxGroup in fxs.Frameworks)
{
foreach (var fx in fxGroup.Value)
{
var thisFx = new NuGetFramework(fx.FrameworkName.Identifier, fx.FrameworkName.Version);
var fxGeneration = Generations.DetermineGenerationForFramework(thisFx, false);
foreach (var assembly in fx.Assemblies.Where(a => !s_classicAssemblies.Contains(a.Key) && a.Value != maxVersion))
{
_log.Reset();
Version assmGeneration = _generations.DetermineGenerationFromSeeds(assembly.Key, assembly.Value, _log);
Version effectiveFxGeneration;
if (!s_generationException.TryGetValue(Tuple.Create(fx.FrameworkName, assembly.Key), out effectiveFxGeneration))
{
effectiveFxGeneration = fxGeneration;
}
Assert.Equal(0, _log.ErrorsLogged);
Assert.Equal(0, _log.WarningsLogged);
Assert.True(null != assmGeneration, $"{assembly.Key},{assembly.Value} should be tracked by generations");
Assert.True(assmGeneration.Major >= 1 && assmGeneration.Minor >= 0);
Assert.True(assmGeneration <= effectiveFxGeneration, $"Generation {assmGeneration} of {assembly.Key}, {assembly.Value} must be less than or equal to {fxGeneration} since this assembly is inbox in {fx.FrameworkName} which is mapped to generation {effectiveFxGeneration}.");
}
}
}
}