Selecting a Target Framework (TFM) via MSBuild command line parameter

Vic R 1 Reputation point
2022-03-29T06:16:57.517+00:00

I have a solution with multi-target project, created like so:

  <PropertyGroup>
    <TargetFrameworks>net461;net472</TargetFrameworks>
    <AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
    <OutputType>Library</OutputType>
  </PropertyGroup>

But every time I build the solution, it's being built first for net461, and then for net472.

What I am trying to achieve is two-fold:

  • Being able to select a specific TFM to build from within Visual Studio IDE (say, I only want to build net472)
  • Same goal as above, but achieve it via MSBuild command line.

Passing something like /p:TargetFrameworks="net472" does not really work.

Any help/advice is greatly appreciated.

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
32,740 questions
{count} votes