Search code examples
c#compilationvisual-studio-2019

c# project build mapping not showing in Configuration manager (VS2019)


I have several projects without build mapping showing, despite definitions in the project (csproj) file. Using VS2019.

What is happening ? How to correct it ?

"not showing":

not target for projects

on project file content:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{4E224C17-D9DA-4C83-B026-22967D0E70C3}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>CPUMetrics</RootNamespace>
    <AssemblyName>CPUMetrics</AssemblyName>
    <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <Deterministic>true</Deterministic>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>..\x64\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <PlatformTarget>x64</PlatformTarget>
    <LangVersion>9</LangVersion>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>..\x64\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <LangVersion>9</LangVersion>
    <PlatformTarget>x64</PlatformTarget>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\x64\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <DebugType>full</DebugType>
    <PlatformTarget>x64</PlatformTarget>
    <LangVersion>9</LangVersion>
    <ErrorReport>prompt</ErrorReport>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
    <OutputPath>bin\x64\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <Optimize>true</Optimize>
    <DebugType>pdbonly</DebugType>
    <PlatformTarget>x64</PlatformTarget>
    <LangVersion>9</LangVersion>
    <ErrorReport>prompt</ErrorReport>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="PresentationCore" />
    <Reference Include="PresentationFramework" />
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Xml" />
    <Reference Include="WindowsBase" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Extensions.cs" />
    <Compile Include="future\CpuID.cs" />
    <Compile Include="future\IA32ThermStatus.cs" />
    <Compile Include="future\SafeTokenHandle.cs" />
    <Compile Include="not used\CoresPack.cs" />
    <Compile Include="CPUMetricsViewModel.cs" />
    <Compile Include="CPUSensorPack.cs" />
    <Compile Include="ICPUViewModel.cs" />
    <Compile Include="serialize\ISerial.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
    <Compile Include="SensorPackFactory.cs" />
    <Compile Include="CPUSensorPackStruct.cs" />
    <Compile Include="serialize\SerBin.cs" />
    <Compile Include="serialize\SerJson.cs" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Newtonsoft.Json">
      <Version>13.0.1</Version>
    </PackageReference>
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\ShutterLib\ShutterLib.csproj">
      <Project>{29966685-E141-4BFB-944E-36DC5116A35B}</Project>
      <Name>ShutterLib</Name>
    </ProjectReference>
  </ItemGroup>
  <ItemGroup />
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

With VS2019, nothing is visible and it does not change after operations (using configuration manager, restarting VS2019).

With VS2022, AnyCPU is selected and visible but Configuration Manager does not allow any change (I do the change (creating x64 configuration from AnyCPU as suggested by wenbingeng-MSFT), but without any impact, AnyCPU remains, event after reload and reboot):

messages: VS2022 messages

configuration manager: VS2022 confmanager


Solution

  • I managed to resolve the problem for one c# .net5+ project stuck at AnyCPU:

    this line should be deleted in the project file:

    <PlatformTarget>x64</PlatformTarget>
    

    an replaced by:

    <Platforms>AnyCPU;x64</Platforms>
    

    After that, I could just select x64 as platform for this project. This shows at least one problem that Configuration Manager could not resolve as it is (17.5.1). This also could help create a minimal repro.