在 Appveyor 脚本中写入一个文本文件

Write a text file in Appveyor script

我在用 appveyor 写一个简单的文本文件时遇到了问题。这是简单的脚本:

version: 1.0.{build}-{branch}

shallow_clone: true

environment:
  matrix:
    - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
      TOOLSET: msvc-14.1
      ARCH: x86_64

install:

build: off

test_script:
  - echo ^<Where are my symbols^> > hello.txt
  - more hello.txt

这会导致控制台出现错误:

Build started
Fetching repository commit (2be7d4b)...OK
Total: 274 bytes in 1 files
echo ^<Where are my symbols^> > hello.txt
Command exited with code 1      

我已经在桌面上尝试了这些命令,但一切正常。

此转义符号不会以这种方式工作,因为在内部我们从自定义 PowerShell 主机执行命令时在您的 cmd 之前使用 call

解决方法:

  • 使用 PowerShell

test_script: - ps: Set-Content -Value "<Where are my symbols>" -Path .\hello.txt - more hello.txt

  • 使用使用 ^ 转义符号和 运行 转义符号的命令签入 .cmd 文件。