0

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?

Dennis
  • 693
  • 1
  • 6
  • 16

1 Answers1

2

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.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • 2
    I thought that might end up being the answer. I'll try the nuget approach. I was just hoping that there was a way to do it because I'd rather deal with project references than nuget packages to ease development, especially when the nuget package will continue to change – Dennis Jan 29 '19 at 13:36
  • I could understand your expectations. But limited to the mechanism of the VS building, we could not to add references during building. It seems that there is still a long way to achieve your expectations. Besides, when the nuget package will continue to change, we would like use the project reference. Check my [another thread](https://stackoverflow.com/questions/48525562/project-reference-vs-nuget/48533648#48533648) for some more details. Hope this helps. – Leo Liu Jan 30 '19 at 02:16