Change csproj OutputType based on project configuration

I need to create a C # project like WinExe or Library depending on the configuration of the project.

I tried both of these methods with no luck:

1) In a common PropertyGroup:

<OutputType Condition=" '$(Configuration)' == 'Release' ">WinExe</OutputType> <OutputType Condition=" '$(Configuration)' == 'Debug' ">Library</OutputType>

2) In the conditional group of properties:

<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> <OutputType>WinExe</OutputType> </PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <OutputType>Library</OutputType> </PropertyGroup>

None of these methods work, and OutputType is always WinExe. The strange thing is that if I change all instances of WinExe to a library, then it is always a Library. This makes me think that he is reading them successfully, but either in a strange manner, or that WinExe takes precedence over the Library.

Any ideas?

+5
source share
1 answer

.csproj , :

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
  <OutputType>Library</OutputType>
  <!-- Other properties go here -->
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
  <OutputType>Exe</OutputType>
  <!-- Other properties go here -->
</PropertyGroup>

OutputType PropertyGroup , OutputType - , , .

, , , , , - , - .

+7

All Articles