简体   繁体   English

VS Post Build Event,复制解决方案文件夹上一级?

[英]VS Post Build Event, copy one level above solution folder?

I currently have 我现在有

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

I want to do something like this, but one level above $(SolutionDir) 我想做这样的事情,但是高于$(SolutionDir)

You can use ..\\ to move up a directory. 您可以使用.. \\来上移目录。

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

Solution: 解:

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

If you have ..\\ within the quotation marks, it will take it as literal instead of running the DOS command up one level. 如果你在引号内有..\\ ,它将把它作为文字而不是在一级运行DOS命令。

This is not working in VS2010 .. is not resolved but becomes part of the path 这在VS2010中不起作用..未解决但成为路径的一部分

Studio is running command something like this copy drive$:\\a\\b\\bin\\debug drive$:\\a\\b..\\c Studio正在运行命令,如此复制驱动器$:\\ a \\ b \\ bin \\ debug drive $:\\ a \\ b .. \\ c

In .Net Core edit csproj file: 在.Net Core中编辑csproj文件:

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

/Y Suppresses prompting to confirm you want to overwrite an existing destination file. /Y禁止提示您确认是否要覆盖现有目标文件。

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

Note: "../" is used for One level up folder structure 注意:“../”用于一级文件夹结构

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM