c# - msbuild/csproj 执行任务问题

标签 c# msbuild

我在使用 msbuild 构建服务器 (2003) 时遇到问题。我已将问题缩小到 csproj 文件中的 exec 任务,我已将其提取到一个非常简单的 csproj(如下)中,但仍然没有任何乐趣,请参阅“C:\Documents”错误。这一切在我的本地机器上都没有问题。

我认为环境变量存在一些问题,但我想不通。有什么建议吗?

输入


<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <Target Name="BeforeBuild">
   <Exec Command="echo hello world" />
  </Target>

</Project>

MSBuild 输出

 D:\cc.net working\source\WebBase>msbuild ExecIssue.csproj
Microsoft (R) Build Engine Version 4.0.30319.1
[Microsoft .NET Framework, Version 4.0.30319.1]
Copyright (C) Microsoft Corporation 2007. All rights reserved.

Build started 11/10/2010 12:37:50.
Project "D:\cc.net working\source\WebBase\ExecIssue.csproj" on node 1 (default t
argets).
BeforeBuild:
  echo hello world



'C:\Documents' is not recognized as an internal or external command,
  operable program or batch file.



D:\cc.net working\source\WebBase\ExecIssue.csproj(5,4): error MSB3073: The comma
nd "echo hello world" exited with code 1.
Done Building Project "D:\cc.net working\source\WebBase\ExecIssue.csproj" (defau
lt targets) -- FAILED.


Build FAILED.

"D:\cc.net working\source\WebBase\ExecIssue.csproj" (default target) (1) ->
(BeforeBuild target) ->
  D:\cc.net working\source\WebBase\ExecIssue.csproj(5,4): error MSB3073: The com
mand "echo hello world" exited with code 1.

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.17

最佳答案

我会在诊断模式下运行它并将其发送到一个文件,然后在该文件中搜索 C:\Documents。也许它在某些路径参数中使用了“C:\Documents and settings\”而没有引用它。诊断模式将打印出大部分(如果不是全部)正在使用的属性、项目组、环境变量等。希望它将打印出 exec 任务正在使用的所有属性,因为您只提供命令参数,它正在为其余部分使用一些默认值。

msbuild ExecIssue.csproj /v:Diagnostic > buildout.txt

关于c# - msbuild/csproj 执行任务问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3905835/

相关文章:

msbuild - 如何从命令行为智能设备 cab 项目创建 inf 文件?

visual-studio - MSBuild 继承平台工具集

c# - 无法编写表达式函数成员

c# - 应用程序主窗口,它的主要用途是什么?

c# - 结合 join 和 group by 时,EF Core 3.1 意外生成 SQL

msbuild - 开源 msbuild 任务

MSBuild - 在不修改单个项目的情况下执行自定义目标

c++ - MSBuild ProjectReference 项文档

c# - 'Gravity' 不包含 'CENTER_HORIZONTAL' 的定义

c# - 如何获得包含定义数量的空格的字符串?