code_junkie

MSBuild Find MSBuildProjectDirectory Parent Directory

Nov 14th, 2011
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. trunk/MainSolution.sln
  2. trunk/Build/MyBuild.Proj
  3. trunk/Library/...
  4. trunk/etc...
  5.  
  6. <RootFolder>$(MSBuildProjectDirectory)..</RootFolder>
  7.  
  8. C:ProjectsMyProjectTrunkBuild..CodeAnalysismyfile.xml
  9.  
  10. <Target Name="GetMSBuildProjectParentDirectory">
  11. <!-- First you create the MSBuildProject Parent directory Item -->
  12. <CreateItem Include="$(MSBuildProjectDirectory)..">
  13. <Output ItemName="MSBuildProjectParentDirectory" TaskParameter="Include"/>
  14. </CreateItem>
  15.  
  16. <!-- You can now retrieve its fullpath using Fullpath metadata -->
  17. <Message Text="%(MSBuildParentDirectory.Fullpath)"/>
  18.  
  19. <!-- Create a property based on parent fullpath-->
  20. <CreateProperty Value="%(MSBuildParentDirectory.Fullpath)">
  21. <Output PropertyName="CodeFolder" TaskParameter="Value"/>
  22. </CreateProperty>
  23. </Target>
Add Comment
Please, Sign In to add comment