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

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.


You can use ..\ to move up a directory.

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

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.


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