i have a project where i include 2 submodules from git. Both projects have "nuget package restore" enabled, the parent project too. The package folder in the two included submodules is not checked in, does not exist in checked out projects. When building the parent project Nuget tries to restore the packages in the subfolders but into the wrong package folder!
"C:\Dev\git\oasisdb\odb_oasis_repository\ODB_OASIS_Repository\.nuget\NuGet.exe" install "C:\Dev\git\oasisdb\odb_oasis_repository\odb_oasis_rvm\ODB_OASIS_RVM_EF\ODB_OASIS_RVM_EF\packages.config" -source "" -NonInteractive -RequireConsent -solutionDir "C:\Dev\git\oasisdb\odb_oasis_repository\ODB_OASIS_Repository\ "
Why does nuget not restore in the solution dir of the submodule?
Thanks
Found the answers: For anyone interrested:
http://www.xavierdecoster.com/how-to-nuget-package-restore-when-sharing-projects-between-solutions
and
NuGet not getting missing packages
you can use symbolic link: After nuget downloads all packages to solution's
packages
directory, create symbolic link in submodule's root directory (namespackages
and link to the solution levelpackages
directory). In short - in your startup project add Pre-Build event that creates symbolic link between your solutionpackages
directory to all your submodulespackages
directory:This is the batch:
Full explanation here: Visual Studio Solution with Nuget git submodules
Source code is here: SolutionWithGitSubmodulesAndNuget
If you're using VS2015 Update 1 or later, you can convert your project to use
project.json
to fix this.In short:
Uninstall-Package <package name> -Force -RemoveDependencies
for all your packages. You may wanna copy-paste yourpackages.config
in notepad before you do this.packages.config
from the project, save the project, unload.props
files at the top related to nuget<Reference>
elements that reference a package.targets
files at the bottom that reference nuget - usually starts with:<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
Add
project.json
with:Finally add your packages again, either by hand under
dependencies
or usingInstall-Package
or with the nuget UI in VS.I've also had to remove any
Microsoft.Bcl.*
packages from my projects because they explicitly look for apackages.config
file.EDIT: this (removing the
Microsoft.Bcl.*
packages will give you a compile-time error, even though the project will build fine, because the.targets
fileMicrosoft.Bcl.Build
adds will still look forpackages.config
.To suppress this, edit your project file and add:
This needs to go to the first
<PropertyGroup>
that doesn't have aCondition
attribute set. If there isn't one, just add another at the top, like:Nuget is restoring the package in the opened solution directory.
You can edit the .csproj of the submodule project and modify package dll references from :
to :
Hope this help!