'Automate Artifactory NuGet download during build in Visual Studio
I have been working with Artifactory NuGet packages in Visual Studio 2019 recently, and have a workflow which looks sort of like this:
- Add private Artifactory repo as NuGet Package Source
- Download specific older version of my NuGet package [either using Package Manager UI or Package Manager Console]
- Once NuGet package is installed, build VS2019 project
I need to eliminate the need for a user to know how to go through these steps, and make it as simple as possible for a Visual Studio 2019 project to automatically install a specific version of my private NuGet package hosted in artifactory.
I've been trying to accomplish this but with no luck, I'm not sure if this would best be done by editing the Visual Studio project file, or by editing the windows global nuget.config file, or create a custom nuget.config file for my visual studio project.
Any advice/help would be appreciated, thanks.
Solution 1:[1]
Since your question does not contain relevant information like if you're using a Visual Studio Solution (*.sln
file), Git, etc., I can only have a guess ?
Assuming you're using Git and having a folder structure like this:
- MyProject
- .git
- MyProject.sln
- ProjectA
- ProjectA.csproj
- ProjectB
- ProjectB.csproj
Now you can create a file MyProject/NuGet.config
with the following content and put it under version control:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="Your Artifactory source" value="https://your.artifactory.source/v3/index.json" />
</packageSources>
</configuration>
According to the docs, NuGet should pick up NuGet.config
automatically.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |