Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Visual Studio post build events be used with ClickOnce publishing?

In Visual Studio 2008, can a post-build event be used with ClickOnce publishing? If so, how?

Out of the box, it looks like I can only use pre-build events and ClickOnce publishing seems to build the project to a different location, before the post build event is launched.

like image 955
Brad Avatar asked Oct 08 '10 01:10

Brad


People also ask

How do I publish my ClickOnce application?

In the Publish wizard, select Folder. In the Specific target page, select ClickOnce. Enter a path or select Browse to select the publish location. In the Install location page, select where users will install the application from.

How to Publish Wizard in Visual Studio?

To access this wizard, on the Build menu, choose Publish SolutionName. You can also access the Publish Wizard from Solution Explorer. Open the shortcut menu for the project node, and then choose Publish.

How do I publish a project in Visual Basic?

In Solution Explorer, right-click the application project and click Properties. The Project Designer appears. Click the Publish tab to open the Publish page in the Project Designer, and click the Publish Wizard button. The Publish Wizard appears.


1 Answers

Looking at the MSBuild files Visual Studio uses, the post build event is run by the Build target. If you run msbuild from the command-line and call the Publish target directly, it definitely calls Build first. If you right-click on the project in VS and click Publish, a trimmed-down target called PublishOnly gets run, on the assumption that VS has already done a build.

Your post build event should be run by Visual Studio when it automatically builds your project prior to publishing. In the Build Events tab of your project's properties, did you set the event to "run always"?

If you want to be more explicit about what happens prior to publishing, there's a BeforePublish target that Publish always looks for, whether it's run by MSBuild or Visual Studio. Edit your project file by hand, and at the bottom you'll see a couple of commented-out Target elements. Add one of your own like this:

<Target Name="BeforePublish">
    <Exec Condition="'$(PostBuildEvent)' != ''" 
          WorkingDirectory="$(OutDir)" Command="$(PostBuildEvent)" />
</Target>

That will run the same post build event you defined in your project, but you could put any MSBuild tasks inside those Target elements.

like image 119
Rory MacLeod Avatar answered Nov 02 '22 23:11

Rory MacLeod