Reputation: 118
I create a new Net Standard library, and I would like to publish the package to a local nuget repository.
In order to achieve it, I have two ways: using the command line, or using the publish option offered by Visual Studio.
Using the command line I use the "add" keyword from the command line (due to the fact it is a non-http package source), and it works fine, it create the nuget package with its nuget.sha512 file.
Using the publish option offered by Visual Studio, I've not been able to replicate the previous behavior, because it replicate the "push" keyword in the command line.
In the same local repository I can't hold two different packages, one with .nupkg.sha512 file and the other without it, because the nuget package manager will find only these packages without the ".nupkg.sha512" extension.
Is there any way I could tell to Visual Studio to replicate the "add" behavior using the publish option?
Thanks in advance.
Upvotes: 0
Views: 299
Reputation: 76986
Is there any way I could tell to Visual Studio to replicate the "add" behavior using the publish option?
I am afraid there is no such directly way that you could tell to Visual Studio to replicate the "add" behavior using the publish option, because the add command is only supported by NuGet CLI. We could not use it directly with publish option.
As workaround, you can add custom target to call NuGet CLI when you publish your project.
To accomplish this, edit your project. Then at the very end of the project, just before the end-tag </project>
, place below scripts:
<Target Name="AddPackage" AfterTargets="GenerateNuspec">
<Message Text="Add Package to the local nuget repository!"></Message>
<Exec Command="<PathOfNuGetCli>\nuget.exe add "<PathOfPackage>\xxx.1.0.0.nupkg" -source "<localNuGetRepository>""></Exec>
</Target>
Note: Since this custom target depends on the target GenerateNuspec
, it will be executed twice, but not worry about it, it will not have any actual operation when it is executed in the first time(The package has not yet been published to the specify folder).
Hope this helps.
Upvotes: 1