1

I'm trying to write a custom project (targets?) file that is to be included in several projects.

For example, inside all of my .csproj and .vbproj files I have:

<Import Project="..\MyCustomTargets\custom.targets"/>

Inside that file I have a custom target (AfterBuild) which copies the compiled files to another location.

However, I'd like to add a reference path that each project can look to when trying to resolve references. Is this possible?

For example, I'd like to add something like this to my .targets file:

<AdditionalReferencePath>C:\LookHereForReferences</AdditionalReferencePath>

I've found a few links that describe a little about how to do this but I can't get it working.

SofaKng
  • 1,063
  • 1
  • 11
  • 32
  • any update for this issue? Could you get useful information from the answer? If not, could you please let us to know the latest information about this question? Thanks. – Leo Liu Apr 12 '17 at 08:58

1 Answers1

1

I'd like to add a reference path that each project can look to when trying to resolve references. Is this possible?

You can set a Property Group in your .targets file:

<PropertyGroup>
  <AdditionalReferencePath>C:\LookHereForReferences</AdditionalReferencePath>
</PropertyGroup>

After import this targets file in to the project file, you can look it by $(AdditionalReferencePath) when trying to resolve references:

  <Import Project="Common.targets" />
  <Target Name="Test" AfterTargets="Build">
    <Message Text="$(AdditionalReferencePath)"></Message>
  </Target>

enter image description here

Leo Liu
  • 71,098
  • 10
  • 114
  • 135