问题
我们在我们的解决方案中使用配置转换。例如:调试、测试、暂存、发布 但是,这些配置仅用于我们的 MVC 项目。所有的库只使用 Debug 和 Release,这更有意义,因为我们的库只需要在 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 文件中
问题
有没有一种方法可以解决这个问题而不必为每个库项目添加这些配置?这里闻起来像一个丑陋的黑客。
最佳答案
设置开关/属性 /p:OutputPath=Test
对你有用吗?它会在名为 Test 的目录中输出 dll(我想您也可以使用 TeamCity 变量)。
链接到类似的问题/答案:
https://stackoverflow.com/a/1083362/90033
关于c# - 使用具有多个配置的 msbuild 构建单个项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8871200/