Is there a way to automatically update nuget.exe in the .nuget folder when using package restore?

后端 未结 3 366
执笔经年
执笔经年 2020-12-23 02:46

My team has been using the Enable Package Restore option since Nuget 1.5 to keep packages out of our source control. When Nuget 1.6 was released we noticed an issue where i

相关标签:
3条回答
  • 2020-12-23 03:07

    I would suggest updating .nuget\nuget.exe with this command from the command line:

    nuget.exe update -self
    

    [EDIT] : Close VS Solution first. If there's an update and the solution is opened, nuget.exe will be removed from the solution.

    You could automatically update nuget.exe on restore by modifying the .nuget\nuget.targets to add the above command. I'd look at the restore command in there as an example. But I'm not sure if it's worth it, nuget.exe updates aren't that common, and backward compatibility should break very rarely.

    0 讨论(0)
  • 2020-12-23 03:17

    I've found the best way to handle this is by simply deleting the .nuget folder and re-enabling solution wide package restore. As said above, you could add a self update command to your build, but that will not update the targets or config files if there are changes between versions (or remove the reference from your solution). Perhaps its not that big of a deal, but this is the sure fire way to make sure you have the latest exe and configuration files. And at the end of the day, updating is only an issue if you need access to a new command or there is eventually a breaking change in a new release.

    0 讨论(0)
  • 2020-12-23 03:25

    See David Ebbo's post at his blog

    Basically, All you need to do is create a NuGet.Config file next to your .sln file, containing:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <packageSources>
        <clear/>
        <add key="nuget.org" value="https://www.nuget.org/api/v2/" />
        <add key="aspnetwebstacknightlyrelease" value="https://www.myget.org/f/aspnetwebstacknightlyrelease/" />
      </packageSources>
    </configuration>
    
    0 讨论(0)
提交回复
热议问题