Wiki Navigation
- Loading...
Overview
Some preparations within a git repository are required to use NuGet properly. These information are targeted for developers setting up a repository.
Details
This guide describes how the MP2 repository has been set up for using NuGet. Improvement suggestions for the guide or the process itself are welcome.
Prepare the solution
Follow the NuGet documentation to enable the NuGet Package Restore for a solution file within your git repository.
This will create a.nuget
subdirectory including
NuGet.exe
,
NuGet.targets
and
NuGet.config
.
Remove the
NuGet.exe
and the
NuGet.config
directly from within VisualStudio and ensure the files are removed in Windows Explorer as well .
Open the
NuGet.targets
and change the property
DownloadNuGetExe
from
false
to
true
.
Default NuGet.targets (NuGet 2.5) at gist: original, modified, Diff
The solution is prepared now and can be saved and closed. Repeat these steps for all the other solution files in your repository.
Note: If you have multiple solutions within the same folder it is required to delete the .nuget folder in Windows Explorer before Package Restore can be enabled for the next solution.
One NuGet.config for the repository
The
NuGet.config
files which were created while Enabling Package Restore have been removed already if you followed the previous steps correctly. For setting all public available configuration properties for the whole repository only once, a
NuGet.config
will be created at the repository root. This is being used by all solution files within this repository, if these do not re-set it.
For more information about the lookup chain of
nuget.config
see NuGet documentation. There you also can find a NuGet config specification.
The sample NuGet.config is used by MediaPortal 2.
Committing the changes of the preparation
Now almost everything should be set up for using NuGet within your repository.
Finally ensure you added the
Packages
directory and
*.exe
files or
NuGet.exe
to your
.gitignore
.
And now: Commit !
Not required content - ignore this for now
References within project files
This descirbes and issue of NuGet. For latest infos or whether it has been fixed see NuGet documentation. TODO: ADD LINK
After adding or updating packages within for a project, NuGet sets the path relative to the project file.
<Reference Include="CommandLine"> <HintPath>..\..\packages\CommandLineParser.1.9.71\lib\net40\CommandLine.dll</HintPath> </Reference>
If the project is being used within a solution, which is using a different directory for packages (i.e. usage as a submodule or re-set the global package dir on solution level), the assembly reference might not be found anymore.
To fix this problem the project files needs to be modified manually like the the following example.
<Reference Include="CommandLine"> <HintPath>$(PackagesDir)\CommandLineParser.1.9.71\lib\net40\CommandLine.dll</HintPath> </Reference>
This page has no comments.