I am trying to update the nuget references of some projects from the command line. These projects use the new format which include PackageReference elements. The command I am using is:
nuget.exe update someproj.csproj
This results in an error:
The default XML namespace of the project must be the MSBuild XML namespace. If the project is authored in the MSBuild 2003 format, please add xmlns="http://schemas.microsoft.com/developer/msbuild/2003" to the element. If the project has been authored in the old 1.0 or 1.2 format, please convert it to MSBuild 2003 format.
Is there some way to use nuget.exe or dotnet.exe to update packages from the command line?
You will need version >= 4 of nuget.exe to work with the new csproj format.
However you will still need to use the old style packages.config
or you will get the following output
C:\dev>nuget.exe update test.csproj
MSBuild auto-detection: using msbuild version '15.1.548.43366' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\bin'.
Unable to update. The project does not contain a packages.config file.
However you might be able to use the powershell commandlets
Update-Package
These can be run from the package manager console (https://learn.microsoft.com/en-us/nuget/tools/package-manager-console).
You can also just load in the powershell module and execute the following
Import-Module PackageManagement.Cmdlets.dll
Set-Project MySolution "MySolution.sln"
Update-Package
more information on this can be found on this blog - http://community.sharpdevelop.net/blogs/mattward/archive/2011/06/12/InstallingNuGetPackagesOutsideVisualStudio.aspx