hi,
I'm writing an msbuild .targets file, and in it I want to use the zip task to zip up some files that I know the locations of relative to the .targets file.
This works ok when I execute the .target file directly. But, when I include the .targets file in an .proj file that's in another directory, the relative paths are resolved relative to the .proj file and not to the .targets file.
Is there a way I can specify relative paths that are relative to the file I've written them in?
I've seen this related question:
http://stackoverflow.com/questions/2099542/how-to-give-relative-path-in-msbuild-file
A workaround I've thought of is to do the following. I haven't tried it yet. Will it work, is there a better way?
my.proj
<Import Project="..\Somewhere\my.targets"/>
<PropertyGroup>
<MyTargetsYouAreHere>$(MSBuildProjectDirectory)\..\Somewhere</MyTargetsYouAreHere>
</PropertyGroup>
my.targets
<Message Text="my.targets is here '$(MyTargetsYouAreHere)'" />