Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command-line Package Service Fabric Application

Our continuous delivery set-up, until recently, was delivering Service Fabric packages using the following command:

msbuild SFApp.sfproj /t:Package

This was necessary because the target Package is unavailable at the solution level. I.e. The command

msbuild SFSolution.sln /t:Package

Fails, as the target does not exist.

As our dependency mesh grows, it gets to a point in which most interfaces projects will not build without a solution file (to work around the "OutputPath does not exist" red herring). There seems to be a way to do that according to this answer. Unfortunately, while targets like Clean work…

msbuild SFSolution.sln /t:SFApplication:Clean
(…snip…)
Build succeeded.
    0 Warning(s)
    0 Error(s)

…the target Package won't!

msbuild SFSolution.sln /t:SFApplication:Package
(…snip…)
Build FAILED.
"SFSolution.sln" (SFApplication:Package target) (1) -> SFSolution.sln.metaproj :
        error MSB4057: The target "SFApplication:Package" does not exist in the
        project. [SFSolution.sln]
    0 Warning(s)
    1 Error(s)

(Solution/project folders/names omitted/paraphrased for clarity. I can provide the actual logs if necessary.)

So the question is: how could I, using the Command Line, build one project using the Package target and the solution file?

Or how can I otherwise package a Service Fabric application from the command line?

like image 331
Ekevoo Avatar asked May 06 '16 19:05

Ekevoo


People also ask

How do I create a Sfpkg?

To create an sfpkg file, start with a folder that contains the original application package, compressed or not. Then, use any utility to zip the folder with the extension ". sfpkg". For example, use ZipFile.


1 Answers

It's bad idea to compile sfproj file(and any other project file) without sln, because it can bring wrong content to its output from referenced projects. Only solution has a knowledge about what project to compile in what configuration.

To make Package similar to "Right Click->Package" in VS: Just add to your sfproj the following target

  <Target Name="ForcePackageTarget" AfterTargets="Build" Condition="'$(ForcePackageTarget)' =='true'">
    <CallTarget Targets="Package"/>
  </Target>

And then running normal build on solution you may trigger the package step by /p:ForcePackageTarget=true :

msbuild yoursolution.sln /t:Build /p:ForcePackageTarget=true /p:Configuration=Release /p:Platform=x64

Actually it performs two-in-one steps, build and package, with respect to Solution Configurations on all referenced projects

like image 102
jenkas Avatar answered Oct 06 '22 21:10

jenkas