When does MSBuild set the $(ProjectName) property?

前端 未结 1 892
无人共我
无人共我 2020-12-16 14:37

I\'m fairly new to MSBuild, and I\'ve done some customization on a WPF project file that I\'m building both in Visual Studio 2010 and TFS 2010. I\'ve customiz

相关标签:
1条回答
  • 2020-12-16 15:23

    Hmm - bit of confusion going on there which I'll try to sort out

    1. Don't use $(ProjectDir) - use $(MSBuildProjectDir) - that's the location of your csproj in the source tree and is set by MSBuild.exe as a reserved property. I don't think $(ProjectDir) is available until after Microsoft.Common.Targets has been imported (which is done by Microsoft.Csharp.targets). Property evaluation is always carried out "in-place" within the file, and not when all the Imports have completed. This may explain why you are seeing the property as valid in the SideKick tool

    2. Likewise use $(MSBuildProjectName) (which I think will address your problem)

    3. I'm unsure about VS2010 and TFS2010 (as that uses MSBuild 4.0 and no doubt a new TeamBuild), but in 2008, it's pretty hard within a .csproj to figure out if your build was called from a command line/IDE build or from within TeamBuild. What I'm trying to say is that I don't think $(TeamBuildOutDir) is available within your csproj. I normally test $(TeamBuildConstants) property, as that property is passed down when teambuild calls your proj file. YMMV as I haven't played with 2010 yet..

    0 讨论(0)
提交回复
热议问题