11

I have a project in visual studio 2010. This project has the following post-build event command lines:

SET TARGET_PROJECT=TestMain
IF NOT EXIST "$(TargetDir)IceBox" (
  XCOPY /E /I /Y "$(SolutionDir)Externals\IceBox" "$(TargetDir)IceBox"
)
IF NOT EXIST "$(TargetDir)bzip2.dll" (
  COPY "$(SolutionDir)Externals\IceBox\bzip2.dll" "$(TargetDir)"
)
XCOPY /E /I /Y "$(SolutionDir)Externals\Infragistics" "$(TargetDir)"

But this commands are just used when I create a debug or a release. When I publish my project will this commands ignored. Gives it a possibility to use this commands when I publish the project?

Thanks for any help.

Waronius
  • 363
  • 2
  • 4
  • 10
  • Perhaps https://stackoverflow.com/questions/3561689/afterpublish-target-not-working will be of use – Spikolynn Aug 22 '17 at 12:23
  • The solution above did not work ok. But this one did: https://stackoverflow.com/questions/19456112/afterpublish-script-doesnt-run-when-i-publish-a-web-app – Spikolynn Aug 22 '17 at 12:43

1 Answers1

11

I recently faced a similar problem. I wanted to run a command 'only' if I published the application and not with every build.

I added a post publish task. Since I don't use MSBuild directly I modified my solution csproj file.

Example:

Solution Name: MyKillerApp

Project File name: MyKillerApp.csproj

Open the file with Notepad++ or other text editor and navigate to the end of the file and find this section(should be almost at the end):

  <PropertyGroup>
    <PreBuildEvent>
    </PreBuildEvent>
  </PropertyGroup>

Then add your postpublish task

  <PropertyGroup>
    <PreBuildEvent>
    </PreBuildEvent>
  </PropertyGroup>
  <Target Name="AfterPublish">
    <Exec Command="..\..\Documentation\DoxyGenExe\createDocs.bat" />
  </Target>

My task runs a bat file that runs Doxygen (a very nice docs creation program) and some other tasks.

You can create a bat file to run any commands is very handy

albert
  • 8,285
  • 3
  • 19
  • 32
Termiux
  • 418
  • 2
  • 7
  • 20