-
Notifications
You must be signed in to change notification settings - Fork 689
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix plugin package install, get credentials in multifeed environment,…
… and add get service index request/response.
- Loading branch information
Showing
37 changed files
with
2,701 additions
and
450 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 41 additions & 9 deletions
50
src/NuGet.Core/NuGet.PackageManagement/FileModifiers/IPackageFileTransformer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,61 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace NuGet.ProjectManagement | ||
{ | ||
/// <summary> | ||
/// Represents a package file transformer. | ||
/// </summary> | ||
public interface IPackageFileTransformer | ||
{ | ||
/// <summary> | ||
/// Transforms the file | ||
/// Asynchronously transforms a file. | ||
/// </summary> | ||
void TransformFile(Func<Stream> fileStreamFactory, string targetPath, IMSBuildNuGetProjectSystem projectSystem); | ||
/// <param name="streamTaskFactory">A stream task factory.</param> | ||
/// <param name="targetPath">A path to the file to be transformed.</param> | ||
/// <param name="projectSystem">The project where this change is taking place.</param> | ||
/// <param name="cancellationToken">A cancellation token.</param> | ||
/// <returns>A task that represents the asynchronous operation.</returns> | ||
/// <exception cref="ArgumentNullException">Thrown if <paramref name="streamTaskFactory" /> | ||
/// is <c>null</c>.</exception> | ||
/// <exception cref="ArgumentNullException">Thrown if <paramref name="projectSystem" /> | ||
/// is <c>null</c>.</exception> | ||
/// <exception cref="OperationCanceledException">Thrown if <paramref name="cancellationToken" /> | ||
/// is cancelled.</exception> | ||
Task TransformFileAsync( | ||
Func<Task<Stream>> streamTaskFactory, | ||
string targetPath, | ||
IMSBuildNuGetProjectSystem projectSystem, | ||
CancellationToken cancellationToken); | ||
|
||
/// <summary> | ||
/// Reverses the transform on the targetPath, using all the potential source of change | ||
/// Asynchronously reverses the transform on the targetPath, using all the potential source of change. | ||
/// </summary> | ||
/// <param name="fileStreamFactory">A factory for accessing the file to be reverted from the nupkg being uninstalled.</param> | ||
/// <param name="streamTaskFactory">A factory for accessing the file to be reverted from the nupkg being uninstalled.</param> | ||
/// <param name="targetPath">A path to the file to be reverted.</param> | ||
/// <param name="matchingFiles">Other files in other packages that may have changed the <paramref name="targetPath"/>.</param> | ||
/// <param name="matchingFiles">Other files in other packages that may have changed the <paramref name="targetPath" />.</param> | ||
/// <param name="projectSystem">The project where this change is taking place.</param> | ||
void RevertFile(Func<Stream> fileStreamFactory, | ||
/// <param name="cancellationToken">A cancellation token.</param> | ||
/// <returns>A task that represents the asynchronous operation.</returns> | ||
/// <exception cref="ArgumentNullException">Thrown if <paramref name="streamTaskFactory" /> | ||
/// is <c>null</c>.</exception> | ||
/// <exception cref="ArgumentNullException">Thrown if <paramref name="matchingFiles" /> | ||
/// is <c>null</c>.</exception> | ||
/// <exception cref="ArgumentNullException">Thrown if <paramref name="projectSystem" /> | ||
/// is <c>null</c>.</exception> | ||
/// <exception cref="OperationCanceledException">Thrown if <paramref name="cancellationToken" /> | ||
/// is cancelled.</exception> | ||
Task RevertFileAsync( | ||
Func<Task<Stream>> streamTaskFactory, | ||
string targetPath, | ||
IEnumerable<InternalZipFileInfo> matchingFiles, | ||
IMSBuildNuGetProjectSystem projectSystem); | ||
IMSBuildNuGetProjectSystem projectSystem, | ||
CancellationToken cancellationToken); | ||
} | ||
} | ||
} |
34 changes: 0 additions & 34 deletions
34
src/NuGet.Core/NuGet.PackageManagement/FileModifiers/PreProcessor.cs
This file was deleted.
Oops, something went wrong.
108 changes: 108 additions & 0 deletions
108
src/NuGet.Core/NuGet.PackageManagement/FileModifiers/Preprocessor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace NuGet.ProjectManagement | ||
{ | ||
/// <summary> | ||
/// Simple token replacement system for content files. | ||
/// </summary> | ||
public class Preprocessor : IPackageFileTransformer | ||
{ | ||
/// <summary> | ||
/// Asynchronously transforms a file. | ||
/// </summary> | ||
/// <param name="streamTaskFactory">A stream task factory.</param> | ||
/// <param name="targetPath">A path to the file to be transformed.</param> | ||
/// <param name="projectSystem">The project where this change is taking place.</param> | ||
/// <param name="cancellationToken">A cancellation token.</param> | ||
/// <returns>A task that represents the asynchronous operation.</returns> | ||
/// <exception cref="ArgumentNullException">Thrown if <paramref name="streamTaskFactory" /> | ||
/// is <c>null</c>.</exception> | ||
/// <exception cref="ArgumentNullException">Thrown if <paramref name="projectSystem" /> | ||
/// is <c>null</c>.</exception> | ||
/// <exception cref="OperationCanceledException">Thrown if <paramref name="cancellationToken" /> | ||
/// is cancelled.</exception> | ||
public async Task TransformFileAsync( | ||
Func<Task<Stream>> streamTaskFactory, | ||
string targetPath, | ||
IMSBuildNuGetProjectSystem projectSystem, | ||
CancellationToken cancellationToken) | ||
{ | ||
if (streamTaskFactory == null) | ||
{ | ||
throw new ArgumentNullException(nameof(streamTaskFactory)); | ||
} | ||
|
||
if (projectSystem == null) | ||
{ | ||
throw new ArgumentNullException(nameof(projectSystem)); | ||
} | ||
|
||
cancellationToken.ThrowIfCancellationRequested(); | ||
|
||
await MSBuildNuGetProjectSystemUtility.TryAddFileAsync( | ||
projectSystem, | ||
targetPath, | ||
async () => StreamUtility.StreamFromString(await ProcessAsync(streamTaskFactory, projectSystem, cancellationToken)), | ||
cancellationToken); | ||
} | ||
|
||
/// <summary> | ||
/// Asynchronously reverses the transform on the targetPath, using all the potential source of change. | ||
/// </summary> | ||
/// <param name="streamTaskFactory">A factory for accessing the file to be reverted from the nupkg being uninstalled.</param> | ||
/// <param name="targetPath">A path to the file to be reverted.</param> | ||
/// <param name="matchingFiles">Other files in other packages that may have changed the <paramref name="targetPath" />.</param> | ||
/// <param name="projectSystem">The project where this change is taking place.</param> | ||
/// <param name="cancellationToken">A cancellation token.</param> | ||
/// <returns>A task that represents the asynchronous operation.</returns> | ||
/// <exception cref="ArgumentNullException">Thrown if <paramref name="streamTaskFactory" /> | ||
/// is <c>null</c>.</exception> | ||
/// <exception cref="ArgumentNullException">Thrown if <paramref name="projectSystem" /> | ||
/// is <c>null</c>.</exception> | ||
/// <exception cref="OperationCanceledException">Thrown if <paramref name="cancellationToken" /> | ||
/// is cancelled.</exception> | ||
public async Task RevertFileAsync( | ||
Func<Task<Stream>> streamTaskFactory, | ||
string targetPath, | ||
IEnumerable<InternalZipFileInfo> matchingFiles, | ||
IMSBuildNuGetProjectSystem projectSystem, | ||
CancellationToken cancellationToken) | ||
{ | ||
if (streamTaskFactory == null) | ||
{ | ||
throw new ArgumentNullException(nameof(streamTaskFactory)); | ||
} | ||
|
||
if (projectSystem == null) | ||
{ | ||
throw new ArgumentNullException(nameof(projectSystem)); | ||
} | ||
|
||
cancellationToken.ThrowIfCancellationRequested(); | ||
|
||
await MSBuildNuGetProjectSystemUtility.DeleteFileSafeAsync( | ||
targetPath, | ||
async () => StreamUtility.StreamFromString(await ProcessAsync(streamTaskFactory, projectSystem, cancellationToken)), | ||
projectSystem, | ||
cancellationToken); | ||
} | ||
|
||
internal static Task<string> ProcessAsync( | ||
Func<Task<Stream>> streamTaskFactory, | ||
IMSBuildNuGetProjectSystem projectSystem, | ||
CancellationToken cancellationToken) | ||
{ | ||
return Common.Preprocessor.ProcessAsync( | ||
streamTaskFactory, | ||
propName => projectSystem.GetPropertyValue(propName), | ||
cancellationToken); | ||
} | ||
} | ||
} |
Oops, something went wrong.