Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Often, new team members must hunt down DLLs to get projects to run locally. To avoid this endless hunt, we can create NuGet packages and upload them to a feed that we control so that developers can simply “clone and run” any project.

Going forward, whenever DLLs need to be found, shared, or linked to a network share, every effort should be made to add the DLL to the Azure Artifacts Feed.

Any DLL that is not already retrieved from http://nuget.org is eligible to be added to our NuGet feed. However, if the exact version already exists in NuGet, we prefer to use that over adding it to our feed. Please check NuGet first before adding a dependency to Azure Artifacts.

In the case where an exact match isn’t found, you may be able to upgrade the minor revision without any negative side effect. These changes would need to be tested.

This article covers:

  1. What the prerequisites are.

  2. How to set up your environment.

  3. How to create a NuGet package for uploading to our private NuGet feed.

  4. How to upload your external dependencies to a NuGet feed.

  5. How to create a project-related nuget.config file to use your feed.

Prerequisites

These are things you will only need to set up once. Once you have things working, you won’t need to repeat this part. Here is what you need to get started:

  1. NuGet.exe

  2. The credential provider

  3. A generic .nuspec file

  4. The default nuget.config

  5. A working folder on your system, with an artifacts subfolder. I use C:\Work\ProjectReference\.

Download NuGet.exe. These instructions were obtained from the “Connect to Feed” button in Azure DevOps, under “Artifacts”.

Download NuGet.exe

Download and install the credential provider

Download the Generic.nuspec file:

Download the nuget.config file:

For more in-depth information, refer to the respective websites above. When running the nuget.exe commands, it must be installed somewhere in your PATH, or you must fully-qualify the location of the executable. For the credential provider, you will need to manually install it into the appropriate folder or run the PowerShell script to do so automatically. Refer to the “Installation on Windows” section.

Set Up Your Environment

  1. Download and install NuGet.exe and the credential provider according to their instructions.

    1. Download and install the credential provider

    2. Download NuGet.exe

      1. I have placed my nuget.exe file inside C:\Work\bin and I have added that folder to my PATH.

        1. Instructions on how to add folder location to PATH.

  2. Place the downloaded Generic.nuspec and nuget.config in your Work folder. I have chosen C:\Work\ProjectReferences to be my work folder. In it, I have an artifacts folder.

Create a NuGet Package for Uploading to Our Private NuGet Feed

  1. Gather information about the DLL. You will need the file name, a brief description, the company name, the version number of the DLL and version of .NET your application is using (usually .NET 4.7.1).

    The version as well as other information about the DLL can be found in the project file and in the DLL itself. First, unload the .vbproj or .csproj file in Visual Studio.


    Then click on the unloaded project and it will open in the editor. Find the DLLs that do not load.


    Locate the missing DLL file to obtain its information. The missing DLLs can sometimes be found in the dev, acc, or prod deployment folder, under the bin folder. These folders are usually indicated on the Applications page.

    Right-click and open the Properties of the DLL file to obtain its information.

  2. Modify the Generic .nuspec file you downloaded from the prerequisites section above to suit the DLL file you are creating this package for, using the information gathered in step 1, entering the:
    1. Filename (without .dll)
    2. Version number
    3. Company name (or copyright information)
    4. Description
    5. The version of .NET your application is using

  3. Save the nuspec file using the same name as the DLL file, with the .nuspec extension instead, in your artifacts folder. For example: AjaxControlTookit.nuspec.

  4. Place your dependencies inside a lib folder.

  5. From your artifacts folder, run the following command:
    nuget pack


    Your nuget package is now ready for uploading.

Upload Your External Dependencies to Our Azure Artifacts

  1. With your directory structure set up according to the above instructions, all that’s left to do is run the following command from within the artifacts folder.

    nuget push -Source DSD-CIVAV-Support-Feed -ApiKey az .\AjaxControlToolkit.3.5.40412.nupkg


    You will be prompted to log into Azure DevOps including approving the 2FA request, if applicable.

Create a Project-Related Nuget file

For projects to use the Azure Artifacts feed, you must include the following nuget.config file in the root of your project.

Troubleshooting Notes

Credentials Pop-Up

If you are not being prompted to enter your credentials for Azure DevOps, you may need to add the following path to your PATH environment variable.

C:\Users\khourip\.nuget\plugins\netcore\CredentialProvider.Microsoft substituting your user folder name.

NuGet Errors in Visual Studio

An error we encountered is when cloning a project with spaces. NuGet does not like this. Consider remove or replacing the %20 with a - (hyphen) in your folder name.

Helpful Links

NuGet CLI push command | Microsoft Docs

Create a NuGet package using nuget.exe CLI | Microsoft Docs

NuGet Gallery | Downloads

GitHub - microsoft/artifacts-credprovider: The Azure Artifacts Credential Provider enables dotnet, NuGet.exe, and MSBuild to interactively acquire credentials for Azure Artifacts feeds.

DSD-CIVAV-Support-Feed - Azure Artifacts

  • No labels