I am working on a silverlight app. We are using nuget packages but we dont check in the packages and the packages should be restored while building. The solution compiles well in visual studio. I am trying to add a compile task in command line using msbuild
Exec { C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe $slnFile /p:OutputPath=$outputPath /p:Configuration=Release /p:SolutionDir=$rootDir\Source\ /verbosity:minimal /nologo /m:4 } "Build Failed
Before doing this step, I'm doing a nuget restore explicitly.
Exec { C:\project\nuget.exe restore $solutionFile} "restore failed"
This step passes with a message "All packages listed in packages.config" are already installed.
But when the actual build step happens the build fails with the message
This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is \Source\.nuget\NuGet.targets.
I am doing a nuget restore explicitly and I have enabled
"Allow nuget to download missing packages" in visual studio and "Enable nuget package restore" in solution level.
My nuget.config has "disableSourceControlIntegration" value="true"
I have seen similar issues in stackoverflow and I have tried all the above solutions that were suggested. I don't have a clue why it fails in spite of all these.
Currently there are no immediate plans to allow restore calls to happen from VS command line. Give your use case we would recommend using NuGet.exe for your restore (MSBuild works the same for Package Reference/ project.json scenarios, but it ignores package.config projects), and then triggering a build like you were doing before.
Run the msbuild -t:pack command. To build a NuGet package (a .nupkg file) from the project, run the msbuild -t:pack command, which also builds the project automatically: In the Developer command prompt for Visual Studio, type the following command: The output shows the path to the .nupkg file.
This project references NuGet package (s) that are missing on this computer. Use NuGet Package Restore to download them. The missing file is {name}. This error occurs when you attempt to build a project that contains references to one or more NuGet packages, but those packages are not presently installed on the computer or in the project.
This error occurs when you attempt to build a project that contains references to one or more NuGet packages, but those packages are not presently installed on the computer or in the project.
You do not need to do both the nuget.exe restore and have MSBuild use NuGet.targets to restore the NuGet packages. You should choose one or the other.
I suspect the problem in your case is that $rootDir is not defined and the SolutionDir property you are passing to MSBuild is:
\Source
In my project file I have:
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
So if SolutionDir is \Source then the solution will fail to compile with the same error message.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With