Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue Building a single project using msbuild that has multiple configurations

Issue

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.

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" 

I get the following error

 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. 

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

Question

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

like image 944
Aaron M Avatar asked Jan 15 '12 16:01

Aaron M


People also ask

How do I create a project using MSBuild command line?

To build a specific target of a specific project in a solution. At the command line, type MSBuild.exe <SolutionName>. sln , where <SolutionName> corresponds to the file name of the solution that contains the target that you want to execute.

What is the use of MSBuild?

The Microsoft Build Engine is a platform for building applications. This engine, which is also known as MSBuild, provides an XML schema for a project file that controls how the build platform processes and builds software.


2 Answers

Would setting the switch/property /p:OutputPath=Test work for you? It would output the dlls in a directory called Test (I guess you also could use TeamCity variables). Link to similar question/answer: https://stackoverflow.com/a/1083362/90033

like image 64
Konstantin Avatar answered Sep 16 '22 21:09

Konstantin


Using the tfs online I got the same error, this fixed my problem

enter image description here

like image 22
Zinov Avatar answered Sep 16 '22 21:09

Zinov