Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify commit and branch in csproj for nuget package creation

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?

like image 567
Julian Avatar asked Jul 30 '19 20:07

Julian


People also ask

Should you commit NuGet packages?

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.

Should NuGet packages be in Source Control?

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.

How do I change the location of a NuGet package?

Open %AppData%\NuGet folder, open existing NuGet. Config file. Edit repositoryPath key and set new destination.


Video Answer


1 Answers

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.

like image 82
nelsontruran Avatar answered Oct 19 '22 11:10

nelsontruran