B
B
Boris the Animal2017-04-17 10:50:10
linux
Boris the Animal, 2017-04-17 10:50:10

How to substitute different commands in PostBuildEvents depending on the configuration of the solution?

How can I make PostBuildEvents to substitute the Windows command for the Debug configuration, and substitute the Linux command for the Linux configuration?
I just need to copy the output file to a shared directory for all projects in the solution.
On Windows I copy like this: xcopy "$(TargetPath)" "$(SolutionDir)bin\$(ConfigurationName)\$(SolutionName)\" /Y
I tried in the project file (*.csproj) to replace this:

<PropertyGroup>
    <PostBuildEvent>xcopy "$(TargetPath)" "$(SolutionDir)bin\$(ConfigurationName)\$(SolutionName)\"  /Y</PostBuildEvent>
  </PropertyGroup>

On this:
<Choose>
    <When Condition="'$(Configuration)'!='Linux'">
      <PropertyGroup>
        <PostBuildEvent>xcopy "$(TargetPath)" "$(SolutionDir)bin\$(ConfigurationName)\$(SolutionName)\"  /Y</PostBuildEvent>
      </PropertyGroup>
      <PropertyGroup>
        <PreBuildEvent>
        </PreBuildEvent>
      </PropertyGroup>
    </When>
    <Otherwise>
      <PropertyGroup>
        <PostBuildEvent></PostBuildEvent>
      </PropertyGroup>
    </Otherwise>
  </Choose>

But this doesn't work in MonoDevelop, because when building the project, MonoDevelop throws an error:
/usr/lib/mono/4.5/Microsoft.Common.targets: Error: Command 'xcopy "/home/MyName/Repos/SomeProject/OutdoorComponents/Config/ bin/Release//Config.dll" "/home/MyName/Repos/SomeProject/bin/Release/SomeServer/" /Y' exited with code: 127. (Config)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Shumkin, 2017-04-27
@ashumkin

so, you Configurationjust do not equal Linux, but equal (judging by what is used in the path itself), Release
add another variable to control the build platform. For example, Platform
then it will
<When Condition="'$(Platform)'!='Linux'">

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question