Question

My projects appear to all have three <PropertyGroup> items.

One:

<PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>

Two: <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
Three: <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">

FinalBuilder has been failing. When I go into the project file and add <OutputPath>bin\Debug\</OutputPath> to the first element in the .csproj file (an MSBuild file as I understand it), the build succeeds.

The remaining two elements already have <OutputPath> defined.

Is this a required field for all three elements? Why is it missing from the first element in my project files?

Was it helpful?

Solution

When MSBuild compiles a project, it takes OutputPath as an argument, to where it should place the build output.

The .csproj file has some default settings. It's in the first <PropertyGroup>.

In the conditional PropertyGroups, there are specific properties, to different configurations and platforms:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">

Properties inside this node overwrites the default one, so it can specialize the build.

To hit the different PropertyGroups, MSBuild takes some argument, for example, hitting "Release|x86", the command looks like this:

msbuild /p:Configuration="Release" /p:Platform="x86" 

MSBuild will use the properties from the default PropertyGroup, and overwrite/use properties from the PropertyGroups that meet the conditions, in this example "Release|x86" to compile the code.

Your problem sounds like MSBuild does not have the right arguments to evaluate the right PropertyGroups.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top