In MVC4, if I create a new build configuration for all projects in a solution, I get the following when building the web .csproj alone:
msbuild Company.Directory.Web.csproj /p:Configuration=Dev
[Error] C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(483, 9): The OutputPath property is not set for project 'Company.Directory.Web.csproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Dev' 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.
However, the OutputPath
property is set!
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Dev|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
<DeployIisAppPath>Port 80/directory/dev</DeployIisAppPath>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{285FBF79-7933-4AF9-AAAF-25EE7734AAAA}</ProjectGuid>
<ProjectTypeGuids>{E3E379DF-F4C6-4180-9B81-6769533ABE47};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Company.Directory.Web</RootNamespace>
<AssemblyName>Company.Directory.Web</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<MvcBuildViews>false</MvcBuildViews>
<UseIISExpress>true</UseIISExpress>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<!-- ... -->
Is this a bug? How can I fix it?
It turns out that the first
PropertyGroup
is important. Visual Studio inserted the new configuration (Dev)PropertyGroup
before it for some reason. I'm guessing its a bug. I fixed it by moving the new configuration after the others.I got the same error for an Azure WebRole-project and added the
<PropertyGroup>
elements manually into the .csproj file. However, I accidentally put them below a couple of<Import>
statements. The build will fail with the error in the question.Right order
Wrong order
I had similar error when trying to build from the command line with msbuild.exe. My problem was I was specifying 'Any CPU' when I should have put 'AnyCPU'.
I had two PropertyGroup elements without conditions, and I think the latter was preventing the former from taking effect. I consolidated all of the child items into the first PropertyGroup element and got rid of the second, and things started working after that.
I had similar problem with
Azure
project. After I added new configurationRelease-CLOUD-STAGE
into solution, I started to receive the same error:After I opened the
ccproj
file in editor and searched for the new configuration, I saw this near the end of it:everything looked fine to me - existing configuration
Release-CLOUD
worked well, but new one did not. Turns out that there are TWOPropertyGroup
elements in that project file - one - COMPLETE - in the very beginning of the project file:and then for some reason there is another one, SHORT version I showed above, inserted close to the end of the file. After I created proper COMPLETE version of the
PropertyGroup
element for newRelease-CLOUD-STAGE
configuration (and removed both SHORT versions) - everything complied.I'm not sure if that's Azure-specific but I did waste some time on this so I would like to share my findings as well.