If I have a project structure like this:
\MySolution
\MyProject
ReadMe.md
\build
MyProject.targets
What would the value of $(MSBuildThisFileDirectory)
be when used in the MyProject.targets
file?
Assuming my solution folder is in the root of C: drive, would it be?..
c:\MySolution\MyProject\build\
In the MyProject.targets
file, how would I reference the ReadMe.md
file using the $(MSBuildThisFileDirectory)
?
Additional information:
MyProject.targets looks like:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)\xxx\ReadMe.md">
<Link>FrameworkTests.feature</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CustomToolNamespace></CustomToolNamespace>
</None>
</ItemGroup>
</Project>
What is the value of MSBuildThisFileDirectory?
It depends on your MyProject.targets
. According to the literal meaning of this variable, you could to know ThisFileDirectory
means "This File Directory".
Since you have use this argument in the file MyProject.targets
, the path should be related to the location of the "this file" MyProject.targets
. So the value of this argument should be the directory of this file MyProject.targets
.
After install the nuget, the file MyProject.targets
should be added to the path:
c:\MySolution\packages\MyProject.1.0.0<YouPackagefolder>\build
You can use a target to output that value in your project file, to accomplish this, unload your project. Then at the very end of the project, just before the end-tag </project>
, place below scripts:
<Target Name="TestValue" AfterTargets="build">
<Message Text="@(none)">
</Message>
</Target>