bevacqua
bevacqua

Reputation: 48566

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)

Upvotes: 17

Views: 18921

Answers (5)

Ali Bayat
Ali Bayat

Reputation: 4096

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.

Upvotes: 1

Sunil bisht
Sunil bisht

Reputation: 1

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

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

Upvotes: -1

sourcecode108
sourcecode108

Reputation: 131

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.

Upvotes: 13

Kiran Bheemarti
Kiran Bheemarti

Reputation: 1459

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

Upvotes: 3

joncham
joncham

Reputation: 1614

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

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

Upvotes: 34

Related Questions