Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding /p:Platform="Any CPU" parameter forces the build in Debug configuration

I run the following to build my solution (all projects in C#):

MSBuild.exe foo.sln /t:Build /p:Configuration=Release /p:Platform="Any CPU"

It builds it in Debug configuration. If i remove the reference to "Any CPU"

MSBuild.exe foo.sln /t:Build /p:Configuration=Release

the build is built in Release configuration.

Why is that? Am I missing something simple here?

like image 671
AngryHacker Avatar asked May 17 '18 18:05

AngryHacker


People also ask

What is debug configuration in C++?

In debug configuration, your program compiles with full symbolic debug information and no optimization. Optimization complicates debugging, because the relationship between source code and generated instructions is more complex.

How do I build a project for a specific platform?

If you select one of the platforms included with Visual Studio, the properties for your project are modified to build your project for the selected platform. On the menu bar, choose Build > Configuration Manager.

How do I change the platform configuration in project designer?

In the Type or select the new platform list, choose x64. If you give your configuration a new name, you may have to modify the settings in the Project Designer to target the correct platform. If you want to copy the settings from a current platform configuration, choose it, and then choose the OK button.

How do I configure a project to target a 64-bit platform?

To configure a project to target a 64-bit platform On the menu bar, choose Build > Configuration Manager. In the Active solution platform list, choose a 64-bit platform for the solution to target, and then choose the Close button. If the platform that you want doesn't appear in the Active solution platform list, choose New.


1 Answers

Adding /p:Platform=“Any CPU” parameter forces the build in Debug configuration

The output directory of the project is related to the property of OutputPath in the PropertyGroup in the project file foo.csproj.

According to your description, you may not have configured the target platform and OutputPath correctly in your project file, for example:

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

If we give the <OutputPath>bin\Debug\</OutputPath> for the Release configuration, then we will get the output in the Debug folder.

So, to resolve this issue, you need to check the property OutputPath in the project file, make sure it match the target platform.

Hope this helps.

like image 121
Leo Liu-MSFT Avatar answered Sep 21 '22 07:09

Leo Liu-MSFT