0

我在 Visual Studio 中有一个自定义项目类型,具有以下内容:

 <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
    <TestNode>$(Configuration)</TestNode>

当我打电话时:

msbuild mysolution.sln /p:Configuration=Release

属性组被正确调用,但 TestNode 不包含“Released”而是“$(Configuration)”......有什么想法吗?

4

2 回答 2

0

'Works for me'

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
    <SomeData>$(Configuration)</SomeData>
  </PropertyGroup>

  <Target Name="Bobby">
    <Message Text="Value of SomeData is: $(SomeData)" />
  </Target>
</Project>

Then running

C:\Users\mvine\Desktop>msbuild Test.fooproj /p:Configuration=Release /t:Bobby
Microsoft (R) Build Engine version 4.0.30319.17929
[Microsoft .NET Framework, version 4.0.30319.18033]
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 24/05/2013 10:06:14.
Project "C:\Users\mvine\Desktop\Test.fooproj" on node 1 (Bobby target(s)).
Bobby:
  Value of SomeData is: Release
Done Building Project "C:\Users\mvine\Desktop\Test.fooproj" (Bobby target(s)).


Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.03

Maybe this answer will help you get your syntax right, if not add a self contained repro (and reply to this answer do I'll get the notification) and I'll take a look.

于 2013-05-24T09:12:20.460 回答
0

尝试用引用它的引号将属性括起来:"$(Configuration)"

    <Target Name="Target1">
    <PropertyGroup>
        <Configuration>release</Configuration>
    </PropertyGroup>
    <Message Text="this is a test $(Configuration)" Importance="high" />
</Target>

输出:这是一个测试版本

于 2013-05-24T00:00:55.473 回答