Changing csproj OutputType based on project configuration

前端 未结 1 1701
[愿得一人]
[愿得一人] 2020-12-31 18:38

I need to build a C# project as either WinExe or Library depending on the project\'s configuration.

I\'ve tried both of these methods with no luck:

1) In the

相关标签:
1条回答
  • 2020-12-31 18:47

    In the top of your .csproj file you will have two sections that look a bit like this:

    <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>
    

    Add your OutputType elements to these two conditional PropertyGroup sections and make sure that you remove all other OutputType elements - I've just tested it and it does exactly what you are asking for.

    Yes this is very similar to what you have already done, but I know for a fact that the above method works because I've just tried it - my only guess is that something somewhere else in your build is messing things up.

    0 讨论(0)
提交回复
热议问题