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());
     }
 }
 internal static async Task DeleteFileSafeAsync(
     string path,
     Func <Task <Stream> > streamFactory,
     IMSBuildProjectSystem projectSystem,
     CancellationToken cancellationToken)
 {
     // Only delete the file if it exists and the checksum is the same
     if (projectSystem.FileExistsInProject(path))
     {
         var fullPath = Path.Combine(projectSystem.ProjectFullPath, path);
         if (await FileSystemUtility.ContentEqualsAsync(fullPath, streamFactory))
         {
             PerformSafeAction(() => projectSystem.RemoveFile(path), projectSystem.NuGetProjectContext);
         }
         else
         {
             // This package installed a file that was modified so warn the user
             projectSystem.NuGetProjectContext.Log(MessageLevel.Warning, Strings.Warning_FileModified, fullPath);
         }
     }
 }