/// <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, IMSBuildProjectSystem projectSystem, CancellationToken cancellationToken) { if (streamTaskFactory == null) { throw new ArgumentNullException(nameof(streamTaskFactory)); } if (projectSystem == null) { throw new ArgumentNullException(nameof(projectSystem)); } cancellationToken.ThrowIfCancellationRequested(); // Get the xml fragment var xmlFragment = await GetXmlAsync(streamTaskFactory, projectSystem, cancellationToken); var transformDocument = XmlUtility.GetOrCreateDocument(xmlFragment.Name, targetPath, projectSystem); // Do a merge transformDocument.Root.MergeWith(xmlFragment, _nodeActions); MSBuildNuGetProjectSystemUtility.AddFile(projectSystem, targetPath, transformDocument.Save); }
private static async Task <XElement> GetXmlAsync( InternalZipFileInfo packageFileInfo, IMSBuildProjectSystem projectSystem, CancellationToken cancellationToken) { string content; using (var packageStream = File.OpenRead(packageFileInfo.ZipArchivePath)) { var zipArchive = new ZipArchive(packageStream); var zipArchivePackageEntry = PathUtility.GetEntry(zipArchive, packageFileInfo.ZipArchiveEntryFullName); if (zipArchivePackageEntry == null) { throw new ArgumentException("internalZipFileInfo"); } content = await Preprocessor.ProcessAsync( () => Task.FromResult(zipArchivePackageEntry.Open()), projectSystem, cancellationToken); } return(XElement.Parse(content, LoadOptions.PreserveWhitespace)); }
public MSBuildNuGetProject( IMSBuildProjectSystem msbuildNuGetProjectSystem, string folderNuGetProjectPath, string packagesConfigFolderPath) { if (folderNuGetProjectPath == null) { throw new ArgumentNullException(nameof(folderNuGetProjectPath)); } if (packagesConfigFolderPath == null) { throw new ArgumentNullException(nameof(packagesConfigFolderPath)); } ProjectStyle = ProjectStyle.PackagesConfig; ProjectSystem = msbuildNuGetProjectSystem ?? throw new ArgumentNullException(nameof(msbuildNuGetProjectSystem)); FolderNuGetProject = new FolderNuGetProject(folderNuGetProjectPath); InternalMetadata.Add(NuGetProjectMetadataKeys.Name, ProjectSystem.ProjectName); InternalMetadata.Add(NuGetProjectMetadataKeys.TargetFramework, ProjectSystem.TargetFramework); InternalMetadata.Add(NuGetProjectMetadataKeys.FullPath, msbuildNuGetProjectSystem.ProjectFullPath); InternalMetadata.Add(NuGetProjectMetadataKeys.UniqueName, msbuildNuGetProjectSystem.ProjectUniqueName); PackagesConfigNuGetProject = new PackagesConfigNuGetProject(packagesConfigFolderPath, InternalMetadata); }
internal static async Task TryAddFileAsync( IMSBuildProjectSystem projectSystem, string path, Func <Task <Stream> > streamTaskFactory, CancellationToken cancellationToken) { if (projectSystem.FileExistsInProject(path)) { // file exists in project, ask user if he wants to overwrite or ignore var conflictMessage = string.Format(CultureInfo.CurrentCulture, Strings.FileConflictMessage, path, projectSystem.ProjectName); var fileConflictAction = projectSystem.NuGetProjectContext.ResolveFileConflict(conflictMessage); if (fileConflictAction == FileConflictAction.Overwrite || fileConflictAction == FileConflictAction.OverwriteAll) { // overwrite projectSystem.NuGetProjectContext.Log(MessageLevel.Info, Strings.Info_OverwritingExistingFile, path); using (var stream = await streamTaskFactory()) { projectSystem.AddFile(path, stream); } } else { // ignore projectSystem.NuGetProjectContext.Log(MessageLevel.Warning, Strings.Warning_FileAlreadyExists, path); } } else { projectSystem.AddFile(path, await streamTaskFactory()); } }
/// <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, IMSBuildProjectSystem 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 IEnumerable <string> GetFiles( IMSBuildProjectSystem projectSystem, string path, string filter, bool recursive) { return(projectSystem.GetFiles(path, filter, recursive)); }
public static XDocument CreateDocument(XName rootName, string path, IMSBuildProjectSystem msBuildNuGetProjectSystem) { var document = new XDocument(new XElement(rootName)); // Add it to the project system MSBuildNuGetProjectSystemUtility.AddFile(msBuildNuGetProjectSystem, path, document.Save); return(document); }
public NetFrameworkNuGetProject( IMSBuildProjectSystem msbuildNuGetProjectSystem, string folderNuGetProjectPath, string packagesConfigFolderPath, INuGetProjectServices nuGetProjectServices) : base(msbuildNuGetProjectSystem, folderNuGetProjectPath, packagesConfigFolderPath) { //ProjectServices = nuGetProjectServices; }
internal static void AddFile(IMSBuildProjectSystem projectSystem, string path, Action <Stream> writeToStream) { using (var memoryStream = new MemoryStream()) { writeToStream(memoryStream); memoryStream.Seek(0, SeekOrigin.Begin); projectSystem.AddFile(path, memoryStream); } }
private static async Task <XElement> GetXmlAsync( Func <Task <Stream> > streamTaskFactory, IMSBuildProjectSystem projectSystem, CancellationToken cancellationToken) { var content = await Preprocessor.ProcessAsync(streamTaskFactory, projectSystem, cancellationToken); return(XElement.Parse(content, LoadOptions.PreserveWhitespace)); }
public PackageInstaller(string localRepositoryPath, string projectPath, IConsole console, string projectName, bool addReferencesToProject) { _projectName = projectName; _localRepositoryPath = localRepositoryPath; IPackagePathResolver packagePathResolver = new DefaultPackagePathResolver(localRepositoryPath); IPackageRepository localRepository = new UnzipedLocalPackageRepository(localRepositoryPath, _flagFileName); _projectSystem = new ModdedMSBuildProjectSystem(projectPath, addReferencesToProject) { Logger = console }; _projectManager = new ProjectManager(localRepository, packagePathResolver, _projectSystem, localRepository) { Logger = console }; }
private static NugetUpdateTask.ProjectPair GetProject(string packagesConfigPath) { IMSBuildProjectSystem msBuildProjectSystem = null; msBuildProjectSystem = NugetUpdateTask.GetMSBuildProject(packagesConfigPath); return(new NugetUpdateTask.ProjectPair { PackagesConfigPath = packagesConfigPath, Project = msBuildProjectSystem }); }
public TestMSBuildNuGetProject( IMSBuildProjectSystem msbuildProjectSystem, string folderNuGetProjectPath, string packagesConfigFolderPath) : base( msbuildProjectSystem, folderNuGetProjectPath, packagesConfigFolderPath) { ProjectClosure = new List <ExternalProjectReference>(); }
internal static Task <string> ProcessAsync( Func <Task <Stream> > streamTaskFactory, IMSBuildProjectSystem projectSystem, CancellationToken cancellationToken) { return(Common.Preprocessor.ProcessAsync( streamTaskFactory, propName => projectSystem.GetPropertyValue(propName), cancellationToken)); }
private static ProjectPair GetProject(string packagesConfigPath) { IMSBuildProjectSystem msBuildProjectSystem = null; msBuildProjectSystem = GetMSBuildProject(packagesConfigPath); return(new ProjectPair { PackagesConfigPath = packagesConfigPath, Project = msBuildProjectSystem }); }
public TestMSBuildNuGetProject( IMSBuildProjectSystem msbuildProjectSystem, string folderNuGetProjectPath, string packagesConfigFolderPath, string projectId) : base( msbuildProjectSystem, folderNuGetProjectPath, packagesConfigFolderPath) { InternalMetadata[NuGetProjectMetadataKeys.ProjectId] = projectId; }
public TestBuildIntegratedNuGetProject( string jsonConfig, IMSBuildProjectSystem msbuildProjectSystem) : base( jsonConfig, Path.Combine( msbuildProjectSystem.ProjectFullPath, $"{msbuildProjectSystem.ProjectName}.csproj")) { InternalMetadata.Add(NuGetProjectMetadataKeys.UniqueName, msbuildProjectSystem.ProjectName); ProjectClosure = new List <ExternalProjectReference>(); }
public TestMSBuildNuGetProject( IMSBuildProjectSystem msbuildProjectSystem, string folderNuGetProjectPath, string packagesConfigFolderPath, string projectId) : base( msbuildProjectSystem, folderNuGetProjectPath, packagesConfigFolderPath) { InternalMetadata[NuGetProjectMetadataKeys.ProjectId] = projectId; //ProjectClosure = new List<ExternalProjectReference>(); }
internal static IEnumerable <string> GetDirectoriesSafe(IMSBuildProjectSystem projectSystem, string path) { try { return(GetDirectories(projectSystem, path)); } catch (Exception e) { projectSystem.NuGetProjectContext.Log(MessageLevel.Warning, e.Message); } return(Enumerable.Empty <string>()); }
internal static IEnumerable <string> GetFilesSafe(IMSBuildProjectSystem projectSystem, string path, string filter) { try { return(GetFiles(projectSystem, path, filter, recursive: false)); } catch (Exception e) { projectSystem.NuGetProjectContext.Log(MessageLevel.Warning, e.Message); } return(Enumerable.Empty <string>()); }
/// <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, IMSBuildProjectSystem projectSystem, CancellationToken cancellationToken) { if (streamTaskFactory == null) { throw new ArgumentNullException(nameof(streamTaskFactory)); } if (projectSystem == null) { throw new ArgumentNullException(nameof(projectSystem)); } cancellationToken.ThrowIfCancellationRequested(); // Get the xml snippet var xmlFragment = await GetXmlAsync(streamTaskFactory, projectSystem, cancellationToken); var document = XmlUtility.GetOrCreateDocument(xmlFragment.Name, projectSystem.ProjectFullPath, targetPath, projectSystem.NuGetProjectContext); // Merge the other xml elements into one element within this xml hierarchy (matching the config file path) var elements = new List <XElement>(); foreach (var matchingFile in matchingFiles) { elements.Add(await GetXmlAsync(matchingFile, projectSystem, cancellationToken)); } var mergedFragments = elements.Aggregate( new XElement(xmlFragment.Name), (left, right) => left.MergeWith(right, _nodeActions)); // Take the difference of the xml and remove it from the main xml file document.Root.Except(xmlFragment.Except(mergedFragments)); // Save the new content to the file system using (var fileStream = FileSystemUtility.CreateFile( projectSystem.ProjectFullPath, targetPath, projectSystem.NuGetProjectContext)) { document.Save(fileStream); } }
public PackageInstaller(string localRepositoryPath, string projectPath, IConsole console, bool addReferencesToProject) { _localRepositoryPath = localRepositoryPath; IPackagePathResolver packagePathResolver = new DefaultPackagePathResolver(localRepositoryPath); IPackageRepository localRepository = new UnzipedLocalPackageRepository(localRepositoryPath, _flagFileName); _projectSystem = new ModdedMSBuildProjectSystem(projectPath, addReferencesToProject) { Logger = console }; _projectManager = new ProjectManager(localRepository, packagePathResolver, _projectSystem, localRepository) { Logger = console }; }
public static XDocument GetOrCreateDocument(XName rootName, string path, IMSBuildProjectSystem msBuildNuGetProjectSystem) { if (File.Exists(Path.Combine(msBuildNuGetProjectSystem.ProjectFullPath, path))) { try { return(GetDocument(msBuildNuGetProjectSystem.ProjectFullPath, path)); } catch (FileNotFoundException) { return(CreateDocument(rootName, path, msBuildNuGetProjectSystem)); } } return(CreateDocument(rootName, path, msBuildNuGetProjectSystem)); }
public BindingRedirectManager(string configurationFile, IMSBuildProjectSystem msBuildNuGetProjectSystem) { if (String.IsNullOrEmpty(configurationFile)) { throw new ArgumentException( Strings.Argument_Cannot_Be_Null_Or_Empty, nameof(configurationFile)); } if (msBuildNuGetProjectSystem == null) { throw new ArgumentNullException(nameof(msBuildNuGetProjectSystem)); } ConfigurationFile = configurationFile; MSBuildNuGetProjectSystem = msBuildNuGetProjectSystem; }
// Deletes an empty folder from disk and the project private static void DeleteDirectory(IMSBuildProjectSystem projectSystem, string path) { var fullPath = Path.Combine(projectSystem.ProjectFullPath, path); if (!Directory.Exists(fullPath)) { return; } // Only delete this folder if it is empty and we didn't specify that we want to recurse if (GetFiles(projectSystem, path, "*.*", recursive: false).Any() || GetDirectories(projectSystem, path).Any()) { projectSystem.NuGetProjectContext.Log(MessageLevel.Warning, Strings.Warning_DirectoryNotEmpty, path); return; } projectSystem.RegisterProcessedFiles(new[] { path }); projectSystem.DeleteDirectory(path, recursive: false); // Workaround for update-package TFS issue. If we're bound to TFS, do not try and delete directories. var sourceControlManager = SourceControlUtility.GetSourceControlManager(projectSystem.NuGetProjectContext); if (sourceControlManager != null) { // Source control bound, do not delete return; } // For potential project systems that do not remove items from disk, we delete the folder directly // There is no actual scenario where we know this is broken without the code below, but since the // code was always there, we are leaving it behind for now. if (!Directory.Exists(fullPath)) { Directory.Delete(fullPath, recursive: false); // The directory is not guaranteed to be gone since there could be // other open handles. Wait, up to half a second, until the directory is gone. for (var i = 0; Directory.Exists(fullPath) && i < 5; ++i) { Thread.Sleep(100); } projectSystem.RegisterProcessedFiles(new[] { path }); projectSystem.NuGetProjectContext.Log(MessageLevel.Debug, Strings.Debug_RemovedFolder, fullPath); } }
internal static async Task PerformXdtTransformAsync( Func <Task <Stream> > streamTaskFactory, string targetPath, IMSBuildProjectSystem msBuildNuGetProjectSystem, CancellationToken cancellationToken) { if (FileSystemUtility.FileExists(msBuildNuGetProjectSystem.ProjectFullPath, targetPath)) { var content = await Preprocessor.ProcessAsync(streamTaskFactory, msBuildNuGetProjectSystem, cancellationToken); try { using (var transformation = new XmlTransformation(content, isTransformAFile: false, logger: null)) { using (var document = new XmlTransformableDocument()) { // make sure we close the input stream immediately so that we can override // the file below when we save to it. string path = FileSystemUtility.GetFullPath(msBuildNuGetProjectSystem.ProjectFullPath, targetPath); using (FileStream fileStream = File.OpenRead(path)) { using var xmlReader = XmlReader.Create(fileStream, GetXmlReaderSettings(LoadOptions.PreserveWhitespace)); document.Load(xmlReader); } var succeeded = transformation.Apply(document); if (succeeded) { // save the result into a memoryStream first so that if there is any // exception during document.Save(), the original file won't be truncated. MSBuildNuGetProjectSystemUtility.AddFile(msBuildNuGetProjectSystem, targetPath, document.Save); } } } } catch (Exception exception) { throw new InvalidDataException( string.Format( CultureInfo.CurrentCulture, Strings.XdtError + " " + exception.Message, targetPath, msBuildNuGetProjectSystem.ProjectName), exception); } } }
private static ProjectPair GetProject(string packagesConfigPath) { IMSBuildProjectSystem msBuildProjectSystem = null; try { msBuildProjectSystem = GetMSBuildProject(packagesConfigPath); } catch (CommandLineException) { } return(new ProjectPair { PackagesConfigPath = packagesConfigPath, Project = msBuildProjectSystem }); }
internal static XDocument GetOrCreateDocument(XName rootName, string path, IMSBuildProjectSystem msBuildNuGetProjectSystem) { if (File.Exists(Path.Combine(msBuildNuGetProjectSystem.ProjectFullPath, path))) { try { return(Shared.XmlUtility.Load(Path.Combine(msBuildNuGetProjectSystem.ProjectFullPath, path), LoadOptions.PreserveWhitespace)); } catch (FileNotFoundException) { } } var document = new XDocument(new XElement(rootName)); // Add it to the project system AddFile(msBuildNuGetProjectSystem, path, document.Save); return(document); }
private void UpdatePackages(IMSBuildProjectSystem projectSystem, string repositoryPath = null, IPackageRepository sourceRepository = null) { // Resolve the repository path repositoryPath = repositoryPath ?? GetRepositoryPath(projectSystem.Root); var sharedRepositoryFileSystem = new PhysicalFileSystem(repositoryPath); var pathResolver = new DefaultPackagePathResolver(sharedRepositoryFileSystem); // Create the local and source repositories var sharedPackageRepository = new SharedPackageRepository(pathResolver, sharedRepositoryFileSystem, sharedRepositoryFileSystem); var localRepository = new PackageReferenceRepository(projectSystem, projectSystem.ProjectName, sharedPackageRepository); sourceRepository = sourceRepository ?? AggregateRepositoryHelper.CreateAggregateRepositoryFromSources(RepositoryFactory, SourceProvider, Source); Console.WriteLine(LocalizedResourceManager.GetString("UpdatingProject"), projectSystem.ProjectName); UpdatePackages(localRepository, sharedRepositoryFileSystem, sharedPackageRepository, sourceRepository, localRepository, pathResolver, projectSystem); projectSystem.Save(); }
private static string ResolveTargetPath( IMSBuildProjectSystem projectSystem, IDictionary <FileTransformExtensions, IPackageFileTransformer> fileTransformers, Func <FileTransformExtensions, string> extensionSelector, string effectivePath, out IPackageFileTransformer transformer) { string truncatedPath; // Remove the transformer extension (e.g. .pp, .transform) transformer = FindFileTransformer(fileTransformers, extensionSelector, effectivePath, out truncatedPath); if (transformer != null) { effectivePath = truncatedPath; } return(projectSystem.ResolvePath(effectivePath)); }
public VsMSBuildNuGetProject( IVsProjectAdapter projectAdapter, IMSBuildProjectSystem msbuildNuGetProjectSystem, string folderNuGetProjectPath, string packagesConfigFolderPath, INuGetProjectServices projectServices) : base( msbuildNuGetProjectSystem, folderNuGetProjectPath, packagesConfigFolderPath) { Assumes.Present(projectAdapter); Assumes.Present(msbuildNuGetProjectSystem); Assumes.Present(projectServices); InternalMetadata.Add(NuGetProjectMetadataKeys.ProjectId, projectAdapter.ProjectId); ProjectServices = projectServices; }
private IEnumerable<PackageDependency> GetReferences(string packagesConfigPath, IMSBuildProjectSystem project = null, string repositoryPath = null, IPackageRepository sourceRepository = null) { // Get the msbuild project project = project ?? NugetUpdateTask.GetMSBuildProject(packagesConfigPath); // Resolve the repository path repositoryPath = repositoryPath ?? GetRepositoryPath(project.Root); var sharedRepositoryFileSystem = new PhysicalFileSystem(repositoryPath); var pathResolver = new DefaultPackagePathResolver(sharedRepositoryFileSystem); // Create the local and source repositories var sharedPackageRepository = new SharedPackageRepository(pathResolver, sharedRepositoryFileSystem, sharedRepositoryFileSystem); var localRepository = new PackageReferenceRepository(project, sharedPackageRepository); sourceRepository = sourceRepository ?? AggregateRepositoryHelper.CreateAggregateRepositoryFromSources(RepositoryFactory, SourceProvider, Source); IPackageConstraintProvider constraintProvider = localRepository; return GetReferences(localRepository, sharedRepositoryFileSystem, sharedPackageRepository, sourceRepository, constraintProvider, pathResolver, project); }
private void UpdatePackages(IMSBuildProjectSystem project, string repositoryPath = null, IPackageRepository sourceRepository = null) { // Resolve the repository path repositoryPath = repositoryPath ?? GetRepositoryPath(project.Root); var sharedRepositoryFileSystem = new PhysicalFileSystem(repositoryPath); var pathResolver = new DefaultPackagePathResolver(sharedRepositoryFileSystem); // Create the local and source repositories var sharedPackageRepository = new SharedPackageRepository(pathResolver, sharedRepositoryFileSystem, sharedRepositoryFileSystem); var localRepository = new PackageReferenceRepository(project, project.ProjectName, sharedPackageRepository); sourceRepository = sourceRepository ?? AggregateRepositoryHelper.CreateAggregateRepositoryFromSources(RepositoryFactory, SourceProvider, Source); Console.WriteLine(LocalizedResourceManager.GetString("UpdatingProject"), project.ProjectName); UpdatePackages(localRepository, sharedRepositoryFileSystem, sharedPackageRepository, sourceRepository, localRepository, pathResolver, project); project.Save(); }
private void UpdatePackages(string packagesConfigPath, IMSBuildProjectSystem project = null, string repositoryPath = null, IPackageRepository sourceRepository = null) { // Get the msbuild project project = project ?? GetMSBuildProject(packagesConfigPath); // Resolve the repository path repositoryPath = repositoryPath ?? GetReposioryPath(project.Root); var pathResolver = new DefaultPackagePathResolver(repositoryPath); // Create the local and source repositories var localRepository = new PackageReferenceRepository(project, new SharedPackageRepository(repositoryPath)); sourceRepository = sourceRepository ?? AggregateRepositoryHelper.CreateAggregateRepositoryFromSources(RepositoryFactory, SourceProvider, Source); IPackageConstraintProvider constraintProvider = localRepository; Console.WriteLine(NuGetResources.UpdatingProject, project.ProjectName); UpdatePackages(localRepository, sourceRepository, constraintProvider, pathResolver, project); project.Save(); }
private void UpdatePackages(string packagesConfigPath, IMSBuildProjectSystem project = null, string repositoryPath = null, IPackageRepository sourceRepository = null) { // Get the msbuild project project = project ?? GetMSBuildProject(packagesConfigPath); // Resolve the repository path repositoryPath = repositoryPath ?? GetRepositoryPath(project.Root); var sharedRepositoryFileSystem = new PhysicalFileSystem(repositoryPath); var pathResolver = new DefaultPackagePathResolver(sharedRepositoryFileSystem); // Create the local and source repositories var sharedPackageRepository = new SharedPackageRepository(pathResolver, sharedRepositoryFileSystem, sharedRepositoryFileSystem); var localRepository = new PackageReferenceRepository(project, sharedPackageRepository); sourceRepository = sourceRepository ?? AggregateRepositoryHelper.CreateAggregateRepositoryFromSources(RepositoryFactory, SourceProvider, Source); IPackageConstraintProvider constraintProvider = localRepository; Log(Level.Info, "Updating project {0}", project.ProjectName); UpdatePackages(localRepository, sharedRepositoryFileSystem, sharedPackageRepository, sourceRepository, constraintProvider, pathResolver, project); project.Save(); }