Instead, you should use Directory.Build.targets
.
Your operation is to overwrite the some items on MSBuild and that is the .targets
file's function. It is imported at the bottom of the csproj
file so that it can overwrite the items.(msbuild reads from the top to the bottom and take the last XML node as the final value).
But .props
file is imported at the top of the csproj
file and it is used as to define some new global properties. Since it imported at the top, it cannot be used as overwriting value operation and it is always overridden by properties under the main body of the csproj file.
Besides, you can this official document to get the usage of the two files.
Since your item remove
is overwriting operations, you should change the file into Directory.Build.targets
.
Note: the two files are embedded into the main csproj file during build. So all the msbuild properties, items,.... can be used under the two files.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…