How to use MSBuild on the sfproj?

To help clarify wasabi's answer. Here is what I did to get this working.

I added the following Target to my *.sfproj file

<Target Name="CreatePackage" Condition="'$(CreatePackage)' == 'true'" DependsOnTargets="Package" />

I also modified the Project element DefaultTargets attribute value to be Build;CreatePackage.

To create the package as part of my automated build, I included /p:CreatePackage="true" as an argument to my build solution step.


I solved this. What I did was add a new Target to the .sfproj file, called MaybePublish, and I set it as one of the default targets. MaybePublish has a Condition for '$(Package)' == 'true'. It has DependsOnTarget set to Package. Basically, this target optionally packages the Service Fabric application, if a property is set when building the solution.

It occurs to me this is probably how the DeployOnBuild stuff works in the Web publishing projects. The Service Fabric target files should have this type of support by default.


You can also perform the package step by running MSBuild on the sfproj with the /t:Package switch.