So currently you could configure the branch and commit a .nuspec (see reference):
<repository type="git"
url="https://github.com/NuGet/NuGet.Client.git"
branch="dev"
commit="e1c65e4524cd70ee6e22abe33e6cb6ec73938cb3" />
But how could we configure that from the SDK-style .csproj files? Currently I have the type and url:
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/NLog/NLog.git</RepositoryUrl>
and I can't find the correct elements or attributes for "branch" and "commit". It's also not on this page: MSDN - Additions to the csproj format for .NET Core.
So how could I configure the branch and commit when creating nuget packages from a sdk-style csproj?
NuGet now has the ability for you to re-download the missing packages as a pre-build step, meaning that you only need to commit your packages. config file (and include nuget.exe in a tools folder). Read Using NuGet Without Committing Packages to Source Control for more details.
Developers typically omit NuGet packages from their source control repositories and rely instead on package restore to reinstall a project's dependencies before a build.
Open %AppData%\NuGet folder, open existing NuGet. Config file. Edit repositoryPath key and set new destination.
The properties you're looking for are as follows:
<RepositoryUrl>https://github.com/your/repository.git</RepositoryUrl>
<RepositoryBranch>release2.2</RepositoryBranch> <!-- optional branch reference -->
<RepositoryCommit>24ca19c71e8a84eeb8b9d3f95faa4b244db4341b</RepositoryCommit> <!-- optional commit reference -->
Note that these are simply added to the package metadata and you will still only build whatever you have locally.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With