命令行包 Service Fabric 应用程序 [英] Command-line Package Service Fabric Application
问题描述
直到最近,我们的持续交付设置还在使用以下命令交付 Service Fabric 包:
Our continuous delivery set-up, until recently, was delivering Service Fabric packages using the following command:
msbuild SFApp.sfproj /t:Package
这是必要的,因为目标 Package 在解决方案级别不可用.IE.命令
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.
随着我们的依赖网格的增长,大多数接口项目将无法在没有解决方案文件的情况下构建(解决方案)OutputPath 不存在"红鲱鱼).根据这个答案似乎有办法做到这一点.不幸的是,虽然像 Clean 这样的目标可以工作......
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)
…目标包不会!
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)
(解决方案/项目文件夹/名称省略/解释清楚.如有必要,我可以提供实际日志.)
所以问题是:我如何使用命令行,使用 Package 目标和 solution 文件构建 one 项目?
So the question is: how could I, using the Command Line, build one project using the Package target and the solution file?
或者我如何才能从命令行打包 Service Fabric 应用程序?
Or how can I otherwise package a Service Fabric application from the command line?
推荐答案
在没有 sln 的情况下编译 sfproj 文件(和任何其他项目文件)是个坏主意,因为它可能会给引用项目的输出带来错误的内容.只有解决方案知道在什么配置中编译什么项目.
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.
在VS中制作类似于右键->包"的包:只需将以下目标添加到您的 sfproj 中
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>
然后在解决方案上运行正常构建,您可以通过/p:ForcePackageTarget=true 触发包步骤:
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
这篇关于命令行包 Service Fabric 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!