1

我有以下简单的脚本:

$workingDir = "C:\foo\bar"
$projectsDir = "C:\foo"

Copy-Item -Path "$projectsDir\some subpath\MyFile1.dll" -Destination $workingDir
Copy-Item -Path "$projectsDir\somewhere else\MyFile2.dll" -Destination $workingDir
Copy-Item -Path "$projectsDir\another place\MyFile3.dll" -Destination $workingDir

出于某种未知原因,每次我运行此脚本时,它都会将文件复制到正确的位置 ( $workingDir) ,并将它们复制到$projectsDir\some subpath\something\else. 每次运行此脚本时,我都必须从其他位置删除多余的文件。

到目前为止,我已经尝试过:

  1. 改变变量名
  2. 指定-Destination "$workingDir\MyFile1.dll"
  3. 使用$null = Copy-Item -Path "...."
  4. 我什至尝试Copy-Itemxcopy.exe

什么都没有改变。我在第一个 Copy-Item 命令上设置了一个断点并查看了变量——它们看起来都正确。这里发生了什么?

4

2 回答 2

0

我能想到的唯一另一件事是copy-item像这样运行:

Copy-Item -Path $($projectsDir + "\some subpath\MyFile1.dll") -Destination $workingDir

这就是我声明几乎所有 Variable + SomethingElse 场景的方式。由于我还没有看到这种行为,我会回去再测试一下,看看我能找到什么。如果我想出别的东西,我会重做我的答案。

于 2012-08-16T17:11:28.290 回答
0

我重新启动了我的电脑。问题解决了。

于 2012-08-16T17:12:13.693 回答