sdk: Default platform target in Properties window is incorrect

From @davidmatson on August 28, 2017 19:40

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net47</TargetFramework>
  </PropertyGroup>
</Project>
using System;
using System.Reflection;

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine(Environment.Is64BitProcess);
        ImageFileMachine b;
        typeof(Program).Assembly.ManifestModule.GetPEKind(out PortableExecutableKinds a, out b);
        Console.WriteLine($"{a}: {b}");
    }
}

Actual output:

True
ILOnly: I386

But, properties window shows: image

Copied from original issue: dotnet/project-system#2744

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Reactions: 3
  • Comments: 29 (22 by maintainers)

Commits related to this issue

Most upvoted comments

From @tannergooding on August 28, 2017 21:1

You can workaround the issue for the time being by explicitly specifying <PlatformTarget>AnyCPU</PlatformTarget> in your project file.

@davkean, based on last comment, I was able to make the platform target set to x64 by explicitly setting all platform-like properties for net462 xunit project:

  <PropertyGroup>
    <TargetFramework>net462</TargetFramework>

    <!-- ideally we should only specify PlatformTarget like old csproj -->
    <!-- upstream issue: https://github.com/dotnet/sdk/issues/1560 -->
    <Platform>x64</Platform>
    <Platforms>$(Platform)</Platforms>
    <PlatformName>$(Platform)</PlatformName>
    <PlatformTarget>$(Platform)</PlatformTarget>
  </PropertyGroup>

then in SLN, added x64 configurations like this:

Global
  GlobalSection(ProjectConfigurationPlatforms) = postSolution
    {GUID}.Debug|x64.ActiveCfg = Debug|x64
    {GUID}.Debug|x64.Build.0 = Debug|x64
    {GUID}.Release|x64.ActiveCfg = Release|x64
    {GUID}.Release|x64.Build.0 = Release|x64
  EndGlobalSection
EndGlobal

After that, property page shows only one option:

Platform: Active (x64)

(which was the desired behavior)