Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nuget Package restore with git submodule

Tags:

git

package

nuget

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

like image 361
Sascha Herrmann Avatar asked Sep 04 '13 08:09

Sascha Herrmann


3 Answers

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 :

   <ItemGroup>
    <Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
      <HintPath>..\packages\Microsoft.Rest.ClientRuntime.2.1.0\lib\net45\Microsoft.Rest.ClientRuntime.dll</HintPath>
      <Private>True</Private>
    </Reference>

to :

 <ItemGroup>
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <HintPath>$(SolutionDir)\packages\Microsoft.Rest.ClientRuntime.2.1.0\lib\net45\Microsoft.Rest.ClientRuntime.dll</HintPath>
  <Private>True</Private>
</Reference>

Hope this help!

like image 57
Srounsroun Avatar answered Nov 20 '22 14:11

Srounsroun


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

like image 41
Sascha Herrmann Avatar answered Nov 20 '22 12:11

Sascha Herrmann


you can use symbolic link: After nuget downloads all packages to solution's packages directory, create symbolic link in submodule's root directory (names packages and link to the solution level packages directory). In short - in your startup project add Pre-Build event that creates symbolic link between your solution packages directory to all your submodules packages directory:

This is the batch:

SET sourceDir=$(SolutionDir)packages
SET destDir=$(SolutionDir)..\..\submodules\saturn72\src\packages

if not exist %sourceDir% mkdir %sourceDir%

if not exist %destDir% mklink /j %destDir% %sourceDir%

Full explanation and source code: SolutionWithGitSubmodulesAndNuget

like image 5
Roi Shabtai Avatar answered Nov 20 '22 14:11

Roi Shabtai