Skip to content

Get the renamed Platform passed in from command-line #4752

@goyzhang

Description

@goyzhang

Steps to reproduce

It is allowed to renamed a platform from "AnyCPU, x86, x64" to a customized name for a solution, such that we can build with a specific platform with command like:

msbuild MSBuildTests.sln -p:Platform=MyPlatform1;Configuration=MyConfig1

We can get MyConfig1 from $(Configuration) in a .csproj, However, there is no way to get the MyPlatform1 argument from $(Platform) as it is overwritten by x64 (assume it is renamed from x64).

There should be a way to get the renamed platform that passed in from command-line when we build on a .sln. Or we already have it?

Project file

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <Platforms>AnyCPU;x64</Platforms>
  </PropertyGroup>

  <Target Name="GetRenamedPlatform">
    <Message Text="$(Platform)" /> <!--this will print x64-->
  </Target>

</Project>

Directory contents:

/
- MSBuildTests.sln
- MSbuildTests/
     - c.cs
     - MSBuildTests.csproj

Command line

`msbuild MSbuildTests.sln -p:platform=MyPlatform1 -t:GetRenamedPlatform`

Expected behavior

Print "MyPlatform1"

Actual behavior

Print "x64"

Environment data

msbuild /version output:
Microsoft (R) Build Engine version 16.2.37902+b5aaefc9f for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

16.2.37902.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions