visual studio solución restaurar referencemanagerpackage paquetes paquete nugetpackage los guardó guarde correctamente antes administrar nuget visual-studio-2015

studio - restaurar paquetes nuget console



VS2015: el paquete ''NuGetPackage'' no se cargó correctamente (11)

Al actualizar proyectos con paquetes nuget de Vx20XX a VS2015, es posible que tenga un problema con los paquetes nuget.

Ejemplo de mensaje de error: Este proyecto hace referencia a los paquetes NuGet que faltan en esta computadora. Habilite Restaurar paquete NuGet para descargarlos. Para obtener más información, consulte http://go.microsoft.com/fwlink/?LinkID=322105 .

Solucioné mi problema escribiendo un pequeño programa que realiza la restauración del paquete integrado MSBuild vs. Restauración automática del paquete

Puede descargar el ejecutable de la herramienta here .

Por favor déjame saber el resultado :-) !

Código como referencia:

<Window x:Class="FixNuGetProblemsInVs2015.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:FixNuGetProblemsInVs2015" mc:Ignorable="d" Title="Fix NuGet Packages problems in Visual Studio 2015 (By Eric Ouellet)" Height="350" Width="525"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto"></RowDefinition> <RowDefinition Height="Auto"></RowDefinition> <RowDefinition Height="*"></RowDefinition> <RowDefinition Height="Auto"></RowDefinition> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"></ColumnDefinition> <ColumnDefinition Width="10"></ColumnDefinition> <ColumnDefinition></ColumnDefinition> </Grid.ColumnDefinitions> <TextBlock Grid.Row="0" Grid.Column="0">Root directory of projects</TextBlock> <Grid Grid.Row="0" Grid.Column="2"> <Grid.ColumnDefinitions> <ColumnDefinition></ColumnDefinition> <ColumnDefinition Width="Auto"></ColumnDefinition> </Grid.ColumnDefinitions> <TextBox Grid.Column="0" Name="DirProjects"></TextBox> <Button Grid.Column="1" VerticalAlignment="Bottom" Name="BrowseDirProjects" Click="BrowseDirProjectsOnClick">Browse...</Button> </Grid> <!--<TextBlock Grid.Row="1" Grid.Column="0">Directory of NuGet Packages</TextBlock> <Grid Grid.Row="1" Grid.Column="2"> <Grid.ColumnDefinitions> <ColumnDefinition></ColumnDefinition> <ColumnDefinition Width="Auto"></ColumnDefinition> </Grid.ColumnDefinitions> <TextBox Grid.Column="0" Name="DirPackages"></TextBox> <Button Grid.Column="1" Name="BrowseDirPackages" Click="BrowseDirPackagesOnClick">Browse...</Button> </Grid>--> <TextBox Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3" Name="TxtLog" IsReadOnly="True"></TextBox> <Button Grid.Row="3" Grid.Column="0" Click="ButtonRevertOnClick">Revert back</Button> <Button Grid.Row="3" Grid.Column="2" Click="ButtonFixOnClick">Fix</Button> </Grid> </Window> using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Forms; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Xml; using System.Xml.Linq; using Application = System.Windows.Application; using MessageBox = System.Windows.MessageBox; /// <summary> /// Applying recommanded modifications in section : "MSBuild-Integrated package restore vs. Automatic Package Restore" /// of : http://docs.nuget.org/Consume/Package-Restore/Migrating-to-Automatic-Package-Restore /// </summary> namespace FixNuGetProblemsInVs2015 { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); DirProjects.Text = @"c:/prj"; // DirPackages.Text = @"C:/PRJ/NuGetPackages"; } private void BrowseDirProjectsOnClick(object sender, RoutedEventArgs e) { FolderBrowserDialog dlg = new FolderBrowserDialog(); dlg.SelectedPath = DirProjects.Text; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { DirProjects.Text = dlg.SelectedPath; } } //private void BrowseDirPackagesOnClick(object sender, RoutedEventArgs e) //{ // FolderBrowserDialog dlg = new FolderBrowserDialog(); // dlg.SelectedPath = DirPackages.Text; // if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) // { // DirPackages.Text = dlg.SelectedPath; // } //} // private string _dirPackages; private void ButtonFixOnClick(object sender, RoutedEventArgs e) { DoJob(false); } private void ButtonRevertOnClick(object sender, RoutedEventArgs e) { DoJob(true); } private void DoJob(bool revert = false) { TxtLog.Text = ""; string dirProjects = DirProjects.Text; // _dirPackages = DirPackages.Text; if (!Directory.Exists(dirProjects)) { MessageBox.Show("Projects directory does not exists: " + dirProjects); return; } //if (!Directory.Exists(_dirPackages)) //{ // MessageBox.Show("Packages directory does not exists: " + _dirPackages); // return; //} RecurseFolder(dirProjects, revert); } private void RecurseFolder(string dirProjects, bool revert = false) { if (revert) { Revert(dirProjects); } else { FixFolder(dirProjects); } foreach (string subfolder in Directory.EnumerateDirectories(dirProjects)) { RecurseFolder(subfolder, revert); } } private const string BackupSuffix = ".fix_nuget_backup"; private void Revert(string dirProject) { foreach (string filename in Directory.EnumerateFiles(dirProject)) { if (filename.ToLower().EndsWith(BackupSuffix)) { string original = filename.Substring(0, filename.Length - BackupSuffix.Length); if (File.Exists(original)) { File.Delete(original); } File.Move(filename, original); Log("File reverted: " + filename + " ==> " + original); } } } private void FixFolder(string dirProject) { BackupFile(System.IO.Path.Combine(dirProject, "nuget.targets")); BackupFile(System.IO.Path.Combine(dirProject, "nuget.exe")); foreach (string filename in Directory.EnumerateFiles(dirProject)) { if (filename.ToLower().EndsWith(".csproj")) { FromProjectFileRemoveNugetTargets(filename); } } } private void BackupFile(string path) { if (File.Exists(path)) { string backup = path + BackupSuffix; if (!File.Exists(backup)) { File.Move(path, backup); Log("File backup: " + backup); } else { Log("Project has already a backup: " + backup); } } } private void FromProjectFileRemoveNugetTargets(string prjFilename) { XDocument xml = XDocument.Load(prjFilename); List<XElement> elementsToRemove = new List<XElement>(); foreach (XElement element in xml.Descendants()) { if (element.Name.LocalName == "Import") { var att = element.Attribute("Project"); if (att != null) { if (att.Value.Contains("NuGet.targets")) { elementsToRemove.Add(element); } } } if (element.Name.LocalName == "Target") { var att = element.Attribute("Name"); if (att != null && att.Value == "EnsureNuGetPackageBuildImports") { elementsToRemove.Add(element); } } } if (elementsToRemove.Count > 0) { elementsToRemove.ForEach(element => element.Remove()); BackupFile(prjFilename); xml.Save(prjFilename); Log("Project updated: " + prjFilename); } } private void Log(string msg) { TxtLog.Text += msg + "/r/n"; } } }

Acabo de abrir VS 2015 Enterprise RTM, abrí un proyecto de trabajo existente, obteniendo el siguiente error:

Microsoft Visual Studio

El paquete ''NuGetPackage'' no se cargó correctamente.

El problema puede haber sido causado por un cambio de configuración o por la instalación de otra extensión. Puede obtener más información examinando el archivo C:/Users/REDACTED/AppData/Roaming/Microsoft/VisualStudio/14.0/ActivityLog.xml .

Reiniciar Visual Studio podría ayudar a resolver este problema.

¿Continuar mostrando este mensaje de error?

[Si no]

Reiniciar no ayudó. Examiné el archivo de registro y encontré las siguientes secciones relevantes para nuget:

<entry> <record>555</record> <time>2015/07/20 16:06:34.364</time> <type>Error</type> <source>Extension Manager</source> <description>Extension will not be loaded because an extension with the same ID &apos;Microsoft.Dev14.VsixTemplatesPackage.443cca91-ec20-41e5-a165-f28e56b89650&apos; is already loaded at C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO 14.0/COMMON7/IDE/ EXTENSIONS/G2URSPAC.VAZ/...</description> <path>C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO 14.0/COMMON7/IDE/EXTENSIONS/ NUGETIFIEDEXTENSIBILITYTEMPLATES/</path> </entry> <entry> <record>556</record> <time>2015/07/20 16:06:34.364</time> <type>Error</type> <source>Extension Manager</source> <description>Extension will not be loaded because an extension with the same ID &apos;Microsoft.VisualStudio.TeamFoundation.TeamExplorer.Extensions&apos; is already loaded at C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO 14.0/COMMON7/IDE/EXTENSIONS/ B1NUOYPH.H2N/...</description> <path>C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO 14.0/COMMON7/IDE/COMMONEXTENSIONS/ MICROSOFT/TEAMFOUNDATION/TEAM EXPLORER/</path> </entry>

