问题
我们在解决方案中使用配置转换。例如:Debug、Test、Staging、Release。然而,这些配置仅用于我们的MVC项目。所有库只使用Debug和Release,这更有意义,因为我们的库只需要以调试模式或发布模式构建。
当尝试从命令行构建单个项目时,问题就出现了。我需要能够这样做,以便从TeamCity自动部署我们的构建到测试环境。
当我像这样构建单个项目时:
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文件中。
问题是:有没有一种方法可以解决这个问题,而不必为每个库项目添加这些配置?这听起来像一个丑陋的hack。