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>
MSBuildProjectDirectory is the property that will give you the full path to the project file which was invoked on the command line.
The “build. prop” file is a system file that contains build properties and settings. Some of the contents are specific to your device or your device's manufacturer, others vary by version of the operating system, but some are generic to all devices running the same version of Android as you are.
Directory. Build. props is a user-defined file that provides customizations to projects under a directory.
MSBuild lets you set properties on the command line by using the -property (or -p) switch. These global property values override property values that are set in the project file. This includes environment properties, but does not include reserved properties, which cannot be changed.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With