简体   繁体   中英

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)

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.

This is not working in VS2010 .. is not resolved but becomes part of the path

Studio is running command something like this copy drive$:\\a\\b\\bin\\debug drive$:\\a\\b..\\c

In .Net Core edit csproj file:

<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.

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

Note: "../" is used for One level up folder structure

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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