本文介绍了如何在sfproj上使用MSBuild?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图在构建服务器上构建我的Service Fabric应用程序.当我生成.sln文件时,不会运行sfproj的Package目标.如预期的那样.我似乎无法让MSBuild运行该目标.

Trying to get my Service Fabric application building on a build server. When I build the .sln file, the sfproj's Package target is not run. As expected. I cannot seem to get MSBuild to run this target.

首先,针对.sln文件进行构建时,唯一可用的目标是标准的构建"和发布"目标.

First, the only targets available when building against the .sln file are the standard Build and Publish targets.

第二,针对.sfproj本身进行构建,可以使目标运行.但是,由于$(BuildPlatform)不匹配,.sfproj引用的项目无法正确构建. .sfproj具有x64平台.我的其他大多数项目都是Any CPU.

Second, building against the .sfproj itself DOES get the target running. However, because of the mismatch of $(BuildPlatform), the projects referenced by the .sfproj do not build correctly. The .sfproj has a x64 platform. Most of my other projects are Any CPU.

我想这不是服务结构问题,而是一般的MSBuild问题.我正在寻找一种不需要统一我项目的所有平台"选项的解决方案. Service Fabric实际上仅是x64,而我的其他项目确实是任何CPU.

This is less of a Service Fabric question and more of a general MSBuild question, I suppose. I'm looking for a solution that does not require me to unify all my project's Platform options. Service Fabric REALLY IS x64 only, and my other projects REALLY ARE Any CPU.

我解决了这个问题.我所做的是在.sfproj文件中添加了一个名为MaybePublish的新目标,并将其设置为默认目标之一. MaybePublish对于'$(Package)' == 'true'具有Condition. DependsOnTarget设置为Package.基本上,如果在构建解决方案时设置了属性,则该目标可以选择打包Service Fabric应用程序.

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.

在我看来,这可能是DeployOnBuild东西在Web发布项目中的工作方式.默认情况下,Service Fabric目标文件应具有这种类型的支持.

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.

推荐答案

我解决了这个问题.我所做的是在.sfproj文件中添加了一个名为MaybePublish的新目标,并将其设置为默认目标之一. MaybePublish的条件为'$(Package)'=='true'.它的DependsOnTarget设置为Package.基本上,如果在构建解决方案时设置了属性,则该目标可以选择打包Service Fabric应用程序.

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.

在我看来,这可能是DeployOnBuild东西在Web发布项目中的工作方式.默认情况下,Service Fabric目标文件应具有这种类型的支持.

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.

这篇关于如何在sfproj上使用MSBuild?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 05:19