本文整理汇总了C#中IPackageManager.InstallPackage方法的典型用法代码示例。如果您正苦于以下问题:C# IPackageManager.InstallPackage方法的具体用法?C# IPackageManager.InstallPackage怎么用?C# IPackageManager.InstallPackage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPackageManager
的用法示例。
在下文中一共展示了IPackageManager.InstallPackage方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddPackage
private IPackage AddPackage(IPackageManager manager, string id, string version, string payloadAssemblyFilePath)
{
PackageBuilder builder = new PackageBuilder();
builder.Id = id;
builder.Title = "dummy title";
builder.Version = new SemanticVersion(version);
builder.Description = "dummy description";
builder.Authors.Add("dummy author 1");
builder.Authors.Add("dummy author 2");
builder.Owners.Add("dummy owner 1");
builder.Owners.Add("dummy owner 2");
builder.ProjectUrl = new System.Uri("http://dummyurl/");
builder.LicenseUrl = new Uri("http://my.license/readme.txt");
PhysicalPackageFile file = new PhysicalPackageFile();
file.SourcePath = payloadAssemblyFilePath;
file.TargetPath = "analyzers/" + Path.GetFileName(payloadAssemblyFilePath);
builder.Files.Add(file);
using (MemoryStream stream = new MemoryStream())
{
builder.Save(stream);
stream.Position = 0;
ZipPackage pkg = new ZipPackage(stream);
manager.InstallPackage(pkg, true, true);
return pkg;
}
}
示例2: AddPackage
private IPackage AddPackage(IPackageManager manager, string id, string version, string payloadAssemblyFilePath, params IPackage[] dependencies)
{
PackageBuilder builder = new PackageBuilder();
ManifestMetadata metadata = new ManifestMetadata()
{
Authors = "dummy author 1,dummy author 2",
Owners = "dummy owner 1,dummy owner 2",
Title = "dummy title",
Version = new SemanticVersion(version).ToString(),
Id = id,
Description = "dummy description",
LicenseUrl = "http://my.license/readme.txt",
ProjectUrl = "http://dummyurl/"
};
List<ManifestDependency> dependencyList = new List<ManifestDependency>();
foreach (IPackage dependencyNode in dependencies)
{
dependencyList.Add(new ManifestDependency()
{
Id = dependencyNode.Id,
Version = dependencyNode.Version.ToString(),
});
}
List<ManifestDependencySet> dependencySetList = new List<ManifestDependencySet>()
{
new ManifestDependencySet()
{
Dependencies = dependencyList
}
};
metadata.DependencySets = dependencySetList;
builder.Populate(metadata);
PhysicalPackageFile file = new PhysicalPackageFile();
file.SourcePath = payloadAssemblyFilePath;
file.TargetPath = "analyzers/" + Path.GetFileName(payloadAssemblyFilePath);
builder.Files.Add(file);
using (MemoryStream stream = new MemoryStream())
{
builder.Save(stream);
stream.Position = 0;
ZipPackage pkg = new ZipPackage(stream);
manager.InstallPackage(pkg, true, true);
return pkg;
}
}
示例3: InstallPackage
internal bool InstallPackage(IPackageManager packageManager, IFileSystem fileSystem, string packageId, SemanticVersion version, bool ignoreDependencies)
{
if (AllowMultipleVersions && IsPackageInstalled(packageId, version, packageManager, fileSystem))
{
// Use a fast check to verify if the package is already installed. We'll do this by checking if the package directory exists on disk.
return false;
}
else if (!AllowMultipleVersions)
{
var installedPackage = packageManager.LocalRepository.FindPackage(packageId);
if (installedPackage != null)
{
if (version != null && installedPackage.Version >= version)
{
// If the package is already installed (or the version being installed is lower), then we do not need to do anything.
return false;
}
else if (packageManager.SourceRepository.Exists(packageId, version))
{
// If the package is already installed, but
// (a) the version we require is different from the one that is installed,
// (b) side-by-side is disabled
// we need to uninstall it.
// However, before uninstalling, make sure the package exists in the source repository.
packageManager.UninstallPackage(installedPackage, forceRemove: false, removeDependencies: true);
}
}
}
packageManager.InstallPackage(packageId, version, ignoreDependencies: ignoreDependencies, allowPrereleaseVersions: Prerelease);
return true;
}
示例4: InstallPackage
/// <summary>
/// Install a package with locking to allow multiple concurrent extractions to work without disk contention.
/// </summary>
public static void InstallPackage(IPackageManager packageManager, IPackage package)
{
var uniqueToken = GenerateUniqueToken(packageManager, package.Id, package.Version);
// Prerelease flag does not matter since we already have the package to install and we ignore dependencies.
ExecuteLocked(uniqueToken, () => packageManager.InstallPackage(package, ignoreDependencies: true, allowPrereleaseVersions: true));
}
示例5: PerformInstall
protected internal virtual void PerformInstall(IPackageManager manager, string id, Version version, bool ignoreDependencies)
{
manager.InstallPackage(id, version == null ? null : new SemanticVersion(version), ignoreDependencies, allowPrereleaseVersions: false);
}
示例6: BuildAndInstallPackage
private void BuildAndInstallPackage(IPackageManager manager, string id, string version)
{
ManifestMetadata metadata = GenerateTestMetadata(true);
metadata.Id = id;
metadata.Version = new SemanticVersion(version).ToString();
Stream packageStream = BuildPackageToStream(metadata, new MemoryStream());
packageStream.Position = 0;
ZipPackage pkg = new ZipPackage(packageStream);
manager.InstallPackage(pkg, true, true);
}
示例7: AddPackage
private void AddPackage(IPackageManager manager, string id, string version, string payloadAssemblyFilePath)
{
PackageBuilder builder = new PackageBuilder();
builder.Id = id;
builder.Version = new SemanticVersion(version);
builder.Description = "dummy description";
builder.Authors.Add("dummy author");
PhysicalPackageFile file = new PhysicalPackageFile();
file.SourcePath = payloadAssemblyFilePath;
file.TargetPath = "analyzers/" + Path.GetFileName(payloadAssemblyFilePath);
builder.Files.Add(file);
using (MemoryStream stream = new MemoryStream())
{
builder.Save(stream);
stream.Position = 0;
ZipPackage pkg = new ZipPackage(stream);
manager.InstallPackage(pkg, true, true);
}
}