16

我目前有

  <PropertyGroup>
    <PostBuildEvent>copy "$(TargetPath)" "$(SolutionDir)Shared.Lib\$(TargetFileName)"</PostBuildEvent>
  </PropertyGroup>

我想做这样的事情,但比上一层$(SolutionDir)

4

5 回答 5

31

您可以使用 ..\ 向上移动目录。

 <PropertyGroup>
    <PostBuildEvent>copy "$(TargetPath)" "$(SolutionDir)..\Shared.Lib\$(TargetFileName)"</PostBuildEvent>
  </PropertyGroup>
于 2011-06-21T00:20:10.940 回答
12

解决方案:

copy "$(TargetPath)" "$(SolutionDir)"..\"Shared.Lib\$(TargetFileName)"

如果你有..\引号,它将把它当作文字而不是运行 DOS 命令上一级。

于 2012-09-20T21:31:59.463 回答
3

这在 VS2010 中不起作用 .. 未解决但成为路径的一部分

Studio 正在运行类似以下命令的命令 copy drive$:\a\b\bin\debug drive$:\a\b..\c

于 2011-06-23T12:36:54.737 回答
1

在 .Net Core 中编辑 csproj 文件:

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
  <Exec Command="copy /Y &quot;$(TargetPath)&quot; &quot;$(SolutionDir)&quot;..\&quot;lib\$(TargetFileName)&quot;" />
</Target>

/Y禁止提示确认您要覆盖现有的目标文件。

于 2019-07-07T14:12:06.163 回答
-1

xcopy "$(TargerDir) . " "$(SolutionDir)..\Installer\bin\"

注意:“../”用于上一级文件夹结构

于 2016-05-31T09:09:05.403 回答