MSBuild无法识别/理解属性

时间:2011-11-19 14:37:34

标签: .net msbuild properties teamcity

我创建了以下简单的msbuild项目文件,但输出很奇怪(请参阅消息标记结果)。

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Upload" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <DirectoryToUpload>Directory\</DirectoryToUpload>
    <RemoteServer>my.remote.server.com</RemoteServer>
  </PropertyGroup>
  <Target Name="Upload">
    <Message Text="Uploading from directory ${DirectoryToUpload} to server ${RemoteServer}" />
  </Target>
</Project>

输出。

D:\Project\Source>C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe ftpupload.proj /target:Upload
Microsoft (R) Build Engine Version 4.0.30319.1
[Microsoft .NET Framework, Version 4.0.30319.239]
Copyright (C) Microsoft Corporation 2007. All rights reserved.

Build started 11/19/2011 4:22:28 PM.
Project "D:\Project\Source\ftpupload.proj" on node 1 (Upload target(s)).
Upload:
  Uploading from directory ${DirectoryToUpload} to server ${RemoteServer}
Done Building Project "D:\Project\Source\ftpupload.proj" (Upload target(s)).

为什么MSbuild显示属性名称,但不是它的值?

P.S。整个过程都在TeamCity下运行,但启动msbuild.exe没什么区别,结果总是一样。

1 个答案:

答案 0 :(得分:4)

该属性语法不正确。正确的语法应该是括号:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Upload" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <DirectoryToUpload>Directory\</DirectoryToUpload>
    <RemoteServer>my.remote.server.com</RemoteServer>
  </PropertyGroup>
  <Target Name="Upload">
    <Message Text="Uploading from directory $(DirectoryToUpload) to server $(RemoteServer)" />
  </Target>
</Project>