1

I am using Stamp.Fody nuget package to stamp my .Net assembly. It has Fody as dependent nuget package. Jenkin is our continuous integration server. In order to build .Net solution MSBuild command line call is used.

Upon running the msbuild command line following error is appearing.

"C:\Source\Demo.sln" (default target) (1) -> "C:\Source\Demo.UI.csproj" (default target) (2) -> C:\Source\Demo.UI.csproj(185,5): error : 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 ..\packages\Fody.1.25.0\build\Fody.targets.

When working with Visual Studio IDE, if either Fody or any other nuget packages are missing then the Visual Studio IDE's package manager itself restoring all the missed packages successfully.

Interestingly if I run MSBuild command line after removing NUnit, Prism and Fody nuget packages and clearing the Nuget package cache, other than Fody nuget package all other packages (NUnit and Prism) are successfully restored. But not Fody.

According to NuGet Package Restore does not fetch Build Target Assemblies (Tools) reference I understood there was a nuget download problem with all Fody nuget packages version prior to 1.13.0.0. Also as advised in that link I added Fody nuget package reference to all the projects in my solution and tried to build the solution but it is again complete build failure. (I have no previous versions installed so no need to remove anything from Tools/Fody folder - as mentioned in the readme.txt)

I have checked all other following known possible cases and end up with no success.

I don't know what I am missing here. Could anyone help me on this please?

Community
  • 1
  • 1
manu
  • 1,807
  • 4
  • 25
  • 32

2 Answers2

4

The recommended approach for nuget packages is to use the Automatic Package Restore before the build rather than during the build. When using with MSBuild, you can use the restore option (available in Nuget version 2.7 and above) before the actual build starts, which will download all the nuget packages that your solution uses.

More info can be found at package restore and in particular the section that says Command-Line Package Restore wrapped in MSBuild

This approach works not only for Jenkins based CI but also for TFS or any other CI servers. Author of the Fody package Simon recommends the same approach

Community
  • 1
  • 1
Jeyanth
  • 78
  • 3
  • Jeyanth, many thanks for your answer. I am more happy with your answer as I can just have to specify the .Net solution in order to download the entire packages in my application. So I can use the command referenced in your aforementioned link and place it in Jenkin as @Sean mentioned. Thanks for solving the problem in an very easier way. – manu Sep 18 '14 at 10:02
2

Depending on how your build job is structured in Jenkins, you could have a very simple batch executed during Build step(s). enter image description here

Batch file could be either something you'd share on your build server with all the jobs, or specific to the project. I tend to have one per project.

..\.nuget\NuGet.exe Install <your-package-to-restore> -OutputDirectory ..\packages
Sean Feldman
  • 23,443
  • 7
  • 55
  • 80