【问题标题】:Powershell script: Create file on TFS server using New-ItemPowershell 脚本:使用 New-Item 在 TFS 服务器上创建文件
【发布时间】:2018-09-13 01:32:22
【问题描述】:

可以使用此命令在本地服务器上创建文件。

$msbuild = "C:\Program Files (x86)\MSBuild\14.0\Bin\msbuild.exe"
$ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path
New-Item -Path $ScriptDir\NITI_20180402.223.txt -ItemType "file" -Value "This is a text string."

但是在 TFS 服务器上构建这个脚本时没有创建文件。

New-Item -Path $ScriptDir\NITI_20180402.223.txt -ItemType "file" -Value "This is a text string."

【问题讨论】:

  • 如何在构建脚本中定义变量?你的两个例子不匹配。
  • 修改问题
  • 您的 TFS 服务器的 powershell 版本是什么?试试New-Item ... -Verbose 4> Logfile.txt
  • New-Item -Path $ScriptDir\abc.txt -ItemType "file" -Value "这是一个文本字符串。" -详细 4 出现错误:找不到接受参数“4”的潜在参数
  • 您是否尝试过手动指定绝对路径而不是使用 $ScriptPath 变量?或者输出 $ScriptPath 的值,看看那里是否设置了奇怪的东西?

标签: powershell tfs


【解决方案1】:

我测试了我这边的脚本,一切正常。

你可以试试这个(添加-Force):

New-Item -Path $ScriptDir\NITI_20180402.223.txt -ItemType "file" -Value "This is a text string." -Force

如果仍然无法解决问题,请分享您的构建定义设置(最好是截屏)和日志以进行进一步的故障排除。

【讨论】:

  • @nitiparikh 你解决了这个问题吗?有更新吗?
猜你喜欢
  • 1970-01-01
  • 2017-12-16
  • 1970-01-01
  • 2014-08-17
  • 1970-01-01
  • 2012-07-24
  • 2014-02-02
  • 2014-12-22
  • 1970-01-01
相关资源
最近更新 更多