Command-line Package Service Fabric Application

前端 未结 5 1337
Happy的楠姐
Happy的楠姐 2021-02-08 21:47

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

msbuild SFApp.sfproj /t:Package
相关标签:
5条回答
  • 2021-02-08 22:22

    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

    0 讨论(0)
  • 2021-02-08 22:23

    MSBuild only supports a small set of target names that can be specified at the solution level. As you've discovered, Package is not one of them. You'll need to execute two separate calls to MSBuild: one which builds the solution and one which calls the Package target on the sfproj. The Package target of an sfproj has a dependency on the Build target so it will ensure that the sfproj and its project dependencies are built.

    0 讨论(0)
  • 2021-02-08 22:32

    Use the below script.

    C:\Program Files (x86)\Microsoft Visual Studio 14.0> msbuild "Fabric.sfproj" /t:Package /p:Configuration=Release

    Service fabric requires Target to be set in x64 platform, So change all you reference projects target to x64 platform.

    you can do this by using configuration properties of your solution. If x64 is not listed in 'Configuration Properties' click configuration manager in the same window and under platform column for the required project add new project platform as x64.

    Hope this works for you.

    0 讨论(0)
  • 2021-02-08 22:34

    I had the same problem and fixed it by changing the Platform in the failing projects to explicitly build for x64.

    Click Build > Configuration Manager and make sure that the assemblies are compiled for the x64 platform, that should also set the Output Paths in the corresponding .csproj files.

    The actual command line action that is being executed is this:

    "C:\Program Files (x86)\MSBuild\14.0\bin\amd64\msbuild.exe" "C:\agent\_work\1\s\Project\SFProject.sfproj" /t:Package /p:platform="x64" /p:configuration="release" /p:VisualStudioVersion="14.0"

    0 讨论(0)
  • 2021-02-08 22:39

    We have had the exact same problem as you had and I have been looking around for a solution all over the web and did some experiments. Those are the steps that worked for us:

    1. Don't manually add a target anywhere as suggested by other answers on StackOverflow. Not necessary. Especially in a CI environment, you want to build the projects separately anyways.
    2. Prepare the projects in the Solution: Change the target platform for all projects to x64
    3. Build the application

    msbuild.exe SFAplication.xproj /p:Configuration=Release /target:rebuild

    1. Package the App

    msbuild.exe SFAplication.sfproj /p:Configuration=Release /target:Package

    0 讨论(0)
提交回复
热议问题