1
votes

I'm new to Azure Dev Ops and I'm trying to create a pipeline for my project. The project is originally in subversion and relies on a few custom downloadable libraries that my company maintains. I'm trying to add these custom dlls to the build process so the nuget restore command will be successful. The dlls are located in a "packages" repository in the source repo. How can I add these dlls to the build pipeline? Any help would be appreciated!

2

2 Answers

3
votes

How do I add a custom dll to an azure dev ops pipeline from a private repository?

There's several directions for your requirement. According to your description, these are dlls instead of nuget packages. Here're two ways I like:

1.If you're familiar with nuget, you can create nuget packages for those dlls. Then publish the nuget package to the Azure Devops nuget feed. After that you can use Nuget Restore Task easily to restore those packages:

enter image description here

Prerequisite: Your project should use nuget package way to manage the dlls, it means you need to edit the project's project file. Your project should reference the nuget packages in csproj instead of referencing the dlls directly using hintpath ...

Advantage: Nuget is common tool to manage dlls when you're working in .net core. And azure devops Feed supports private feed, so no one can access your feed until you grant access to them.

Disadvantage: You have to do some jobs about packing/publishing dlls and editing the project file (xx.xxproj).

2.If your team insists on using single dlls instead packing them into nuget packages, then you don't need to worry about nuget restore step. All you need to make sure is the build step can find the missing assemblies.

For example, in local machine my project relies on one assembly in windows desktop. Then its xx.csproj has:

    <Reference Include="ClassLibrary1">
      <HintPath>..\..\..\..\Desktop\ClassLibrary1.dll</HintPath>
    </Reference>

It's obvious that it would fail if I deploy it to Azure Devops, cause the pipeline won't find the same path. For this issue, my idea is to create an empty Dlls folder in project directory, add the folder into source control. Also, edit the HintPath in project file to be <HintPath>Dlls\ClassLibrary1.dll</HintPath>

Now in devops pipeline, I can add a git task or cmd task that runs git commands to download your assemblies from private repos. Then a command-line task to copy the assemblies to the Dlls folder under System.DefaultWorkingDirectory. Finally, the build process can also succeed.

I just shows two directions for your scenario, there actually exists other directions. Among them, I strongly recommend nuget packages+Azure Devops Feed way cause it's more convenient after configuring them well. Hope all above helps.

1
votes

If you are saying that your repository contains some dll's needed to build the app, you have an issue not with nuget restore. Nuget restore simply download linked nuget packages. And in your case you need to get dll's to build the app. You can use multi repo approach and get your subversion repo alongside with new one. Or you can use script step and there call directly svn command line to get just specific folders (and files needed for your build). Since both windows and ubuntu host agents have svn installed you are half way home. Please keep in mind that you need to get your dll's to proper folder so MSBuild can find them at build.

Another approach is to create nuget packages for those dll's and then keep them in Azure Feed. Then change references in your projects so they will be dependent on nuget package and not dll files directly.