0
votes

I have a solution that I'm moving to Azure Devops pipelines and am having trouble figuring out how to use a shared project. So here is the scenario. I have 3 projects Common.csproj, A.csproj and B.csproj. Common is used in both projects. A and B reference Common through a project reference in my solution.

<ItemGroup>
  <ProjectReference Include="..\Common\Common.csproj">
    <Project>{40838373-5284-4073-86e5-9bf4e1bfb855}</Project>
    <Name>Common</Name>
  </ProjectReference>
</ItemGroup>

I have moved the Common project to it's own git repo and have a build pipeline that publishes the build artifact dll at the end.

In my pipeline for project A I am trying to download that Common build artifact and reference it with msbuild, but haven't figured out how to do it yet. Is there a command line argument that will reference the assembly directly or am I thinking about this in the wrong way?

1

1 Answers

2
votes

Is there a command line argument that will reference the assembly directly or am I thinking about this in the wrong way?

I am afraid there is no such command line argument that will reference the assembly directly. That because we could not add reference during the building, Visual Studio/MSBuild is a pre-compilation mechanism, it get all the reference assembly path before building.

So, to resolve this issue, you should add the reference before you build your reference project A and B. You can build the solution with project reference instead of the project A,B with dll file.

Besides, if you still use Common project individually as dll file, you could try to use nuget.

Some steps:

  • Build the Common project, pack it to a nuget package and publish the nuget package to the Azure Devops Artifact.
  • Install the nuget package to the project A and B in your local with Visual Studio.
  • Use nuget restore task to restore nuget package when you build the project A and B with Azure Devops.

Check the document Get started with NuGet packages in Azure DevOps Services and TFS for some more details. Hope this helps.