Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build configurations in csproj file

Tags:

c#

build

I have a class library with these property groups in the csproj files:

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <Prefer32Bit>false</Prefer32Bit>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>

If I build this project in a solution that builds under some othe build configuration other than 'Debug' or 'Release' the build will fail for this project because it won't find proper build configuration.

Is there a way to define a default build configuration that will run even if none of the conditions is met?

like image 633
Guy Segal Avatar asked Mar 15 '15 09:03

Guy Segal


People also ask

What does Csproj file contains?

A CSPROJ file is a C# (C Sharp) programming project file created by Microsoft Visual Studio. It contains XML-formatted text that lists a project's included files and compilation options.

What is build configuration?

A build configuration is a collection of settings used to start a build and group the sequence of the builds in the UI. Examples of build configurations are distribution, integration tests, prepare release distribution, "nightly" build. A build configuration belongs to a project and contains builds.

What are Debug and release build configurations?

A Debug configuration supports the debugging of an app, and a Release configuration builds a version of the app that can be deployed.


1 Answers

Just add this definition:

<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
like image 91
Amir Yonatan Avatar answered Oct 12 '22 18:10

Amir Yonatan