Lo que sugeriría una extensión duplicada, pero este no parece ser el caso en el administrador de extensiones.

Esto está en una máquina que también tiene instalado VS2013. Nunca se ha instalado ninguna de las versiones de vista previa / RC de VS2015.


Después de una instalación completamente limpia de Visual Studio Professional 2015 desde el sitio web de MSDN, ejecuté VS2015 como administrador, abrí la consola de Package Manager desde Tools -> NuGet Package Manager... -> Package Manager Console y recibí este error:

"Windows PowerShell updated your execution policy successfully, but the setting is overridden by a policy defined at a more specific scope. Due to the override, your shell will retain its current effective execution policy of Unrestricted. Type "Get-ExecutionPolicy -List" to view your execution policy settings. For more information please see "Get-Help Set-ExecutionPolicy"

Siguiendo los pasos anteriores para

1) Use Tools -> Extensions and Updates... para desinstalar NuGet Package Manager for Visual Studio 2015 .

2) Reinicie Visual Studio.

3) Use Tools -> Extensions and Updates... para reinstalar NuGet Package Manager for Visual Studio 2015 .

4) Reinicie Visual Studio.

Ahora, cuando abro la consola de Package Manager, Powershell se carga correctamente y todo está bien. ¡Muchas gracias por esto!


Eliminar completamente NuGet a través de extensiones y actualizaciones, reiniciar VS y luego reinstalar NuGet a través de extensiones y actualizaciones resolvió el problema para mí. No fue necesaria una reinstalación completa de VS.


Eliminar todos los archivos de esta carpeta C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/Extensions/imf5jbeu.eak parece haber funcionado para mí.


Encontré esto en google, recibí un error similar: el paquete ''NuGetPackage'' no se cargó correctamente.

Se produjo un error al leer el archivo xxx. Hay paquetes duplicados.

Verifique el archivo packages.config en cada proyecto y elimine la línea del paquete duplicado, y debería funcionar.


Entrar en :

Herramientas
Extensiones y Actualizaciones

Inserte en el cuadro de búsqueda a la derecha de Nuget Package Manager y Nuget Package Manager (configuración completa).

Después de eso, tendría la opción Administrar paquetes Nuget en la sección Herramientas.


La actualización de Nuget a la última versión parece haber resuelto el problema.

  1. Herramientas> Extensiones y actualizaciones

  2. Actualizaciones> Galería de Visual Studio

  3. Haga clic en Actualizar en la opción Administrador de paquetes Nuget


Parece que nuget en VS2015 está configurado para mostrar solo paquetes de microsoft. Para poder buscar todos los paquetes en nuget.org, vaya a Herramientas> Opciones> NuGet Package Manager> Fuentes de paquetes, haga clic en agregar, ponga nuget.org como Nombre y https://www.nuget.org/api/v2/ como Fuente , luego haga clic en Aceptar. Ahora en Nuget Package Manager puede seleccionar nuget.org (o All) como fuente del paquete y podrá buscar todos los paquetes (no solo los que provienen de microsoft).


Reiniciar Visual Studio (2017) me arregló esto.


Tuve el mismo problema y lo resolví con la solución ya mencionada, pero necesitaba más intentos. Es necesario reiniciar VS completamente después de desinstalar e instalar la extensión NuGetPackage y en mi sistema no funcionó hasta que cerré mi solución abierta. Esperemos que la extensión NuGetPackage se vuelva más estable en el futuro cercano.


Tener en cuenta

¡Una reinstalación del Administrador de paquetes NuGet NO parece eliminar el archivo NuGet.Config existente contenido en c: / users / name / AppData / Roaming / NuGet!

Al mío le faltaba la sección ''packageSources'' (por qué, no lo sé), pero como este archivo no fue recreado, ¡NuGet todavía no funcionó!

¡Así que ingrese manualmente esta sección o elimine este archivo de configuración, luego reinstale NuGet a través de las Extensiones y Actualizaciones que recrearán uno nuevo!