使用具有多个配置的msbuild构建单个项目时出现问题 [英] Issue Building a single project using msbuild that has multiple configurations

查看:119
本文介绍了使用具有多个配置的msbuild构建单个项目时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题

我们在解决方案中使用配置转换.例如:调试,测试,登台,发布 但是,这些配置仅在我们的MVC项目中使用.所有的库都只使用Debug and Release,这更有意义,因为我们的库只需要以调试模式或发布模式构建.

We are using config transforms inside our solution. For example: Debug, Test, Staging, Release However, those configurations are only used on our MVC projects. all of the libraries only use Debug and Release, which makes more sense, because our libraries only need to be built in either debug mode, or release mode.

尝试从命令行构建单个项目时,会出现此问题.我需要能够执行此操作,以便将我们的构建从TeamCity自动部署到我们的测试环境.

The issue arises when attempting to build a single project from the command line. I need to be able to do this in order to auto deploy our builds from TeamCity to our testing environment.

当我像这样构建单个项目时

When I build the single project like this

msbuild myproject.csproj 
/t:Build 
/P:Configuration=Test 
/P:Platform=AnyCPU 
/P:DeployOnBuild=True 
/P:DeployTarget=MSDeployPublish 
/P:MsDeployServiceUrl=https://SERVER:8172/MsDeploy.axd 
/P:AllowUntrustedCertificate=True 
/P:MSDeployPublishMethod=WMSvc 
/P:CreatePackageOnPublish=True 
/P:UserName=Username 
/P:Password=Passsword 
/P:DeployIisAppPath="IISAPPPATH"

我收到以下错误


myproject.csproj" (Build target) (1) ->
"C:\src\myproject.csproj" (default target) (18) ->
  c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(483,9)
: error : The OutputPath property is not set for project 'sampleLibrary.csproj'.  
Please check to make sure that you have specified a valid combination of
 Configuration and Platform for this project.  Configuration='Test'
  Platform='AnyCPU'.  You may be seeing this message because you are trying
 to build a project without a solution file, and have specified a
 non-default Configuration or Platform that doesn't exist for this project.

我知道这是什么意思,因为我的sampleLibrary没有用于测试的配置,并且sampleLibrary的映射将包含在我的.sln文件中

I know what it means, because my sampleLibrary does not have a configuration for test, and the mapping for the sampleLibrary would be contained in my .sln file

问题

是否有一种解决方法,而不必为每个库项目添加这些配置?这里闻起来像一个丑陋的骇客.

Is there a way to resolve this without having to add those configurations for every library project? It smells like an ugly hack here.

推荐答案

不幸的是,您将必须修改解决方案中使用的每个项目以使其具有相同的构建路径.

Unfortunately, you will have to modify every project that is used in the solution to have the same build path.

但是,如果所有项目无论配置如何都构建到同一路径,这是一件很容易的事情:在项目属性的Build选项卡中,从Configuration下拉列表中选择All Configurations,然后更改Output path.

However, this is a pretty easy thing to do if your projects all build to the same path regardless of configuration: in the project properties' Build tab, select All Configurations from the Configuration dropdown and then change the Output path.

这将为项目文件中所有尚不存在的配置创建条目,并为所有配置设置相同的输出路径.

This will create entries for all of the configurations in the project file that do not already existing and set the same output path for all configurations.

这篇关于使用具有多个配置的msbuild构建单个项目时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