Search code examples
c#.netgitnugetmyget

Pulling in nuget dependencies on build


I am using myget build services with a github web hook to build my nuget packages on every push to github.

The github repo is at project level so the packages folder (which is at sln level) does not get pushed.

So my build fails because it doesnt have the dependencies. What is best practise here? I would like to pull in the dependencies with nuget during build. Is this possible with myget and if so how could i set it up. I have looked at package restore but that also creates config at sln level so i dont think it can help me.


Solution

  • You can hook into the MyGet Build Services using your own build script, as explained in the documentation: http://docs.myget.org/docs/reference/build-services

    You can then make use of NuGet to restore the packages yourself: http://docs.myget.org/docs/how-to/make-use-of-nuget-within-your-build-scripts

    The real problem is the fact that your project is referencing libraries which are outside of your source repository root. I'd suggest you respect the default convention of having the following directory structure in your repository:

    $(SolutionDir) = repository root
        \ProjectDir
    

    You can either include a project specific solution in the solution directory (and have the project in its own sub-directory), or you use a build script in the solution directory that restores the packages in the $(SolutionDir)\Packages folder (you can create it on the fly as long as it is inside the checkout directory, and call nuget.exe install on your packages.config).