Reputation: 6643
I have a simple class library project (with Class1
) and have enabled NuGet Package Restore for the solution.
That imports the restorepackages
task into the .csproj file.
I can compile the project with
C:>msbuild myproj.csproj /t:compile
And I can call the restorepackages task successfully before adding packages with
C:>msbuild myproj.csproj /t:restorepackages
However, adding any package will cause the restorepackages task to fail with an error 3.
It seems that the NuGet task is called with a wrong working directory, and you may actually fix the behavior by removing the workingdir attribut in the NuGet.targets file, that was added to the solution.
Edit the task like this:
<Exec Command="$(RestoreCommand)"
LogStandardErrorAsError="true"
Condition="Exists('$(PackagesConfig)')"
WorkingDirectory="$(NuGetToolsPath)" />
and remove the working dir:
<Exec Command="$(RestoreCommand)" LogStandardErrorAsError="true" Condition="Exists('$(PackagesConfig)')" />
It seems to work as expected both from commandline msbuild and within VS2010.
Does anyone know if this change might break any tooling?
Upvotes: 3
Views: 6073
Reputation: 2138
Can it be related to the issue "Package Restore's $(SolutionDir) goes too far"?
Did you check the injected SolutionDir
property in your project file? It might be that the generated relative path won't point to the actual solution dir.
Upvotes: 1