32
votes

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.

5
I'm not sure if this specifically addresses the issue you're having but you might get some useful information from my SO post over here.David Clarke

5 Answers

13
votes

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

8
votes

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

enter image description here

7
votes

Unfortunately, you will have to modify every project that is used in the solution to have the same build 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.

3
votes

Put an OR condition for the different values on Release for as many different configurations that you have.

eg.

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' Or '$(Configuration)|$(Platform)' == 'Test|AnyCPU'">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
2
votes

One simple solution would be to add a new property to your projects called "DeploymentConfiguration" and have it do the mapping between configs. Example:

  <!-- this is your non-deployment DLL -->
  <!-- Default DeploymentConfiguration to 'Debug' -->
 <DeploymentConfiguration Condition="'$(DeploymentConfiguration)'==''">Debug</DeploymentConfiguartion>
 <Configuration Condition='$(DeploymentConfiguration)'=='Test'">Debug</Configuration>

Then in your MSBuild invocation, pass in

 /p:DeploymentConfiguration=Test

In your deployment MVC you'd just assign DeploymentConfiguration through to Configuration directly.