I am having a weird issue with nuget.exe command line tool.
I have a console application that launches a process which executes nuget command line tool.
Here is the output:
nuget.exe pack Project.csproj -Prop Configuration=Release
Attempting to build package from 'Project.csproj'. Packing files from
'C:\Project\bin\Release'.
It throws an Object reference not set to an instance of an object. exception.
But the way, my process WorkingDirectory is C:\Project, so the file path is ok.
What is weird is that when I use the standard windows command line, cd into the .csproj folder and execute the same command, the nupkg file is being created.
If I do:
cd ..
and runs:
nuget.exe pack Project\Project.csproj -Prop Configuration=Release
I am getting the Object reference not set to an instance of an object. exception.
My console application code is:
var process = new Process {
StartInfo = new ProcessStartInfo("nuget.exe",
"pack Project.csproj -Prop Configuration=Release")
{
WorkingDirectory = "C:\\Project",
UseShellExecute = false,
RedirectStandardInput = true,
}
};
I had the same issue and my problem was that after an update of an package (and a merge in SVN), the packages.config file still had both versions of the package referenced: the old and the new package. After I deleted the folder with the old package, the “Object reference not set to an instance of an object.”-error popped up.
So, to solve that error, be sure that your packages.config file only has one version of a package in it.