本文整理汇总了C#中INuGetProjectContext类的典型用法代码示例。如果您正苦于以下问题:C# INuGetProjectContext类的具体用法?C# INuGetProjectContext怎么用?C# INuGetProjectContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
INuGetProjectContext类属于命名空间,在下文中一共展示了INuGetProjectContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RestoreMissingPackagesAsync
public Task RestoreMissingPackagesAsync (
INuGetAwareProject project,
INuGetProjectContext context,
CancellationToken token)
{
return project.RestorePackagesAsync (solutionManager, context, token);
}
示例2: CreateFile
public override Stream CreateFile(string fullPath, INuGetProjectContext nuGetProjectContext)
{
// See if there are any pending changes for this file
var pendingChanges = PrivateWorkspace.GetPendingChanges(fullPath, RecursionType.None).ToArray();
var pendingDeletes = pendingChanges.Where(c => c.IsDelete).ToArray();
// We would need to pend an edit if (a) the file is pending delete (b) is bound to source control and does not already have pending edits or adds
bool sourceControlBound = IsSourceControlBound(fullPath);
bool requiresEdit = pendingDeletes.Any() || (!pendingChanges.Any(c => c.IsEdit || c.IsAdd) && sourceControlBound);
// Undo all pending deletes
if (pendingDeletes.Any())
{
PrivateWorkspace.Undo(pendingDeletes);
}
// If the file was marked as deleted, and we undid the change or has no pending adds or edits, we need to edit it.
if (requiresEdit)
{
// If the file exists, but there is not pending edit then edit the file (if it is under source control)
requiresEdit = PrivateWorkspace.PendEdit(fullPath) > 0;
}
var fileStream = FileSystemUtility.CreateFile(fullPath);
// If we didn't have to edit the file, this must be a new file.
if (!sourceControlBound)
{
PrivateWorkspace.PendAdd(fullPath);
}
return fileStream;
}
示例3: InstallPackageAsync
public async override Task<bool> InstallPackageAsync(Packaging.Core.PackageIdentity packageIdentity, System.IO.Stream packageStream,
INuGetProjectContext nuGetProjectContext, CancellationToken token)
{
if (!packageStream.CanSeek)
{
throw new ArgumentException(NuGet.ProjectManagement.Strings.PackageStreamShouldBeSeekable);
}
nuGetProjectContext.Log(MessageLevel.Info, Strings.InstallingPackage, packageIdentity);
packageStream.Seek(0, SeekOrigin.Begin);
var zipArchive = new ZipArchive(packageStream);
PackageReader packageReader = new PackageReader(zipArchive);
var packageSupportedFrameworks = packageReader.GetSupportedFrameworks();
var projectFrameworks = _project.GetSupportedFrameworksAsync(token)
.Result
.Select(f => NuGetFramework.Parse(f.FullName));
var args = new Dictionary<string, object>();
args["Frameworks"] = projectFrameworks.Where(
projectFramework =>
IsCompatible(projectFramework, packageSupportedFrameworks)).ToArray();
await _project.InstallPackageAsync(
new NuGetPackageMoniker
{
Id = packageIdentity.Id,
Version = packageIdentity.Version.ToNormalizedString()
},
args,
logger: null,
progress: null,
cancellationToken: token);
return true;
}
示例4: CreateNuGetProject
public NuGetProject CreateNuGetProject (DotNetProject project, INuGetProjectContext context)
{
Runtime.AssertMainThread ();
var nugetAwareProject = project as INuGetAwareProject;
if (nugetAwareProject != null)
return nugetAwareProject.CreateNuGetProject ();
var projectSystem = new MonoDevelopMSBuildNuGetProjectSystem (project, context);
string projectJsonPath = ProjectJsonPathUtilities.GetProjectConfigPath (project.BaseDirectory, project.Name);
if (File.Exists (projectJsonPath)) {
return new BuildIntegratedProjectSystem (
projectJsonPath,
project.FileName,
project,
projectSystem,
project.Name,
settings);
}
string baseDirectory = GetBaseDirectory (project);
string folderNuGetProjectFullPath = PackagesFolderPathUtility.GetPackagesFolderPath (baseDirectory, settings);
string packagesConfigFolderPath = project.BaseDirectory;
return new MSBuildNuGetProject (
projectSystem,
folderNuGetProjectFullPath,
packagesConfigFolderPath);
}
示例5: CreateRefreshFile
/// <summary>
/// Creates a .refresh file in bin directory of the IFileSystem that points to the assembly being installed.
/// This works around issues in DTE's AddReference method when dealing with GACed binaries.
/// </summary>
/// <remarks>Adds the file to the DTE project system</remarks>
/// <param name="projectSystem">the web site project system where this will be added</param>
/// <param name="assemblyPath">The path to the assembly being added</param>
public static void CreateRefreshFile(WebSiteProjectSystem projectSystem, string assemblyPath, INuGetProjectContext nuGetProjectContext)
{
if (projectSystem == null)
{
throw new ArgumentNullException("projectSystem");
}
if (assemblyPath == null)
{
throw new ArgumentNullException("assemblyPath");
}
string refreshFilePath = CreateRefreshFilePath(projectSystem.ProjectFullPath, assemblyPath);
if (!FileSystemUtility.FileExists(projectSystem.ProjectFullPath, refreshFilePath))
{
try
{
using (var stream = CreateRefreshFileStream(projectSystem.ProjectFullPath, assemblyPath))
{
// TODO: log to nuGetProjectContext?
projectSystem.AddFile(refreshFilePath, stream);
}
}
catch (UnauthorizedAccessException exception)
{
// log IO permission error
ExceptionHelper.WriteToActivityLog(exception);
}
}
}
示例6: InstallPackageByIdentityAsync
/// <summary>
/// Install package by Identity
/// </summary>
/// <param name="project"></param>
/// <param name="identity"></param>
/// <param name="resolutionContext"></param>
/// <param name="projectContext"></param>
/// <param name="isPreview"></param>
/// <param name="isForce"></param>
/// <param name="uninstallContext"></param>
/// <returns></returns>
protected async Task InstallPackageByIdentityAsync(NuGetProject project, PackageIdentity identity, ResolutionContext resolutionContext, INuGetProjectContext projectContext, bool isPreview, bool isForce = false, UninstallationContext uninstallContext = null)
{
List<NuGetProjectAction> actions = new List<NuGetProjectAction>();
// For Install-Package -Force
if (isForce)
{
PackageReference installedReference = project.GetInstalledPackagesAsync(CancellationToken.None).Result.Where(p =>
StringComparer.OrdinalIgnoreCase.Equals(identity.Id, p.PackageIdentity.Id)).FirstOrDefault();
if (installedReference != null)
{
actions.AddRange(await PackageManager.PreviewUninstallPackageAsync(project, installedReference.PackageIdentity, uninstallContext, projectContext, CancellationToken.None));
}
NuGetProjectAction installAction = NuGetProjectAction.CreateInstallProjectAction(identity, ActiveSourceRepository);
actions.Add(installAction);
}
else
{
actions.AddRange(await PackageManager.PreviewInstallPackageAsync(project, identity, resolutionContext, projectContext, ActiveSourceRepository, null, CancellationToken.None));
}
if (isPreview)
{
PreviewNuGetPackageActions(actions);
}
else
{
await PackageManager.ExecuteNuGetProjectActionsAsync(project, actions, this, CancellationToken.None);
}
}
示例7: AddFile
public static void AddFile(string root, string path, Action<Stream> writeToStream, INuGetProjectContext nuGetProjectContext)
{
if (writeToStream == null)
{
throw new ArgumentNullException("writeToStream");
}
AddFileCore(root, path, writeToStream, nuGetProjectContext);
}
示例8: RunPostProcessAsync
/// <summary>
/// PostProcessAsync is not run for BuildIntegratedNuGetProjects so we run it directly after
/// running a NuGet action.
/// </summary>
public static Task RunPostProcessAsync (this NuGetProject project, INuGetProjectContext context, CancellationToken token)
{
var buildIntegratedProject = project as IBuildIntegratedNuGetProject;
if (buildIntegratedProject != null) {
return buildIntegratedProject.PostProcessAsync (context, token);
}
return Task.FromResult (0);
}
示例9: IsPackagesFolderBoundToSourceControl
public static bool IsPackagesFolderBoundToSourceControl(INuGetProjectContext nuGetProjectContext)
{
var sourceControlManager = GetSourceControlManager(nuGetProjectContext);
if (sourceControlManager != null)
{
return sourceControlManager.IsPackagesFolderBoundToSourceControl();
}
return false;
}
示例10: ExecuteNuGetProjectActionsAsync
public Task ExecuteNuGetProjectActionsAsync (
NuGetProject nuGetProject,
IEnumerable<NuGetProjectAction> nuGetProjectActions,
INuGetProjectContext nuGetProjectContext,
CancellationToken token)
{
return packageManager.ExecuteNuGetProjectActionsAsync (
nuGetProject,
nuGetProjectActions,
nuGetProjectContext,
token);
}
示例11: GetSourceControlManager
public static SourceControlManager GetSourceControlManager(INuGetProjectContext nuGetProjectContext)
{
if (nuGetProjectContext != null)
{
var sourceControlManagerProvider = nuGetProjectContext.SourceControlManagerProvider;
if (sourceControlManagerProvider != null)
{
return sourceControlManagerProvider.GetSourceControlManager();
}
}
return null;
}
示例12: InstallNuGetPackageAction
public InstallNuGetPackageAction (
IEnumerable<SourceRepository> primarySources,
IMonoDevelopSolutionManager solutionManager,
IDotNetProject dotNetProject,
INuGetProjectContext projectContext)
: this (
primarySources,
null,
solutionManager,
dotNetProject,
projectContext)
{
}
示例13: InstallPackageAsync
public async override Task<bool> InstallPackageAsync(PackageIdentity packageIdentity, Stream packageStream,
INuGetProjectContext nuGetProjectContext, CancellationToken token)
{
if (packageIdentity == null)
{
throw new ArgumentNullException("packageIdentity");
}
if (packageStream == null)
{
throw new ArgumentNullException("packageStream");
}
if (nuGetProjectContext == null)
{
throw new ArgumentNullException("nuGetProjectContext");
}
if (!packageStream.CanSeek)
{
throw new ArgumentException(Strings.PackageStreamShouldBeSeekable);
}
// 1. Check if the Package already exists at root, if so, return false
if (PackageExists(packageIdentity))
{
nuGetProjectContext.Log(MessageLevel.Warning, Strings.PackageAlreadyExistsInFolder, packageIdentity, Root);
return false;
}
nuGetProjectContext.Log(MessageLevel.Info, Strings.AddingPackageToFolder, packageIdentity, Root);
// 2. Call PackageExtractor to extract the package into the root directory of this FileSystemNuGetProject
packageStream.Seek(0, SeekOrigin.Begin);
var addedPackageFilesList = new List<string>(await PackageExtractor.ExtractPackageAsync(packageStream, packageIdentity, PackagePathResolver, nuGetProjectContext.PackageExtractionContext,
PackageSaveMode, token));
if (PackageSaveMode.HasFlag(PackageSaveModes.Nupkg))
{
var packageFilePath = GetInstalledPackageFilePath(packageIdentity);
if (File.Exists(packageFilePath))
{
addedPackageFilesList.Add(packageFilePath);
}
}
// Pend all the package files including the nupkg file
FileSystemUtility.PendAddFiles(addedPackageFilesList, Root, nuGetProjectContext);
nuGetProjectContext.Log(MessageLevel.Info, Strings.AddedPackageToFolder, packageIdentity, Root);
return true;
}
示例14: TestMSBuildNuGetProjectSystem
public TestMSBuildNuGetProjectSystem(NuGetFramework targetFramework, INuGetProjectContext nuGetProjectContext,
string projectFullPath = null, string projectName = null)
{
TargetFramework = targetFramework;
References = new Dictionary<string, string>();
FrameworkReferences = new HashSet<string>();
Files = new HashSet<string>();
Imports = new HashSet<string>();
NuGetProjectContext = nuGetProjectContext;
ProjectFullPath = String.IsNullOrEmpty(projectFullPath) ? Environment.CurrentDirectory : projectFullPath;
ScriptsExecuted = new Dictionary<string, int>();
ProcessedFiles = new HashSet<string>();
ProjectName = projectName ?? TestProjectName;
}
示例15: ReinstallNuGetPackageAction
public ReinstallNuGetPackageAction (
IDotNetProject project,
IMonoDevelopSolutionManager solutionManager,
INuGetProjectContext projectContext,
IPackageManagementEvents packageManagementEvents)
{
this.context = projectContext;
this.packageManagementEvents = packageManagementEvents;
var repositories = solutionManager.CreateSourceRepositoryProvider ().GetRepositories ();
installAction = CreateInstallAction (solutionManager, project, repositories);
uninstallAction = CreateUninstallAction (solutionManager, project);
}